// Copyright 2022 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.cloud_upload.mojom; // The selected action when the user closes the dialog. enum UserAction { kCancel, kCancelGoogleDrive, kCancelOneDrive, kSetUpOneDrive, kUploadToGoogleDrive, kUploadToOneDrive, kConfirmOrUploadToGoogleDrive, kConfirmOrUploadToOneDrive, }; // Used for metrics to represent each individual page of the dialog, and should // be kept in sync with OfficeSetupPage in enums.xml. These values are // persisted to logs. Entries should not be renumbered and numeric values should // never be reused. enum MetricsRecordedSetupPage { kFileHandlerPage = 0, kMoveConfirmationOneDrive = 1, kMoveConfirmationGoogleDrive = 2, kOneDriveSetupWelcome = 3, kOneDriveSetupPWAInstall = 4, kOneDriveSetupODFSMount = 5, kOneDriveSetupComplete = 6, }; // Operation used to upload the source file. enum OperationType { kMove, kCopy, }; // A local file task that is displayed in the `kFileHandlerDialog` which the // user could select to open the files. The `position` is the tasks position // in a vector with the other `DialogTask`s. struct DialogTask { int32 position; string title; string app_id; string icon_url; }; struct OneDriveSetupDialogArgs { // True if the setup flow should end with setting Microsoft 365 as default // handler. bool set_office_as_default_handler; }; struct MoveConfirmationOneDriveDialogArgs { // Indicates what operation is used to upload the source file (copy or move). OperationType operation_type; }; struct MoveConfirmationGoogleDriveDialogArgs { // Indicates what operation is used to upload the source file (copy or move). OperationType operation_type; }; struct ConnectToOneDriveDialogArgs {}; struct FileHandlerDialogArgs { // The local file tasks the user can pick from to open the files. Displayed in // the `kFileHandlerDialog` dialog. array local_tasks; // Whether Google Workspace should be displayed in the `kFileHandlerDialog` // dialog. bool show_google_workspace_task; // Whether Microsoft 365 should be displayed in the `kFileHandlerDialog` // dialog. bool show_microsoft_office_task; }; union DialogSpecificArgs { FileHandlerDialogArgs file_handler_dialog_args; OneDriveSetupDialogArgs one_drive_setup_dialog_args; MoveConfirmationOneDriveDialogArgs move_confirmation_one_drive_dialog_args; MoveConfirmationGoogleDriveDialogArgs move_confirmation_google_drive_dialog_args; ConnectToOneDriveDialogArgs connect_to_one_drive_dialog_args; }; // Contains the arguments used to set up the dialog. struct DialogArgs { // List of files that will be uploaded on dialog close if the user completes // the setup. May be empty if the dialog wasn't initiated from a file handler. array file_names; // Contains arguments specific to the given dialog. DialogSpecificArgs dialog_specific_args; }; // Lives in the browser process. A renderer uses this to create a page handler // that enables communication between a renderer and the browser process. interface PageHandlerFactory { // Creates a page handler to enable communication with the browser process. CreatePageHandler(pending_receiver handler); }; // Lives in the browser process. A renderer uses this to invoke methods that // are implemented in the browser process. interface PageHandler { // Returns arguments passed to the dialog on creation. Might return nothing if // called outside of a normal flow (say, when opening chrome://cloud-upload // directly in the browser). GetDialogArgs() => (DialogArgs? args); // Returns whether or not the Office web app is installed. IsOfficeWebAppInstalled() => (bool installed); // Attempts to install the Office web app. Returns whether the web app // successfully installed or was already installed. InstallOfficeWebApp() => (bool installed); // Returns whether or not the OneDrive filesystem is mounted. IsODFSMounted() => (bool mounted); // Starts the OneDrive authentication process. SignInToOneDrive() => (bool success); // Returns the user selected action and requests the dialog to be closed. RespondWithUserActionAndClose(UserAction response); // Returns the user selected local file task to launch and requests the // dialog to be closed. RespondWithLocalTaskAndClose(int32 task_position); // Set Office as the default file handler for office files and mark the // setup as complete so that it does not need to be started again. SetOfficeAsDefaultHandler(); // Get the preference for whether we should always move office files to // Google Drive without asking the user first. GetAlwaysMoveOfficeFilesToDrive() => (bool always_move); // Set the preference for whether we should always move office files to // Google Drive without asking the user first. SetAlwaysMoveOfficeFilesToDrive(bool always_move); // Get the preference for whether we should always move office files to // OneDrive without asking the user first. GetAlwaysMoveOfficeFilesToOneDrive() => (bool always_move); // Set the preference for whether we should always move office files to // OneDrive without asking the user first. SetAlwaysMoveOfficeFilesToOneDrive(bool always_move); // Get the preference for whether the move to Drive confirmation dialog has // been shown before. GetOfficeMoveConfirmationShownForDrive() => (bool move_confirmation_shown); // Get the preference for whether the move to OneDrive confirmation dialog // has been shown before. GetOfficeMoveConfirmationShownForOneDrive() => (bool move_confirmation_shown); // Records the page at which the setup was cancelled. RecordCancel(MetricsRecordedSetupPage page); };