1// Copyright 2018 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5module apps.mojom; 6 7import "chrome/services/app_service/public/mojom/types.mojom"; 8import "components/services/app_service/public/mojom/types.mojom"; 9 10// An intermediary between M app consumers (e.g. app launcher UI, intent 11// pickers) and N app providers (also known as app platforms, e.g. Android 12// apps, Linux apps and Web apps). It abstracts over platform-specific 13// implementations and allow consumers to issue generic queries (e.g. for an 14// app's name and icon) that are satisfied by the appropriate provider. 15// 16// See chrome/services/app_service/README.md. 17interface AppService { 18 // Called by a publisher of apps to register itself and its apps with the App 19 // Service. 20 RegisterPublisher(pending_remote<Publisher> publisher, AppType app_type); 21 22 // Called by a consumer that wishes to know about available apps to register 23 // itself with the App Service. 24 RegisterSubscriber(pending_remote<Subscriber> subscriber, ConnectOptions? opts); 25 26 // App Icon Factory methods. 27 LoadIcon( 28 AppType app_type, 29 string app_id, 30 IconKey icon_key, 31 IconCompression icon_compression, 32 int32 size_hint_in_dip, 33 bool allow_placeholder_icon) => (IconValue icon_value); 34 35 // App Runner methods. 36 Launch( 37 AppType app_type, 38 string app_id, 39 int32 event_flags, 40 LaunchSource launch_source, 41 int64 display_id); 42 43 // Launches an app with |app_id| and |file_path| 44 LaunchAppWithFiles( 45 AppType app_type, 46 string app_id, 47 LaunchContainer container, 48 int32 event_flags, 49 LaunchSource launch_source, 50 FilePaths file_paths); 51 52 // Launches an app with |app_id| and Chrome OS generic |intent| irrespective 53 // of app platform. 54 LaunchAppWithIntent( 55 AppType app_type, 56 string app_id, 57 Intent intent, 58 LaunchSource launch_source, 59 int64 display_id); 60 61 SetPermission( 62 AppType app_type, 63 string app_id, 64 Permission permission); 65 66 // Directly uninstalls |app_id| without prompting the user. 67 // |clear_site_data| is available for bookmark apps only. If true, any site 68 // data associated with the app will be removed.. 69 // |report_abuse| is available for Chrome Apps only. If true, the app will be 70 // reported for abuse to the Web Store. 71 Uninstall( 72 AppType app_type, 73 string app_id, 74 bool clear_site_data, 75 bool report_abuse); 76 77 // Pauses an app to stop the current running app, and apply the icon effect. 78 PauseApp( 79 AppType app_type, 80 string app_id); 81 82 // Unpauses an app, and recover the icon effect for the app. 83 UnpauseApps( 84 AppType app_type, 85 string app_id); 86 87 // Returns the menu items for an app with |app_id|. 88 GetMenuModel( 89 AppType app_type, 90 string app_id, 91 MenuType menu_type, 92 int64 display_id) => (MenuItems menu_items); 93 94 // Opens native settings for the app with |app_id|. 95 OpenNativeSettings( 96 AppType app_type, 97 string app_id); 98 99 // Sets app identified by |app_id| as preferred app for |intent_filter|. 100 // |intent| is needed to set the preferred app in ARC. 101 // If the request is |from_publisher|, we would not sync the preferred 102 // app back to the publisher. 103 AddPreferredApp( 104 AppType app_type, 105 string app_id, 106 IntentFilter intent_filter, 107 Intent? intent, 108 bool from_publisher); 109 110 // Removes all preferred app setting for an |app_id|. 111 RemovePreferredApp(AppType app_type, string app_id); 112 113 // Resets app identified by |app_id| as preferred app for |intent_filter|. 114 RemovePreferredAppForFilter( 115 AppType app_type, 116 string app_id, 117 IntentFilter intent_filter); 118}; 119 120interface Publisher { 121 // App Registry methods. 122 Connect(pending_remote<Subscriber> subscriber, ConnectOptions? opts); 123 124 // App Icon Factory methods. 125 LoadIcon( 126 string app_id, 127 IconKey icon_key, 128 IconCompression icon_compression, 129 int32 size_hint_in_dip, 130 bool allow_placeholder_icon) => (IconValue icon_value); 131 132 // App Runner methods. 133 Launch( 134 string app_id, 135 int32 event_flags, 136 LaunchSource launch_source, 137 int64 display_id); 138 139 // Launches an app with |app_id| and |file_path| 140 LaunchAppWithFiles( 141 string app_id, 142 LaunchContainer container, 143 int32 event_flags, 144 LaunchSource launch_source, 145 FilePaths file_paths); 146 147 // Launches an app with |app_id| and Chrome OS generic |intent| irrespective 148 // of app platform. 149 LaunchAppWithIntent( 150 string app_id, 151 Intent intent, 152 LaunchSource launch_source, 153 int64 display_id); 154 155 SetPermission( 156 string app_id, 157 Permission permission); 158 159 // Directly uninstalls |app_id| without prompting the user. 160 // |clear_site_data| is available for bookmark apps only. If true, any site 161 // data associated with the app will be removed.. 162 // |report_abuse| is available for Chrome Apps only. If true, the app will be 163 // reported for abuse to the Web Store. 164 Uninstall( 165 string app_id, 166 bool clear_site_data, 167 bool report_abuse); 168 169 // Pauses an app to stop the current running app, and apply the icon effect. 170 PauseApp( 171 string app_id); 172 173 // Unpauses an app, and recover the icon effect for the app. 174 UnpauseApps( 175 string app_id); 176 177 // Returns the menu items for an app with |app_id|. 178 GetMenuModel( 179 string app_id, 180 MenuType menu_type, 181 int64 display_id) => (MenuItems menu_items); 182 183 // Opens native settings for the app with |app_id|. 184 OpenNativeSettings( 185 string app_id); 186 187 // Indicates that the app identified by |app_id| has been set as a preferred 188 // app for |intent_filter|, and the |replaced_app_preferences| is the apps 189 // that are no longer preferred apps for their corresponding |intent_filters|. 190 // This method is used by the App Service to sync the change to publishers. 191 // |intent| is needed to set the preferred app in ARC. 192 OnPreferredAppSet( 193 string app_id, 194 IntentFilter intent_filter, 195 Intent intent, 196 ReplacedAppPreferences replaced_app_preferences); 197}; 198 199interface Subscriber { 200 OnApps(array<App> deltas); 201 202 // Binds this to the given receiver (message pipe endpoint), being to Mojo 203 // interfaces what POSIX's dup is to file descriptors. 204 // 205 // See https://groups.google.com/a/chromium.org/d/msg/chromium-mojo/nFhBzGsb5Pg/V7t_8kNRAgAJ 206 Clone(pending_receiver<Subscriber> receiver); 207 208 // Indicates that the app identified by |app_id| has been set as a preferred 209 // app for |intent_fitler|. This method is used by the App Service to sync 210 // the change from one subscriber to the others. 211 OnPreferredAppSet(string app_id, 212 IntentFilter intent_filter); 213 214 // Indicates that the app identified by |app_id| is no longer a preferred 215 // app for |intent_filter|. This method is used by the App Service to sync 216 // the change to all subscribers. 217 OnPreferredAppRemoved(string app_id, IntentFilter intent_filter); 218 219 // Initialize the |preferred_apps| in the subscribers from the app service. 220 InitializePreferredApps(array<PreferredApp> preferred_apps); 221}; 222 223struct ConnectOptions { 224 // TODO: some way to represent l10n info such as the UI language. 225}; 226