// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module crosapi.mojom;
import "chromeos/crosapi/mojom/app_service_types.mojom";
import "chromeos/crosapi/mojom/ui_constants.mojom";
// Interacts with the app service. Implemented in ash-chrome.
// This is a generic app-publisher interface that is used by the implementation
// for both Web Apps and Chrome Apps in Lacros.
// Next version: 3
// Next method id: 3
[Stable, Uuid="238dd8e0-480e-49f4-a3a0-28e610ef7119"]
interface AppPublisher {
// Publish a stream of apps from lacros-chrome.
// |deltas| holds a sparse data structure that includes the update App data
// from the existing app state in app service.
OnApps@0(array<App> deltas);
// Lacros exposes an AppController interface to Ash. This allows Ash to
// launch, or otherwise interact with Apps that run in Lacros.
[MinVersion=1]
RegisterAppController@1(pending_remote<AppController> controller);
// Receives a stream of accesses from lacros-chrome, and saves to
// AppCapabilityAccess.
[MinVersion=2]
OnCapabilityAccesses@2(array<CapabilityAccess> deltas);
};
// Interacts with the app service. Implemented in lacros-chrome and called in
// ash-chrome.
// Next version: 22
// Next method id: 22
[Stable, Uuid="2031a614-3f0b-4111-8977-fd96fd780cb7"]
interface AppController {
// Directly uninstalls |app_id| without prompting the user.
// If |clear_site_data| is true, any site data associated with the app will
// be removed.
// If |report_abuse| is true, the app will be reported for abuse to the Web
// Store.
[MinVersion=1]
Uninstall@1(
string app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse);
// Pauses an app to stop the current running app, and apply the icon effect
// to indicate the app is paused.
// Pause a paused app will make the app stay paused, and pause an app
// that is not currently running will only change the icon to paused
// indication and make the app in pause state when the app is launched the
// next time.
[MinVersion=3]
PauseApp@2(string app_id);
// Unpauses an app, and recover the icon effect for the app to indicate
// the app is no longer paused.
// Unpause an unpaused app will make the app stay unpaused, and unpause
// an app that is not currently running will only change the icon back to
// normal state and make the app in normal state when the app is launched
// the next time.
[MinVersion=3]
UnpauseApp@3(string app_id);
// Returns the context menu items for an app with |app_id| to show in app
// list and shelf. This interface only returns menu items that needs to be
// populated in lacros-chrome (e.g. app-specific shortcuts).
[MinVersion=4]
GetMenuModel@4(string app_id) => (MenuItems menu_items);
// Load icon for an app with |app_id| from lacros-chrome.
// |icon_key| contains the arguments for an app icon, see
// apps::mojom::IconKey for more details. |icon_type| represent the icon
// format requested (e.g. compressed, uncompressed. etc). |size_hint_in_dip|
// is a hint of how big the icon should be. All these fields are necessary
// to fill to get the required icon.
// There should always be a return value for this method. If there is an
// error during the loading, the return value should be a default IconValue
// struct, with IconType = kUnknown to indicate it's an error case. If loading
// succeeded, the size of the returning icon is expected to be as close as
// possible with the |size_hint_in_dip| set in the interface, but may not be
// exactly the same.
// DEPRECATED. Use GetCompressedIcon() instead.
[MinVersion=5]
DEPRECATED_LoadIcon@5(
string app_id,
IconKey icon_key,
IconType icon_type,
int32 size_hint_in_dip) => (IconValue icon_value);
// Requests a compressed icon data for an app identified by `app_id` from
// lacros-chrome. The icon is identified by `size_in_dip` and `scale_factor`.
// Calls `callback` with the result.
[MinVersion=20]
GetCompressedIcon@20(
string app_id,
int32 size_in_dip,
ResourceScaleFactor scale_factor) => (IconValue icon_value);
// Opens the app platform settings page for the app with |app_id|.
// e.g. for web app, it opens the Chrome site settings page for the app.
[MinVersion=6]
OpenNativeSettings@6(string app_id);
// Set the window display mode for the app identified by |app_id|.
// |window_mode| represents how the app will be open in (e.g. in a
// standalone window or in a browser tab).
[MinVersion=7]
SetWindowMode@7(
string app_id,
WindowMode window_mode);
// Launch the app with |params|. The params include |app_id|,
// |launch_source|, and optional |intent| at the moment. This method will
// return |launch_result| to allow us find out which instance the app is
// running in.
[MinVersion=10]
Launch@8(LaunchParams params) => (LaunchResult launch_result);
// Sends the execution command to Lacros when user selects an item in the
// context menu to execute for an app with |app_id|. Current only the
// shortcut items in context menu need to be executed in lacros-chrome.
// The |id| represent which item user selected.
// This method will launch the app with selected shortcut and return
// |launch_result| to allow us find out which instance the app is running in.
[MinVersion=12]
ExecuteContextMenuCommand@9(
string app_id,
string id) => (LaunchResult launch_result);
// Close all instances of the given |app_id|.
[MinVersion=13]
StopApp@10(string app_id);
// Change permission setting for the app with |app_id|.
[MinVersion=14]
SetPermission@11(
string app_id,
Permission permission);
// Requests the size of an app with |app_id|. Publishers are expected to
// calculate and update the size of the app and publish this to App Service
[MinVersion=21]UpdateAppSize@21(string app_id);
};
// Interacts with the app service. Implemented in ash-chrome and called in
// lacros-chrome. This interface will allow the browser to interact with
// all types of apps installed in Chrome OS.
// Next version: 21
// Next method id: 9
[Stable, Uuid="a8979226-04ab-4c29-bca6-1b487ca769f7"]
interface AppServiceProxy {
// Lacros exposes an AppServiceSubscriber interface to Ash. This allows Ash
// to update the info for apps that registered in app service.
[MinVersion=8]
RegisterAppServiceSubscriber@0(
pending_remote<AppServiceSubscriber> subscriber);
// Launch the app with |params|. The params include |app_id|,
// |launch_source|, and optional |intent| at the moment.
// Deprecated: use `LaunchWithResult`.
[MinVersion=11]
Launch@1(LaunchParams params);
// Launch the app with |params|. The params include |app_id|,
// |launch_source|, and optional |intent| at the moment. This method will
// return |launch_result| to allow us find out which instance the app is
// running in.
[MinVersion=19]
LaunchWithResult@7(LaunchParams params) => (LaunchResult launch_result);
// Load icon for an app with |app_id| from ash-chrome.
// |icon_key| contains the arguments for an app icon, see
// apps::mojom::IconKey for more details. |icon_type| represent the icon
// format requested (e.g. compressed, uncompressed. etc). |size_hint_in_dip|
// is a hint of how big the icon should be. All these fields are necessary
// to fill to get the required icon.
// There should always be a return value for this method. If there is an
// error during the loading, the return value should be a default IconValue
// struct, with IconType = kUnknown to indicate it's an error case. If loading
// succeeded, the size of the returning icon is expected to be as close as
// possible with the |size_hint_in_dip| set in the interface, but may not be
// exactly the same.
[MinVersion=12]
LoadIcon@2(
string app_id,
IconKey icon_key,
IconType icon_type,
int32 size_hint_in_dip) => (IconValue icon_value);
// Unused and unimplemented as of M117. Use SetSupportedLinksPreference() to
// change preferred apps instead.
[MinVersion=15]
AddPreferredAppDeprecated@3(string app_id, Intent intent);
// In the Settings SWA, show the app management page for |app_id|.
[MinVersion=16]
ShowAppManagementPage@4(string app_id);
// Sets |app_id| as the preferred app for all of its supported links ('view'
// intent filters with a scheme, host, and port) in ash-chrome. All changes to
// the user's preferences as a result of this call will be synchronized back
// to lacros-chrome through AppServiceSubscriber::OnPreferredAppsChanged.
[MinVersion=17]
SetSupportedLinksPreference@5(string app_id);
// Uninstalls |app_id| without prompting the user to confirm.
[MinVersion=18]
UninstallSilently@6(string app_id, UninstallSource uninstall_source);
// Requests to install an app.
// Doc: go/cros-app-install-sketch
// If InstallAppParams::Surface::kUnknown is received then a version mismatch
// is assumed and the request will be cancelled.
[MinVersion=20]
InstallAppWithFallback@8(
InstallAppParams params) => (AppInstallResult result);
};
// Interacts with the app service. Implemented in lacros-chrome and called in
// ash-chrome. This interface will allow the app service to push updates to
// the lacros-chrome so that the browser can access the app service info
// in the same process.
// Next version: 16
// Next method id: 3
[Stable, Uuid="d77d3b7e-ef90-4615-b81b-7e43482a4d5e"]
interface AppServiceSubscriber {
// Receives a stream of apps from ash-chrome from a publisher, and save to
// AppRegistryCache.
// If |should_notify_initialized| is true, notifies observers that |app_type|
// has finished initiating apps.
[MinVersion=9]
OnApps@0(array<App> deltas, AppType app_type, bool should_notify_initialized);
// Indicates that a changes have been made by App Service to the preferred
// apps list. All of the changes should be applied to the subscriber's copy of
// the list using PreferredAppsList::ApplyBulkUpdate.
[MinVersion=15]
OnPreferredAppsChanged@1(PreferredAppChanges changes);
// On startup, Ash informs Lacros of the user's historically preferred apps
// for given intents. This allows Lacros to initialize its in-memory
// representation of the user's preferred apps.
[MinVersion=15]
InitializePreferredApps@2(array<PreferredApp> preferred_apps);
};
// Interacts with the app service. Implemented in ash-chrome.
// This is a generic app-shortcut-publisher interface that is used by the
// implementation for browser shortcuts and other future lacros based shortcut
// (e.g. shortcut to a web app).
// Deprecated in M127, reason: moving shortcuts storage from Lacros to Ash.
[Stable, Uuid="f46f05bb-218e-4370-ad07-f2f0dfef0298"]
interface AppShortcutPublisher {
// Publish a stream of app shortcuts from lacros-chrome.
// |deltas| holds a sparse data structure that includes the update
// AppShortcut data from the existing shortcut state in app service.
PublishShortcuts@0(array<AppShortcut> deltas) => ();
// Lacros exposes an AppShortcutController interface to Ash. This allows
// Ash to launch, or otherwise interact with shortcuts that run in Lacros.
[MinVersion=1]
RegisterAppShortcutController@1(
pending_remote<AppShortcutController> controller) =>
(ControllerRegistrationResult result);
// Notify ash-chrome that a shortcut identified by 'shortcut_id' has been
// removed.
[MinVersion=2]
ShortcutRemoved@2(string shortcut_id) => ();
};
// Interacts with shortcuts that run in Lacros. Implemented in lacros-chrome
// and called in ash-chrome.
// Deprecated in M127, reason: moving shortcuts storage from Lacros to Ash.
[Stable, Uuid="aa20b7ea-e177-4e14-b30e-cf54d9cde94c"]
interface AppShortcutController {
// Launches a shortcut identified by `local_shortcut_id` in the app identified
// by 'host_app_id`. `display_id` contains the id of the display from which
// the shortcut is targeted to launch. If the display id is not valid, it is
// expected to fallback to launch the shortcut in the primary display.
// Currently it is only expected to notify the caller on launch completion,
// regardless whether the launch is success, and we might add launch result
// in the callback if needed in the future.
[MinVersion=1]
LaunchShortcut@0(
string host_app_id, string local_shortcut_id, int64 display_id) => ();
// Requests a compressed icon data for a shortcut identified by
// `local_shortcut_id` in the app identified by 'host_app_id` from
// lacros-chrome. The icon is identified by `size_in_dip` and `scale_factor`.
// Calls `callback` with the result.
[MinVersion=2]
GetCompressedIcon@1(
string host_app_id,
string local_shortcut_id,
int32 size_in_dip,
ResourceScaleFactor scale_factor) => (IconValue icon_value);
// Removes a shortcut identified by `local_shortcut_id` in the app
// identified by 'host_app_id` without prompting the user to confirm.
// Currently it is only expected to notify the caller on removal completion,
// regardless whether the removal is success, and we might add removal result
// in the callback if needed in the future.
[MinVersion=3]
RemoveShortcut@2(
string host_app_id,
string local_shortcut_id,
UninstallSource uninstall_source) => ();
};