| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module apps.mojom; |
| |
| import "chrome/services/app_service/public/mojom/types.mojom"; |
| import "mojo/public/mojom/base/values.mojom"; |
| |
| // An intermediary between M app consumers (e.g. app launcher UI, intent |
| // pickers) and N app providers (also known as app platforms, e.g. Android |
| // apps, Linux apps and Web apps). It abstracts over platform-specific |
| // implementations and allow consumers to issue generic queries (e.g. for an |
| // app's name and icon) that are satisfied by the appropriate provider. |
| // |
| // See chrome/services/app_service/README.md. |
| interface AppService { |
| // Called by a publisher of apps to register itself and its apps with the App |
| // Service. |
| RegisterPublisher(pending_remote<Publisher> publisher, AppType app_type); |
| |
| // Called by a consumer that wishes to know about available apps to register |
| // itself with the App Service. |
| RegisterSubscriber(pending_remote<Subscriber> subscriber, ConnectOptions? opts); |
| |
| // App Icon Factory methods. |
| LoadIcon( |
| AppType app_type, |
| string app_id, |
| IconKey icon_key, |
| IconCompression icon_compression, |
| int32 size_hint_in_dip, |
| bool allow_placeholder_icon) => (IconValue icon_value); |
| |
| // App Runner methods. |
| Launch( |
| AppType app_type, |
| string app_id, |
| int32 event_flags, |
| LaunchSource launch_source, |
| int64 display_id); |
| |
| // Launches an app with |app_id| and Chrome OS generic |intent| irrespective |
| // of app platform. |
| LaunchAppWithIntent( |
| AppType app_type, |
| string app_id, |
| Intent intent, |
| LaunchSource launch_source, |
| int64 display_id); |
| |
| SetPermission( |
| AppType app_type, |
| string app_id, |
| Permission permission); |
| |
| // Directly uninstalls |app_id| without prompting the user. |
| // |clear_site_data| is available for bookmark apps only. If true, any site |
| // data associated with the app will be removed.. |
| // |report_abuse| is available for Chrome Apps only. If true, the app will be |
| // reported for abuse to the Web Store. |
| Uninstall( |
| AppType app_type, |
| string app_id, |
| bool clear_site_data, |
| bool report_abuse); |
| |
| // Pauses an app to stop the current running app, and apply the icon effect. |
| PauseApp( |
| AppType app_type, |
| string app_id); |
| |
| // Unpauses an app, and recover the icon effect for the app. |
| UnpauseApps( |
| AppType app_type, |
| string app_id); |
| |
| // Returns the menu items for an app with |app_id|. |
| GetMenuModel( |
| AppType app_type, |
| string app_id, |
| MenuType menu_type, |
| int64 display_id) => (MenuItems menu_items); |
| |
| // Opens native settings for the app with |app_id|. |
| OpenNativeSettings( |
| AppType app_type, |
| string app_id); |
| |
| // Sets app identified by |app_id| as preferred app for |intent_filter|. |
| // |intent| is needed to set the preferred app in ARC. |
| // If the request is |from_publisher|, we would not sync the preferred |
| // app back to the publisher. |
| AddPreferredApp( |
| AppType app_type, |
| string app_id, |
| IntentFilter intent_filter, |
| Intent? intent, |
| bool from_publisher); |
| |
| // Removes all preferred app setting for an |app_id|. |
| RemovePreferredApp(AppType app_type, string app_id); |
| |
| // Resets app identified by |app_id| as preferred app for |intent_filter|. |
| RemovePreferredAppForFilter( |
| AppType app_type, |
| string app_id, |
| IntentFilter intent_filter); |
| }; |
| |
| interface Publisher { |
| // App Registry methods. |
| Connect(pending_remote<Subscriber> subscriber, ConnectOptions? opts); |
| |
| // App Icon Factory methods. |
| LoadIcon( |
| string app_id, |
| IconKey icon_key, |
| IconCompression icon_compression, |
| int32 size_hint_in_dip, |
| bool allow_placeholder_icon) => (IconValue icon_value); |
| |
| // App Runner methods. |
| Launch( |
| string app_id, |
| int32 event_flags, |
| LaunchSource launch_source, |
| int64 display_id); |
| |
| // Launches an app with |app_id| and Chrome OS generic |intent| irrespective |
| // of app platform. |
| LaunchAppWithIntent( |
| string app_id, |
| Intent intent, |
| LaunchSource launch_source, |
| int64 display_id); |
| |
| SetPermission( |
| string app_id, |
| Permission permission); |
| |
| // Directly uninstalls |app_id| without prompting the user. |
| // |clear_site_data| is available for bookmark apps only. If true, any site |
| // data associated with the app will be removed.. |
| // |report_abuse| is available for Chrome Apps only. If true, the app will be |
| // reported for abuse to the Web Store. |
| Uninstall( |
| string app_id, |
| bool clear_site_data, |
| bool report_abuse); |
| |
| // Pauses an app to stop the current running app, and apply the icon effect. |
| PauseApp( |
| string app_id); |
| |
| // Unpauses an app, and recover the icon effect for the app. |
| UnpauseApps( |
| string app_id); |
| |
| // Returns the menu items for an app with |app_id|. |
| GetMenuModel( |
| string app_id, |
| MenuType menu_type, |
| int64 display_id) => (MenuItems menu_items); |
| |
| // Opens native settings for the app with |app_id|. |
| OpenNativeSettings( |
| string app_id); |
| |
| // Indicates that the app identified by |app_id| has been set as a preferred |
| // app for |intent_filter|, and the |replaced_app_preferences| is the apps |
| // that are no longer preferred apps for their corresponding |intent_filters|. |
| // This method is used by the App Service to sync the change to publishers. |
| // |intent| is needed to set the preferred app in ARC. |
| OnPreferredAppSet( |
| string app_id, |
| IntentFilter intent_filter, |
| Intent intent, |
| ReplacedAppPreferences replaced_app_preferences); |
| }; |
| |
| interface Subscriber { |
| OnApps(array<App> deltas); |
| |
| // Binds this to the given receiver (message pipe endpoint), being to Mojo |
| // interfaces what POSIX's dup is to file descriptors. |
| // |
| // See https://groups.google.com/a/chromium.org/d/msg/chromium-mojo/nFhBzGsb5Pg/V7t_8kNRAgAJ |
| Clone(pending_receiver<Subscriber> receiver); |
| |
| // Indicates that the app identified by |app_id| has been set as a preferred |
| // app for |intent_fitler|. This method is used by the App Service to sync |
| // the change from one subscriber to the others. |
| OnPreferredAppSet(string app_id, |
| IntentFilter intent_filter); |
| |
| // Indicates that the app identified by |app_id| is no longer a preferred |
| // app for |intent_filter|. This method is used by the App Service to sync |
| // the change to all subscribers. |
| OnPreferredAppRemoved(string app_id, IntentFilter intent_filter); |
| |
| InitializePreferredApps(mojo_base.mojom.Value preferred_apps); |
| }; |
| |
| struct ConnectOptions { |
| // TODO: some way to represent l10n info such as the UI language. |
| }; |