app_service_types.mojom 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. // Copyright 2021 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. //
  5. // NOTE: Future MinVersion values should take into account that MinVersion is
  6. // scoped per struct. In the past, some of the MinVersion values in this file
  7. // were set based on the understanding that the entire file should share a
  8. // MinVersion counter.
  9. module crosapi.mojom;
  10. import "mojo/public/mojom/base/file_path.mojom";
  11. import "mojo/public/mojom/base/time.mojom";
  12. import "mojo/public/mojom/base/unguessable_token.mojom";
  13. import "ui/gfx/image/mojom/image.mojom";
  14. import "url/mojom/url.mojom";
  15. // Information about an app. See components/services/app_service/README.md.
  16. // This struct is used to transport App data between lacros-chrome and
  17. // ash-chrome. It is intended to be the minimal subset of apps::mojom::App
  18. // required for this purpose, and exists to allow apps::mojom::App to not have
  19. // to be versioned.
  20. // See components/services/app_service/public/mojom/types.mojom for details
  21. // for the structs in this file.
  22. [Stable]
  23. struct App {
  24. AppType app_type@0;
  25. string app_id@1;
  26. // The fields above are mandatory. Everything else below is optional.
  27. Readiness readiness@2;
  28. string? name@3;
  29. string? short_name@4;
  30. // An optional, publisher-specific ID for this app, e.g. for Android apps,
  31. // this field contains the Android package name, and for web apps, it
  32. // contains the start URL.
  33. string? publisher_id@5;
  34. string? description@6;
  35. string? version@7;
  36. array<string> additional_search_terms@8;
  37. IconKey? icon_key@9;
  38. mojo_base.mojom.Time? last_launch_time@10;
  39. mojo_base.mojom.Time? install_time@11;
  40. // Whether the app was installed by sync, policy or as a default app.
  41. InstallReason install_reason@12;
  42. OptionalBool recommendable@13;
  43. OptionalBool searchable@14;
  44. OptionalBool show_in_launcher@15;
  45. OptionalBool show_in_shelf@16;
  46. OptionalBool show_in_search@17;
  47. OptionalBool show_in_management@18;
  48. // Whether the app icon should add the notification badging.
  49. OptionalBool has_badge@19;
  50. // Paused apps cannot be launched, and any running apps that become paused
  51. // will be stopped. This is independent of whether or not the app is ready to
  52. // be launched (defined by the Readiness field).
  53. OptionalBool paused@20;
  54. // This vector stores all the intent filters defined in this app. Each
  55. // intent filter defines a matching criteria for whether an intent can
  56. // be handled by this app. One app can have multiple intent filters.
  57. array<IntentFilter> intent_filters@21;
  58. // Whether the app's display mode is in the browser or otherwise.
  59. [MinVersion=2]
  60. WindowMode window_mode@22;
  61. // An optional ID used for policy to identify the app.
  62. // For web apps, it contains the install URL.
  63. [MinVersion=7]
  64. string? policy_id@23;
  65. // This vector must be treated atomically, if there is a permission
  66. // change, the publisher must send through the entire list of permissions.
  67. // Should contain no duplicate IDs.
  68. // If null during updates, Subscriber can assume no changes.
  69. // There is no guarantee that this is sorted by any criteria.
  70. [MinVersion=8]
  71. array<Permission>? permissions@24;
  72. [MinVersion=11]
  73. // Whether the app publisher allows the app to be uninstalled.
  74. OptionalBool allow_uninstall@25;
  75. [MinVersion=12]
  76. // kTrue if the app is able to handle intents and should be shown in intent
  77. // surfaces.
  78. OptionalBool handles_intents@26;
  79. [MinVersion=18]
  80. // Shortcuts help users perform specific actions easily.
  81. // This vector must be treated atomically, if there is a shortcut
  82. // change, the publisher must send through the entire list of shortcuts.
  83. // Should contain no duplicate IDs.
  84. // If empty during updates, Subscriber can assume no changes.
  85. // There is no guarantee that this is sorted by any criteria.
  86. array<Shortcut>? shortcuts@27;
  87. [MinVersion=19]
  88. OptionalBool is_platform_app@28;
  89. };
  90. // The types of apps available in the registry.
  91. [Stable, Extensible]
  92. enum AppType {
  93. [Default] kUnknown = 0,
  94. kArc, // Android app.
  95. kWeb, // Web app.
  96. kSystemWeb, // System web app.
  97. [MinVersion=1]
  98. kStandaloneBrowserChromeApp, // Chrome app.
  99. [MinVersion=17]
  100. kStandaloneBrowserExtension, // Chrome extension.
  101. };
  102. // Whether an app is ready to launch, i.e. installed.
  103. [Stable, Extensible]
  104. enum Readiness {
  105. [Default] kUnknown = 0,
  106. kReady, // Installed and launchable.
  107. kDisabledByBlocklist, // Disabled by SafeBrowsing.
  108. kDisabledByPolicy, // Disabled by admin policy.
  109. kDisabledByUser, // Disabled by explicit user action.
  110. kTerminated, // Renderer process crashed.
  111. kUninstalledByUser,
  112. // Removed apps are purged from the registry cache and have their
  113. // associated memory freed. Subscribers are not notified of removed
  114. // apps, so publishers must set the app as uninstalled before
  115. // removing it.
  116. kRemoved,
  117. [MinVersion=1] kUninstalledByMigration,
  118. };
  119. // The reason why the app was installed.
  120. [Stable, Extensible, RenamedFrom="crosapi.mojom.InstallSource"]
  121. enum InstallReason {
  122. [Default] kUnknown = 0,
  123. kSystem, // Installed with the system and is considered a part of the OS.
  124. kPolicy, // Installed by policy.
  125. kOem, // Installed by an OEM.
  126. kDefault, // Preinstalled by default, but is not considered a system app.
  127. kSync, // Installed by sync.
  128. kUser, // Installed by user action.
  129. [MinVersion=7] kSubApp, // Installed by the SubApp API call.
  130. };
  131. // Augments a bool to include an 'unknown' value.
  132. [Stable, Extensible]
  133. enum OptionalBool {
  134. [Default] kUnknown = 0,
  135. kFalse,
  136. kTrue,
  137. };
  138. [Stable]
  139. struct IconKey {
  140. // A timeline value for icons that do not change.
  141. const uint64 kDoesNotChangeOverTime = 0;
  142. // A monotonically increasing number so that, after an icon update, a new
  143. // IconKey, one that is different in terms of field-by-field equality, can be
  144. // broadcast by a Publisher.
  145. //
  146. // The exact value of the number isn't important, only that newer IconKey's
  147. // (those that were created more recently) have a larger timeline than older
  148. // IconKey's.
  149. //
  150. // This is, in some sense, *a* version number, but the field is not called
  151. // "version", to avoid any possible confusion that it encodes *the* app's
  152. // version number, e.g. the "2.3.5" in "FooBar version 2.3.5 is installed".
  153. //
  154. // For example, if an app is disabled for some reason (so that its icon is
  155. // grayed out), this would result in a different timeline even though the
  156. // app's version is unchanged.
  157. uint64 timeline;
  158. // A bitmask of icon post-processing effects, such as desaturation to gray
  159. // and rounding the corners.
  160. // The mask enum apps::IconEffects is defined in
  161. // chrome/browser/apps/app_service/app_icon/app_icon_factory.h and will remain
  162. // stable.
  163. uint32 icon_effects;
  164. };
  165. // The intent filter matching condition types.
  166. [Stable, Extensible]
  167. enum ConditionType {
  168. [Default] kScheme, // Matches the URL scheme (e.g. https, tel).
  169. kHost, // Matches the URL host (e.g. www.google.com).
  170. kPath , // Matches the URL path (e.g. /abc/*).
  171. kAction, // Matches the action type (e.g. view, send).
  172. kMimeType, // Matches the top-level mime type (e.g. text/plain).
  173. [MinVersion=1] kFileExtension, // Deprecated.
  174. [MinVersion=4] kFile // Matches against all files.
  175. };
  176. // The pattern match type for intent filter pattern condition.
  177. [Stable, Extensible]
  178. enum PatternMatchType {
  179. [Default] kNone = 0,
  180. kLiteral,
  181. kPrefix,
  182. kGlob,
  183. kMimeType,
  184. [MinVersion=1] kFileExtension,
  185. [MinVersion=6] kIsDirectory,
  186. [MinVersion=16] kSuffix
  187. };
  188. // For pattern type of condition, the value match will be based on the pattern
  189. // match type. If the match_type is kNone, then an exact match with the value
  190. // will be required.
  191. [Stable]
  192. struct ConditionValue {
  193. string value;
  194. PatternMatchType match_type; // This will be None for non pattern conditions.
  195. };
  196. // The condition for an intent filter. It matches if the intent contains this
  197. // condition type and the corresponding value matches with any of the
  198. // condition_values.
  199. [Stable]
  200. struct Condition {
  201. ConditionType condition_type;
  202. array<ConditionValue> condition_values;
  203. };
  204. // An intent filter is defined by an app, and contains a list of conditions that
  205. // an intent needs to match. If all conditions match, then this intent filter
  206. // matches against an intent.
  207. [Stable]
  208. struct IntentFilter {
  209. array<Condition> conditions;
  210. // Activity which registered this filter. We only fill this field for ARC
  211. // share intent filters.
  212. string? activity_name;
  213. // The label shown to the user for this activity.
  214. string? activity_label;
  215. };
  216. // What caused the app to be uninstalled.
  217. [Stable, Extensible]
  218. enum UninstallSource {
  219. [Default] kUnknown = 0,
  220. kAppList, // Uninstall by the user from the App List (Launcher)
  221. kAppManagement, // Uninstall by the user from the App Management page
  222. kShelf, // Uninstall by the user from the Shelf
  223. kMigration, // Uninstall by app migration.
  224. };
  225. // Information about whether an app is accessing some capability, e.g. camera,
  226. // microphone.
  227. [Stable]
  228. struct CapabilityAccess {
  229. string app_id;
  230. // Whether the app is accessing camera.
  231. OptionalBool camera;
  232. // Whether the app is accessing microphone.
  233. OptionalBool microphone;
  234. };
  235. [Stable, Extensible]
  236. enum IconType {
  237. // Sentinel value used in error cases.
  238. [Default] kUnknown,
  239. // Icon as an uncompressed gfx::ImageSkia with no standard Chrome OS mask.
  240. kUncompressed,
  241. // Icon as compressed bytes in PNG format with no standard Chrome OS mask.
  242. kCompressed,
  243. // Icon as an uncompressed gfx::ImageSkia with the standard Chrome OS mask
  244. // applied. This is the default suggested icon type.
  245. kStandard,
  246. };
  247. // The icon value for each app.
  248. [Stable]
  249. struct IconValue {
  250. // The icon format and whether it uses Chrome OS mask.
  251. IconType icon_type;
  252. // The uncompressed icon data in gfx::ImageSkia format.
  253. gfx.mojom.ImageSkia? uncompressed;
  254. // The compressed icon data in PNG format.
  255. array<uint8>? compressed;
  256. // Whether this icon data is a placeholder icon.
  257. bool is_placeholder_icon;
  258. };
  259. // MenuItems are used to populate context menus.
  260. [Stable]
  261. struct MenuItems {
  262. array<MenuItem> items@0;
  263. };
  264. // The context menu model for each app. For web apps currently it's the info
  265. // for shortcut items.
  266. [Stable]
  267. struct MenuItem {
  268. string label@0; // The string label, may be empty.
  269. gfx.mojom.ImageSkia? image@1; // The image icon, may be null.
  270. [MinVersion=3]string? id@2; // The id of the item.
  271. };
  272. [Stable, Extensible]
  273. // The mode that the app will be opened in (e.g. standalone window or browser
  274. // tab).
  275. enum WindowMode {
  276. [Default] kUnknown = 0,
  277. // Opens in a standalone window
  278. kWindow,
  279. // Opens in the default web browser
  280. kBrowser,
  281. // Opens in a tabbed app window
  282. kTabbedWindow,
  283. };
  284. // Metadata for a single file shared through an intent.
  285. [Stable]
  286. struct IntentFile {
  287. // The file path of the file to share.
  288. mojo_base.mojom.FilePath file_path@0;
  289. // File MIME type.
  290. [MinVersion=15] string? mime_type@1;
  291. };
  292. // Action and resource handling request. This should
  293. // be kept in sync with ConvertIntentToValue and ConvertValueToIntent in
  294. // components/services/app_service/public/cpp/intent_util.*
  295. [Stable]
  296. struct Intent {
  297. string action@0; // Intent action. e.g. view, send.
  298. url.mojom.Url? url@1; // The URL of the intent. e.g. https://www.google.com/.
  299. string? mime_type@2; // MIME type. e.g. text/plain, image/*.
  300. string? share_text@3; // Text to share. e.g. Share link to other app.
  301. string? share_title@4; // Title for the share.
  302. // The files to view or share.
  303. [MinVersion=5] array<IntentFile>? files@5;
  304. // The activity for the app to launch.
  305. [MinVersion=13] string? activity_name@6;
  306. [MinVersion=14] string? data@7;
  307. };
  308. // The result from launching an app.
  309. [Stable]
  310. struct LaunchResult {
  311. // The id to represent which instance the app is launched in. Deprecated: use
  312. // `instance_ids`.
  313. mojo_base.mojom.UnguessableToken instance_id@0;
  314. // The IDs that represent the instances the app is launched in.
  315. [MinVersion=1] array<mojo_base.mojom.UnguessableToken>? instance_ids@1;
  316. };
  317. // Enumeration of app launch sources.
  318. [Stable, Extensible]
  319. enum LaunchSource {
  320. [Default] kUnknown = 0,
  321. kFromAppListGrid, // Grid of apps, not the search box.
  322. kFromAppListGridContextMenu, // Grid of apps; context menu.
  323. kFromAppListQuery, // Query-dependent results (larger icons).
  324. kFromAppListQueryContextMenu, // Query-dependent results; context menu.
  325. kFromAppListRecommendation, // Query-less recommendations (smaller
  326. // icons).
  327. kFromParentalControls, // Parental Controls Settings Section and
  328. // Per App time notification.
  329. kFromShelf, // Shelf.
  330. kFromFileManager, // FileManager.
  331. kFromLink, // Left-clicking on links in the browser.
  332. kFromOmnibox, // Enter URL in the Omnibox in the
  333. // browser.
  334. kFromChromeInternal, // Chrome internal call.
  335. kFromKeyboard, // Keyboard shortcut for opening app.
  336. kFromOtherApp, // Clicking link in another app or webui.
  337. kFromMenu, // Menu.
  338. kFromInstalledNotification, // Installed notification
  339. kFromTest, // Test
  340. kFromArc, // Arc.
  341. kFromSharesheet, // Sharesheet.
  342. kFromReleaseNotesNotification, // Release Notes Notification.
  343. kFromFullRestore, // Full restore.
  344. kFromSmartTextContextMenu, // Smart text selection context menu.
  345. kFromDiscoverTabNotification, // Discover Tab Notification.
  346. [MinVersion=10] kFromManagementApi, // Management API.
  347. [MinVersion=10] kFromKiosk, // Kiosk.
  348. [MinVersion=10] kFromNewTabPage, // New tab page.
  349. [MinVersion=10] kFromIntentUrl, // Intent Url.
  350. [MinVersion=10] kFromOsLogin, // Run on OS login.
  351. [MinVersion=10] kFromProtocolHandler, // Protocol handler.
  352. [MinVersion=10] kFromUrlHandler, // Url handler.
  353. };
  354. [Stable, Extensible]
  355. // The container type to launch the application in.
  356. enum LaunchContainer {
  357. [Default] kLaunchContainerNone, // No specified container
  358. kLaunchContainerWindow, // Window container
  359. kLaunchContainerTab, // Tab container
  360. };
  361. [Stable, Extensible]
  362. // Controls how a tab is opened in a window.
  363. enum WindowOpenDisposition {
  364. [Default] kUnknown,
  365. kCurrentTab,
  366. kNewForegroundTab,
  367. kNewBackgroundTab,
  368. kNewWindow,
  369. };
  370. [Stable]
  371. // The parameters to launch an app.
  372. struct LaunchParams {
  373. string app_id@0; // The app id of the app.
  374. LaunchSource launch_source@1; // The app launch source.
  375. Intent? intent@2; // The intent the app will launch with.
  376. // The container the app will launch in.
  377. [MinVersion=14]LaunchContainer container@3;
  378. // How the tab opened in a window if app is opened in tab.
  379. [MinVersion=14]WindowOpenDisposition disposition@4;
  380. // An id that indicates which display the app should be launched in.
  381. [MinVersion=15]int64 display_id@5;
  382. };
  383. [Stable]
  384. struct Permission {
  385. PermissionType permission_type@0;
  386. PermissionValue value@1;
  387. // If the permission is managed by an enterprise policy.
  388. bool is_managed@2;
  389. };
  390. // The types of permissions in App Service.
  391. [Stable, Extensible]
  392. enum PermissionType {
  393. [Default] kUnknown = 0,
  394. kCamera = 1,
  395. kLocation = 2,
  396. kMicrophone = 3,
  397. kNotifications = 4,
  398. [MinVersion=9] kContacts = 5,
  399. [MinVersion=9] kStorage = 6,
  400. [MinVersion=10] kFileHandling = 7,
  401. };
  402. [Stable]
  403. enum TriState {
  404. kAllow,
  405. kBlock,
  406. kAsk,
  407. };
  408. [Stable]
  409. union PermissionValue {
  410. bool bool_value;
  411. TriState tristate_value;
  412. };
  413. // Represents changes which have been made to the preferred apps list, both
  414. // adding new filters and removing existing filters. The map is keyed by
  415. // |app_id|, and the value is the list of the filters that is added/removed
  416. // for that |app_id|.
  417. [Stable]
  418. struct PreferredAppChanges {
  419. map<string, array<IntentFilter>> added_filters;
  420. map<string, array<IntentFilter>> removed_filters;
  421. };
  422. // Represents the entry of the preferred apps list.
  423. [Stable]
  424. struct PreferredApp {
  425. IntentFilter intent_filter;
  426. string app_id;
  427. };
  428. // Represents an app shortcut.
  429. [Stable]
  430. struct Shortcut {
  431. // Represents a particular shortcut in an app. Needs to be unique within an
  432. // app as calls will be made using both app_id and shortcut_id.
  433. string shortcut_id@0;
  434. // Name of the shortcut.
  435. string name@1;
  436. // "Position" of a shortcut, which is a non-negative, sequential
  437. // value. If position is 0, no position was specified.
  438. uint8 position@2;
  439. };