// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module ash.projector.mojom;
import "ash/webui/projector_app/public/mojom/projector_types.mojom";
import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/safe_base_name.mojom";
import "url/mojom/url.mojom";
// UntrustedProjectorPageHandler handles requests that come from the
// javascript to the browser process.
interface UntrustedProjectorPageHandler {
// Requested by the Projector SWA to check the new screencast precondition
// state.
GetNewScreencastPrecondition() => (NewScreencastPrecondition precondition);
// Requested by the Projector SWA to check if SODA is not available and should
// be downloaded. Returns false if the device doesn't support SODA.
ShouldDownloadSoda() => (bool should_download);
// Requested by the Projector SWA to trigger SODA installation.
// Returns true if installation was triggered. The installation progress
// is returned via the OnSoda* methods defined in UntrustedProjectorPage
// below.
InstallSoda() => (bool triggered);
// Requested by the Projector SWA to fetch a list of screencasts pending to
// upload or failed to upload.
GetPendingScreencasts() => (array<PendingScreencast> pending_screencasts);
// Requested by the Projector SWA to get the value of a user pref.
GetUserPref(PrefsThatProjectorCanAskFor pref)
=> (mojo_base.mojom.Value value);
// Requested by the Projector SWA to get the value of a user pref.
SetUserPref(PrefsThatProjectorCanAskFor pref, mojo_base.mojom.Value value)
=> ();
// Requested by the Projector SWA to open the Chrome feedback dialog.
OpenFeedbackDialog() => ();
// Requests the handler to start a new projector session. The request will
// fail if the new screencast preconditions are not met.
StartProjectorSession(
mojo_base.mojom.SafeBaseName storage_dir_name) => (bool success);
// Used to send xhr requests through the browser process. This is
// needed due to cross-origin-resource-sharing restriction set by
// Google Drive.
// The parameters for the request are the following:
// 1. The request URL
// 2. The request method, for example: GET
// 3. The request body data.
// 4. A bool to indicate whether or not to use end user credential to
// authorize the request.
// 5. A bool to indicate whether or not to use api key to authorize the
// request.
// 6. Additional headers objects.
// 7. The email address associated with the account
SendXhr(
url.mojom.Url url,
RequestType method,
string? request_body,
bool use_credentials,
bool use_api_key,
map<string, string>? headers,
string? account_email) => (XhrResponse response);
// Requested by the Projector SWA to list the available accounts (primary and
// secondary accounts) in the current session. The list of accounts will be
// used in the account picker in the SWA.
GetAccounts() => (array<Account> accounts);
// Requested by the Projector SWA to fetch a single video from DriveFS.
// Launches the given DriveFS video file with `video_file_id` into the
// Projector app. The `resource_key` is an additional security token needed to
// gain access to link-shared files. Since the `resource_key` is currently
// only used by Googlers, the `resource_key` might be empty.
GetVideo(string video_file_id, string? resource_key) =>
(GetVideoResult result);
};
// Implemented in Javascript to handle requests from the browser process.
interface UntrustedProjectorPage {
// Called by the browser process when the precondition for starting a new
// projector session changes.
OnNewScreencastPreconditionChanged(NewScreencastPrecondition precondition);
// Called by the browser process when SODA installation is making progress.
OnSodaInstallProgressUpdated(int32 progress);
// Called by the browser process when SODA has been installed.
OnSodaInstalled();
// Called by the browser process when SODA installation has
// encountered an error.
OnSodaInstallError();
// Called by the browser process when the pending
// screencasts are being uploaded to google drive change.
OnScreencastsStateChange(
array<PendingScreencast> pending_screencasts);
};
// Implemented in C++ in the browser process to set up the communication between
// the UntrustedProjectorPage and UntrustedProjectorPageHandler.
interface UntrustedProjectorPageHandlerFactory {
// Set up the communication between the browser process and the javascript.
Create(pending_receiver<UntrustedProjectorPageHandler> handler,
pending_remote<UntrustedProjectorPage> page);
};