arc.mojom 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. module crosapi.mojom;
  5. import "ui/gfx/image/mojom/image.mojom";
  6. // These interfaces let Lacros-chrome handle ARC's right click and smart
  7. // selection.
  8. // TODO(crbug.com/1268687): It should be migrated to AppService in the future.
  9. // The status in ash-chrome side. Return with the result.
  10. [Stable, Extensible]
  11. enum RequestActivityIconsStatus {
  12. // Connection established successfully in ash-chrome.
  13. kSuccess,
  14. // Ended with error to connect to ARC in ash-chrome.
  15. [Default] kArcNotAvailable,
  16. };
  17. [Stable, Extensible]
  18. enum RequestTextSelectionActionsStatus {
  19. // Connection established successfully in ash-chrome.
  20. kSuccess,
  21. // Ended with error to connect to ARC in ash-chrome.
  22. [Default] kArcNotAvailable,
  23. };
  24. [Stable, Extensible]
  25. enum RequestUrlHandlerListStatus {
  26. // Connection established successfully in ash-chrome.
  27. kSuccess,
  28. // Ended with error to connect to ARC in ash-chrome.
  29. [Default]kArcNotAvailable,
  30. };
  31. [Stable, Extensible]
  32. enum IsInstallableResult {
  33. // The app is available for installation in ARC.
  34. kInstallable,
  35. // The app is not available for installation in ARC or is already installed.
  36. kNotInstallable,
  37. // ARC is not running (e.g. disabled).
  38. kArcIsNotRunning,
  39. // ARC mojo API version is too low.
  40. kArcIsTooOld,
  41. };
  42. // This struct reflects components/arc/mojom/intent_common.mojom.
  43. // Describes an activity.
  44. [Stable]
  45. struct ActivityName {
  46. string package_name@0;
  47. // may be null to indicate any activity within package
  48. string? activity_name@1;
  49. };
  50. // This struct reflects components/arc/mojom/app.mojom
  51. // Describes the raw icon png data published by an Android application.
  52. [Stable]
  53. struct RawIconPngData {
  54. // True if the icon is an adaptive icon, or false otherwise.
  55. bool is_adaptive_icon@0;
  56. // The raw icon for the non-adaptive icon, or the generated standard icon done
  57. // by the ARC side for the adaptive icon.
  58. array<uint8>? icon_png_data@1;
  59. // The foreground image for the adaptive icon.
  60. array<uint8>? foreground_icon_png_data@2;
  61. // The background image for the adaptive icon.
  62. array<uint8>? background_icon_png_data@3;
  63. };
  64. // This struct reflects components/arc/mojom/scale_factor.mojom.
  65. // Duplicates ui::ResourceScaleFactor enum in order to be accessible on
  66. // Lacros side.
  67. [Stable, Extensible]
  68. enum ScaleFactor {
  69. // Some numbers are missing because we removed deprecated values.
  70. SCALE_FACTOR_NONE = 0,
  71. SCALE_FACTOR_100P = 1,
  72. SCALE_FACTOR_200P = 7,
  73. SCALE_FACTOR_300P = 9,
  74. };
  75. // This struct reflects components/arc/mojom/intent_helper.mojom
  76. // Describes an icon for the activity.
  77. [Stable]
  78. struct ActivityIcon {
  79. ActivityName activity@0;
  80. uint32 width@1; // in px
  81. uint32 height@2; // in px
  82. array<uint8> icon@3; // in BGRA8888 format
  83. RawIconPngData? icon_png_data@4;
  84. };
  85. // Describes a package that can handle an intent.
  86. // Removed unnecessary perameters for Lacros from IntentHandlerInfo declared in
  87. // components/arc/mojom/intent_helper.mojom.
  88. // Next version: 2
  89. [Stable]
  90. struct IntentHandlerInfo {
  91. string name@0;
  92. string package_name@1;
  93. string activity_name@2; // A hint for retrieving the package's icon.
  94. [MinVersion=1] bool is_preferred@3;
  95. [MinVersion=1] string? fallback_url@4;
  96. };
  97. // Describes an action that can handle an intent.
  98. // Removed unnecessary parameters: |clip_data_uri| and |uri_components| for
  99. // Lacros from IntentInfo declared in components/arc/mojom/intent_helper.mojom.
  100. [Stable]
  101. struct IntentInfo {
  102. string action@0;
  103. array<string>? categories@1;
  104. string? data@2; // URI
  105. string? type@3; // explicit MIME type for data
  106. bool ui_bypassed@4; // Whether or not the user saw the UI.
  107. // Optional string extras. These are the key-value pairs stored in android
  108. // intents to carry additional data. See:
  109. // https://developer.android.com/reference/android/content/Intent#putExtra(java.lang.String,%20java.lang.String)
  110. map<string, string>? extras@5;
  111. };
  112. // Describe an action given by the android text selection delegate (e.g. open
  113. // maps).
  114. [Stable]
  115. struct TextSelectionAction {
  116. // App ID of the package.
  117. // This parameter is not set in arc::mojom::TextSelectionAction, but required
  118. // in Lacros since Lacros cannot get app id from ActivityName.
  119. string app_id@0;
  120. // Icon of the package.
  121. // This parameter is different from arc::mojom::TextSelectionAction.icon.
  122. // Generate ImageSkia icon from RawIconPngData in ash-chrome, and send it to
  123. // lacros-chrome as a ImageSkia.
  124. gfx.mojom.ImageSkia icon@1;
  125. // The activity and package name of the component that handle the intent.
  126. ActivityName activity@2;
  127. // The title of the action that will be shown in the UI, e.g. "Map", "Call",
  128. // "Open".
  129. string title@3;
  130. // The intent to launch when the action is clicked.
  131. IntentInfo action_intent@4;
  132. };
  133. // Observe ARC.
  134. // Next version: 1
  135. // Next method id: 1
  136. [Stable, Uuid="e0993657-e667-408c-9950-e08480fd8013"]
  137. interface ArcObserver {
  138. // Notified when ARC does so via arc::mojom::IntentHelperHost.
  139. OnIconInvalidated@0(string package_name);
  140. };
  141. // Interacts with ARC.
  142. // Next version: 5
  143. // Next method id: 8
  144. [Stable, Uuid="a39a22dd-2f5c-4c99-b0ea-d83d5b1c987f"]
  145. interface Arc {
  146. // Registers ArcObserver in Lacros-chrome to Ash-chrome
  147. AddObserver@0(pending_remote<ArcObserver> observer);
  148. // Requests 48dp * 48dp icons for the |activities| suitable for the
  149. // |scale_factor| from Lacros-chrome to Ash-chrome. Ash-chrome will request
  150. // icons to ARC and send back the result attained from ARC.
  151. // An array of icon data and ARC connection status will be returned.
  152. // If ash-chrome succeeded to access to ARC, return icon array with kSuccess.
  153. // If not, return empty array with other status.
  154. RequestActivityIcons@1(array<ActivityName> activities,
  155. ScaleFactor scale_factor)
  156. => (array<ActivityIcon> icons,
  157. [MinVersion=2] RequestActivityIconsStatus status);
  158. // Requests a list of packages that can handle the URL from Lacros-chrome to
  159. // Ash-chrome. Ash-chrome will request a handler list to ARC and send back
  160. // the result attained from ARC.
  161. // An array of IntentHandlerInfo will be returned.
  162. // If ash-chrome succeeded to access to ARC, return handler list with
  163. // kSuccess. If not, return empty list with other status.
  164. RequestUrlHandlerList@2(string url)
  165. => (array<IntentHandlerInfo> handlers,
  166. [MinVersion=2] RequestUrlHandlerListStatus status);
  167. // Request generated actions that can handle |text| from Lacros-chrome to
  168. // Ash-chrome. Ash-chrome will request acions to ARC and send back the result
  169. // attained from ARC with generating Skia icons.
  170. // An arrya of TextSelectionAction will be returned.
  171. [MinVersion=2] RequestTextSelectionActions@4(string text,
  172. ScaleFactor scale_factor)
  173. => (RequestTextSelectionActionsStatus status,
  174. array<TextSelectionAction> actionos);
  175. // Handles the URL by sending an ACTION_VIEW intent to the package. The
  176. // most suitable activity for the URL within the package will be started.
  177. [MinVersion=1] HandleUrl@3(string url, string package_name);
  178. // Passes an intent to an activity and launch app.
  179. [MinVersion=3] HandleIntent@5(IntentInfo intent, ActivityName activity);
  180. // Sets the given package as a preferred package. The next time an ACTION_VIEW
  181. // intent is sent with a URL that requires disambiguation, instead of opening
  182. // the ResolverActivity, this package will be picked if it is on the list.
  183. // When multiple packages are set as preferred, the most recent setting wins.
  184. [MinVersion=3] AddPreferredPackage@6(string package_name);
  185. // Checks if the |package_name| is available for installation.
  186. // See |arc.mojom.AppInstance.IsInstallable|.
  187. [MinVersion=4] IsInstallable@7(string package_name) =>
  188. (IsInstallableResult result);
  189. };