File: renderer.mojom

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (189 lines) | stat: -rw-r--r-- 7,853 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module extensions.mojom;

import "extensions/common/mojom/api_permission_id.mojom";
import "extensions/common/mojom/channel.mojom";
import "extensions/common/mojom/extension_id.mojom";
import "extensions/common/mojom/feature_session_type.mojom";
import "extensions/common/mojom/host_id.mojom";
import "extensions/common/mojom/manifest.mojom";
import "extensions/common/mojom/permission_set.mojom";
import "extensions/common/mojom/url_pattern_set.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "mojo/public/mojom/base/values.mojom";

// Mojo struct to be used as argument on the LoadExtension method.
struct ExtensionLoadedParams {
  // The subset of the extension manifest data we send to renderers.
  mojo_base.mojom.DictionaryValue manifest;

  // The location the extension was installed from. This is used in the renderer
  // only to generate the extension ID for extensions that are loaded unpacked.
  ManifestLocation location;

  // The path the extension was loaded from.
  mojo_base.mojom.FilePath path;

  // The extension's active and withheld permissions.
  PermissionSet active_permissions;
  PermissionSet withheld_permissions;
  map<int32, PermissionSet> tab_specific_permissions;

  // Contains URLPatternSets defining which URLs an extension may not interact
  // with by policy.
  URLPatternSet policy_blocked_hosts;
  URLPatternSet policy_allowed_hosts;

  // If the extension uses the default list of blocked / allowed URLs.
  bool uses_default_policy_blocked_allowed_hosts;

  // Whether the extension is allowed to use the userScript API.
  bool user_scripts_allowed;

  // We keep this separate so that it can be used in logging and testing.
  string id;

  // If this extension is Service Worker based, then this contains the
  // activation token of the extension
  mojo_base.mojom.UnguessableToken? worker_activation_token;

  // Send creation flags so that extension is initialized identically.
  int32 creation_flags;

  // Reuse the extension guid when creating the extension in the renderer.
  string guid;
};

// Settings for a given user script world.
struct UserScriptWorldInfo {
  // The corresponding extension ID.
  ExtensionId extension_id;

  // The ID of the world to configure. If omitted, configures the default
  // user script world.
  string? world_id;

  // A custom CSP for the user script world, if any.
  string? csp;

  // Whether to enable messaging APIs in the isolated world.
  bool enable_messaging;
};

// This should be used for implementing browser-to-renderer control messages
// which need to retain FIFO with respect to other mojo interfaces like
// content.mojom.Renderer.
interface Renderer {
  // Marks an extension as 'active' in an extension process. 'Active' extensions
  // have more privileges than other extension content that might end up running
  // in the process (e.g. because of iframes or content scripts).
  ActivateExtension(ExtensionId extension_id);

  // Tells the renderer whether or not activity logging is enabled. This is only
  // sent if logging is or was previously enabled; not being enabled is assumed
  // otherwise.
  SetActivityLoggingEnabled(bool enabled);

  // Notifies the renderer that extensions were loaded in the browser.
  LoadExtensions(array<ExtensionLoadedParams> params);

  // Notifies the renderer that an extension was unloaded in the browser.
  UnloadExtension(ExtensionId extension_id);

  // Tells the page to dispatch the suspend event. If we complete a round of
  // ShouldSuspend Mojo method and the reply without the lazy background page
  // becoming active again, we are ready to unload.
  SuspendExtension(ExtensionId extension_id) => ();

  // Cancels suspending the extension.
  CancelSuspendExtension(ExtensionId extension_id);

  // Informs the renderer whether or not the developer mode is enabled.
  SetDeveloperMode(bool developer_mode_only);

  // Informs the renderer whether the userScripts API has been allowed for the
  // extension.
  SetUserScriptsAllowed(ExtensionId extension_id, bool allowed);

  // Informs the renderer what channel (dev, beta, stable, etc) and user session
  // type is running.
  SetSessionInfo(Channel channel,
                 FeatureSessionType session);

  // Tells the renderer process the platform's system font.
  SetSystemFont(string font_family, string font_size);

  // Reports the WebView partition ID to the WebView guest renderer process.
  SetWebViewPartitionID(string partition_id);

  // Updates the scripting allowlist for extensions in the render process. This
  // is only used for testing.
  SetScriptingAllowlist(array<ExtensionId> extension_ids);

  // Updates the user script worlds accordiging to `infos`.
  UpdateUserScriptWorlds(array<UserScriptWorldInfo> infos);

  // Clears configurations associated with the given `extension_id` and
  // `world_id`.
  ClearUserScriptWorldConfig(ExtensionId extension_id,
                             string? world_id);

  // Asks the lazy background page if it is ready to be suspended and replies
  // back to the browser. This is sent when the page is considered idle.
  ShouldSuspend() => ();

  // Sent by the browser to indicate a Blob handle has been transferred to the
  // renderer. The reply is sent back to the browser when it has received the
  // Blob handle.
  // This is sent after the actual extension response, and depends on the
  // sequential nature of IPCs so that the blob has already been caught.
  TransferBlobs() => ();

  // Tells the renderer to update an extension's permission set.
  UpdatePermissions(ExtensionId extension_id,
                    PermissionSet active_permissions,
                    PermissionSet withheld_permissions,
                    URLPatternSet policy_blocked_hosts,
                    URLPatternSet policy_allowed_hosts,
                    bool uses_default_policy_host_restrictions);

  // Tells the renderer to update an extension's policy_blocked_hosts set.
  UpdateDefaultPolicyHostRestrictions(
        URLPatternSet default_policy_blocked_hosts,
        URLPatternSet default_policy_allowed_hosts);

  // Tells the renderer to update the collection of user-restricted hosts.
  UpdateUserHostRestrictions(
        URLPatternSet user_blocked_hosts,
        URLPatternSet user_allowed_hosts);

  // Tells the render view about new tab-specific permissions for an extension.
  UpdateTabSpecificPermissions(ExtensionId extension_id,
                               URLPatternSet new_hosts,
                               int32 tab_id,
                               bool update_origin_allowlist);

  // Notifies the renderer that the user scripts have been updated. It has one
  // ReadOnlySharedMemoryRegion argument consisting of the pickled script data.
  // This memory region is valid in the context of the renderer.
  // |owner| must not be empty, and all scripts from |owner| will be updated.
  UpdateUserScripts(mojo_base.mojom.ReadOnlySharedMemoryRegion region,
                    HostID owner);

  // Tells the render view to clear tab-specific permissions for some
  // extensions.
  ClearTabSpecificPermissions(array<ExtensionId> extension_ids,
                              int32 tab_id,
                              bool update_origin_allowlist);

  // Notifies the renderer that an extension wants notifications when certain
  // searches match the active page. This method replaces the old set of
  // searches, and triggers extensions::mojom::LocalFrameHost::WatchedPageChange
  // from each tab to keep the browser updated about changes.
  WatchPages(array<string> css_selectors);
};