chromium/chrome/browser/ui/webui/app_home/app_home.mojom

// 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 app_home.mojom;

import "url/mojom/url.mojom";

import "chrome/browser/web_applications/mojom/user_display_mode.mojom";

// The RunOnOsLoginModes must be kept in sync with RunOnOsLoginMode in
// chrome/browser/web_applications/web_app_constants.h
enum RunOnOsLoginMode {
  // kNotRun: The web app will not run during OS login.
  kNotRun = 0,
  // kWindowed: The web app will run during OS login and will be launched as
  // normal window. This is also the default launch mode for web apps.
  kWindowed = 1,
  // kMinimized: The web app will run during OS login and will be launched as a
  // minimized window.
  kMinimized = 2,
};

struct AppInfo {
  // The app id.
  string id;
  // The first url to load when app start launching.
  url.mojom.Url start_url;
  // The app's name.
  string name;
  // The app's icon url showing on `chrome://apps`.
  url.mojom.Url icon_url;
  // Whether need to show `RunOnOsLoginMode` menu item or not.
  bool may_show_run_on_os_login_mode;
  // Whether need to show `RunOnOsLoginMode` menu item checked or not.
  bool may_toggle_run_on_os_login_mode;
  // The app's `RunOnOsLoginMode`, including `RunOnOsLoginModeNotRun` and
  // `RunOnOsLoginModeWindowed`.
  RunOnOsLoginMode run_on_os_login_mode;
  // Whether the app is installed locally.
  bool is_locally_installed;
  // Whether the app open in a app window or as a browser tab.
  bool open_in_window;
  // Whether this app can be uninstalled by user.
  bool may_uninstall;
  // If this app is a deprecated chrome app.
  bool is_deprecated_app;
  // If this is an extension that came from the web store.
  url.mojom.Url? store_page_url;
};

struct ClickEvent {
  // TODO(crbug.com/40234138): Use enum class to represent button event.
  double button;
  bool alt_key;
  bool ctrl_key;
  bool meta_key;
  bool shift_key;
};

interface PageHandlerFactory {
  CreatePageHandler(pending_remote<Page> page,
                    pending_receiver<PageHandler> handler);
};

// Renderer to browser interface to support chrome://apps WebUI.
interface PageHandler {
  // Get all apps' information that defined in `AppInfo`.
  GetApps() => (array<AppInfo> app_list);
  // Gets the i18n'ed string for the label for removing deprecated apps.
  GetDeprecationLinkString() => (string link_string);
  // Uninstall app for specific `app_id`.
  UninstallApp(string app_id);
  // Open app’s site setting page.
  ShowAppSettings(string app_id);
  // Create shortcut link for app.
  CreateAppShortcut(string app_id) => ();
  // Launch app for specific `app_id`.
  // `source` is the launch source used for metrics reporting,
  // see `AppLaunchBucket` in extension_constants.h for more detail.
  // `click_event` is used for determining launch container for apps.
  LaunchApp(string app_id, ClickEvent? click_event);
  // Used to set the Run On OS Login Modes from the frontend of an app.
  SetRunOnOsLoginMode(string app_id, RunOnOsLoginMode run_on_os_login_mode);
  // Open the deprecated apps dialog.
  LaunchDeprecatedAppDialog();
  // Install app and set this app locally installed.
  // A locally installed app has shortcuts installed on various UI surfaces.
  InstallAppLocally(string app_id);
  // Set user display mode for web app.
  SetUserDisplayMode(string app_id, web_app.mojom.UserDisplayMode display_mode);
};

// The `Page` interface is used for sending mojom action messsage
// from backend to frontend.
interface Page {
  // Inform frontend that an app is successfully installed
  // and instruct frontend to update data.
  AddApp(AppInfo app_info);
  // Inform frontend that an app is uninstalled.
  RemoveApp(AppInfo app_info);
};