renderer.mojom 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // Copyright 2020 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 extensions.mojom;
  5. import "mojo/public/mojom/base/shared_memory.mojom";
  6. import "extensions/common/mojom/activation_sequence.mojom";
  7. import "extensions/common/mojom/api_permission_id.mojom";
  8. import "extensions/common/mojom/channel.mojom";
  9. import "extensions/common/mojom/host_id.mojom";
  10. import "extensions/common/mojom/feature_session_type.mojom";
  11. import "extensions/common/mojom/manifest.mojom";
  12. import "extensions/common/mojom/permission_set.mojom";
  13. import "extensions/common/mojom/url_pattern_set.mojom";
  14. import "mojo/public/mojom/base/values.mojom";
  15. import "mojo/public/mojom/base/file_path.mojom";
  16. // Mojo struct to be used as argument on the LoadExtension method.
  17. struct ExtensionLoadedParams {
  18. // The subset of the extension manifest data we send to renderers.
  19. mojo_base.mojom.Value manifest;
  20. // The location the extension was installed from. This is used in the renderer
  21. // only to generate the extension ID for extensions that are loaded unpacked.
  22. ManifestLocation location;
  23. // The path the extension was loaded from.
  24. mojo_base.mojom.FilePath path;
  25. // The extension's active and withheld permissions.
  26. PermissionSet active_permissions;
  27. PermissionSet withheld_permissions;
  28. map<int32, PermissionSet> tab_specific_permissions;
  29. // Contains URLPatternSets defining which URLs an extension may not interact
  30. // with by policy.
  31. URLPatternSet policy_blocked_hosts;
  32. URLPatternSet policy_allowed_hosts;
  33. // If the extension uses the default list of blocked / allowed URLs.
  34. bool uses_default_policy_blocked_allowed_hosts;
  35. // We keep this separate so that it can be used in logging and testing.
  36. string id;
  37. // If this extension is Service Worker based, then this contains the
  38. // activation sequence of the extension
  39. ActivationSequence? worker_activation_sequence;
  40. // Send creation flags so that extension is initialized identically.
  41. int32 creation_flags;
  42. // Reuse the extension guid when creating the extension in the renderer.
  43. string guid;
  44. };
  45. // This should be used for implementing browser-to-renderer control messages
  46. // which need to retain FIFO with respect to other mojo interfaces like
  47. // content.mojom.Renderer.
  48. interface Renderer {
  49. // Marks an extension as 'active' in an extension process. 'Active' extensions
  50. // have more privileges than other extension content that might end up running
  51. // in the process (e.g. because of iframes or content scripts).
  52. ActivateExtension(string extension_id);
  53. // Tells the renderer whether or not activity logging is enabled. This is only
  54. // sent if logging is or was previously enabled; not being enabled is assumed
  55. // otherwise.
  56. SetActivityLoggingEnabled(bool enabled);
  57. // Notifies the renderer that extensions were loaded in the browser.
  58. LoadExtensions(array<ExtensionLoadedParams> params);
  59. // Notifies the renderer that an extension was unloaded in the browser.
  60. UnloadExtension(string extension_id);
  61. // Tells the page to dispatch the suspend event. If we complete a round of
  62. // ShouldSuspend Mojo method and the reply without the lazy background page
  63. // becoming active again, we are ready to unload.
  64. SuspendExtension(string extension_id) => ();
  65. // Cancels suspending the extension.
  66. CancelSuspendExtension(string extension_id);
  67. // Informs the renderer whether or not the developer mode is enabled.
  68. SetDeveloperMode(bool developer_mode_only);
  69. // Informs the renderer what channel (dev, beta, stable, etc) and user session
  70. // type is running. |is_lock_screen_context| represents whether the browser
  71. // context is associated with Chrome OS lock screen.
  72. SetSessionInfo(Channel channel,
  73. FeatureSessionType session,
  74. bool is_lock_screen_context);
  75. // Tells the renderer process the platform's system font.
  76. SetSystemFont(string font_family, string font_size);
  77. // Reports the WebView partition ID to the WebView guest renderer process.
  78. SetWebViewPartitionID(string partition_id);
  79. // Updates the scripting allowlist for extensions in the render process. This
  80. // is only used for testing.
  81. SetScriptingAllowlist(array<string> extension_ids);
  82. // Asks the lazy background page if it is ready to be suspended and replies
  83. // back to the browser. This is sent when the page is considered idle.
  84. ShouldSuspend() => ();
  85. // Sent by the browser to indicate a Blob handle has been transferred to the
  86. // renderer. The reply is sent back to the browser when it has received the
  87. // Blob handle.
  88. // This is sent after the actual extension response, and depends on the
  89. // sequential nature of IPCs so that the blob has already been caught.
  90. TransferBlobs() => ();
  91. // Tells the renderer to update an extension's permission set.
  92. UpdatePermissions(string extension_id,
  93. PermissionSet active_permissions,
  94. PermissionSet withheld_permissions,
  95. URLPatternSet policy_blocked_hosts,
  96. URLPatternSet policy_allowed_hosts,
  97. bool uses_default_policy_host_restrictions);
  98. // Tells the renderer to update an extension's policy_blocked_hosts set.
  99. UpdateDefaultPolicyHostRestrictions(
  100. URLPatternSet default_policy_blocked_hosts,
  101. URLPatternSet default_policy_allowed_hosts);
  102. // Tells the renderer to update the collection of user-restricted hosts.
  103. UpdateUserHostRestrictions(
  104. URLPatternSet user_blocked_hosts,
  105. URLPatternSet user_allowed_hosts);
  106. // Tells the render view about new tab-specific permissions for an extension.
  107. UpdateTabSpecificPermissions(string extension_id,
  108. URLPatternSet new_hosts,
  109. int32 tab_id,
  110. bool update_origin_allowlist);
  111. // Notifies the renderer that the user scripts have been updated. It has one
  112. // ReadOnlySharedMemoryRegion argument consisting of the pickled script data.
  113. // This memory region is valid in the context of the renderer.
  114. // |owner| must not be empty, and all scripts from |owner| will be updated.
  115. UpdateUserScripts(mojo_base.mojom.ReadOnlySharedMemoryRegion region,
  116. HostID owner);
  117. // Tells the render view to clear tab-specific permissions for some
  118. // extensions.
  119. ClearTabSpecificPermissions(array<string> extension_ids,
  120. int32 tab_id,
  121. bool update_origin_allowlist);
  122. // Notifies the renderer that an extension wants notifications when certain
  123. // searches match the active page. This method replaces the old set of
  124. // searches, and triggers extensions::mojom::LocalFrameHost::WatchedPageChange
  125. // from each tab to keep the browser updated about changes.
  126. WatchPages(array<string> css_selectors);
  127. };