Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / common / extension_messages.h
blob44549341b84c6d00434e0914be70a80e18a05fb1
1 // Copyright 2014 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.
5 // IPC messages for extensions.
6 // Multiply-included message file, hence no include guard.
8 #include <string>
9 #include <vector>
11 #include "base/memory/shared_memory.h"
12 #include "base/values.h"
13 #include "content/public/common/common_param_traits.h"
14 #include "content/public/common/socket_permission_request.h"
15 #include "extensions/common/api/messaging/message.h"
16 #include "extensions/common/draggable_region.h"
17 #include "extensions/common/extension.h"
18 #include "extensions/common/extensions_client.h"
19 #include "extensions/common/host_id.h"
20 #include "extensions/common/permissions/media_galleries_permission_data.h"
21 #include "extensions/common/permissions/permission_set.h"
22 #include "extensions/common/permissions/socket_permission_data.h"
23 #include "extensions/common/permissions/usb_device_permission_data.h"
24 #include "extensions/common/stack_frame.h"
25 #include "extensions/common/url_pattern.h"
26 #include "extensions/common/url_pattern_set.h"
27 #include "extensions/common/user_script.h"
28 #include "extensions/common/view_type.h"
29 #include "ipc/ipc_message_macros.h"
30 #include "ui/gfx/ipc/gfx_param_traits.h"
31 #include "url/gurl.h"
33 #define IPC_MESSAGE_START ExtensionMsgStart
35 IPC_ENUM_TRAITS_MAX_VALUE(extensions::ViewType, extensions::VIEW_TYPE_LAST)
36 IPC_ENUM_TRAITS_MAX_VALUE(content::SocketPermissionRequest::OperationType,
37 content::SocketPermissionRequest::OPERATION_TYPE_LAST)
39 IPC_ENUM_TRAITS_MAX_VALUE(extensions::UserScript::InjectionType,
40 extensions::UserScript::INJECTION_TYPE_LAST)
42 IPC_ENUM_TRAITS_MAX_VALUE(HostID::HostType, HostID::HOST_TYPE_LAST)
44 // Parameters structure for ExtensionHostMsg_AddAPIActionToActivityLog and
45 // ExtensionHostMsg_AddEventToActivityLog.
46 IPC_STRUCT_BEGIN(ExtensionHostMsg_APIActionOrEvent_Params)
47 // API name.
48 IPC_STRUCT_MEMBER(std::string, api_call)
50 // List of arguments.
51 IPC_STRUCT_MEMBER(base::ListValue, arguments)
53 // Extra logging information.
54 IPC_STRUCT_MEMBER(std::string, extra)
55 IPC_STRUCT_END()
57 // Parameters structure for ExtensionHostMsg_AddDOMActionToActivityLog.
58 IPC_STRUCT_BEGIN(ExtensionHostMsg_DOMAction_Params)
59 // URL of the page.
60 IPC_STRUCT_MEMBER(GURL, url)
62 // Title of the page.
63 IPC_STRUCT_MEMBER(base::string16, url_title)
65 // API name.
66 IPC_STRUCT_MEMBER(std::string, api_call)
68 // List of arguments.
69 IPC_STRUCT_MEMBER(base::ListValue, arguments)
71 // Type of DOM API call.
72 IPC_STRUCT_MEMBER(int, call_type)
73 IPC_STRUCT_END()
75 // Parameters structure for ExtensionHostMsg_Request.
76 IPC_STRUCT_BEGIN(ExtensionHostMsg_Request_Params)
77 // Message name.
78 IPC_STRUCT_MEMBER(std::string, name)
80 // List of message arguments.
81 IPC_STRUCT_MEMBER(base::ListValue, arguments)
83 // Extension ID this request was sent from. This can be empty, in the case
84 // where we expose APIs to normal web pages using the extension function
85 // system.
86 IPC_STRUCT_MEMBER(std::string, extension_id)
88 // URL of the frame the request was sent from. This isn't necessarily an
89 // extension url. Extension requests can also originate from content scripts,
90 // in which case extension_id will indicate the ID of the associated
91 // extension. Or, they can originate from hosted apps or normal web pages.
92 IPC_STRUCT_MEMBER(GURL, source_url)
94 // The id of the tab that sent this request, or -1 if there is no source tab.
95 IPC_STRUCT_MEMBER(int, source_tab_id)
97 // Unique request id to match requests and responses.
98 IPC_STRUCT_MEMBER(int, request_id)
100 // True if request has a callback specified.
101 IPC_STRUCT_MEMBER(bool, has_callback)
103 // True if request is executed in response to an explicit user gesture.
104 IPC_STRUCT_MEMBER(bool, user_gesture)
105 IPC_STRUCT_END()
107 // Allows an extension to execute code in a tab.
108 IPC_STRUCT_BEGIN(ExtensionMsg_ExecuteCode_Params)
109 // The extension API request id, for responding.
110 IPC_STRUCT_MEMBER(int, request_id)
112 // The ID of the requesting injection host.
113 IPC_STRUCT_MEMBER(HostID, host_id)
115 // Whether the code is JavaScript or CSS.
116 IPC_STRUCT_MEMBER(bool, is_javascript)
118 // String of code to execute.
119 IPC_STRUCT_MEMBER(std::string, code)
121 // The webview guest source who calls to execute code.
122 IPC_STRUCT_MEMBER(GURL, webview_src)
124 // Whether to inject into about:blank (sub)frames.
125 IPC_STRUCT_MEMBER(bool, match_about_blank)
127 // When to inject the code.
128 IPC_STRUCT_MEMBER(int, run_at)
130 // Whether to execute code in the main world (as opposed to an isolated
131 // world).
132 IPC_STRUCT_MEMBER(bool, in_main_world)
134 // Whether the request is coming from a <webview>.
135 IPC_STRUCT_MEMBER(bool, is_web_view)
137 // Whether the caller is interested in the result value. Manifest-declared
138 // content scripts and executeScript() calls without a response callback
139 // are examples of when this will be false.
140 IPC_STRUCT_MEMBER(bool, wants_result)
142 // The URL of the file that was injected, if any.
143 IPC_STRUCT_MEMBER(GURL, file_url)
145 // Whether the code to be executed should be associated with a user gesture.
146 IPC_STRUCT_MEMBER(bool, user_gesture)
147 IPC_STRUCT_END()
149 // Struct containing information about the sender of connect() calls that
150 // originate from a tab.
151 IPC_STRUCT_BEGIN(ExtensionMsg_TabConnectionInfo)
152 // The tab from where the connection was created.
153 IPC_STRUCT_MEMBER(base::DictionaryValue, tab)
155 // The ID of the frame that initiated the connection.
156 // 0 if main frame, positive otherwise. -1 if not initiated from a frame.
157 IPC_STRUCT_MEMBER(int, frame_id)
158 IPC_STRUCT_END()
160 // Struct containing information about the destination of tab.connect().
161 IPC_STRUCT_BEGIN(ExtensionMsg_TabTargetConnectionInfo)
162 // The destination tab's ID.
163 IPC_STRUCT_MEMBER(int, tab_id)
165 // Frame ID of the destination. -1 for all frames, 0 for main frame and
166 // positive if the destination is a specific child frame.
167 IPC_STRUCT_MEMBER(int, frame_id)
168 IPC_STRUCT_END()
170 // Struct containing the data for external connections to extensions. Used to
171 // handle the IPCs initiated by both connect() and onConnect().
172 IPC_STRUCT_BEGIN(ExtensionMsg_ExternalConnectionInfo)
173 // The ID of the extension that is the target of the request.
174 IPC_STRUCT_MEMBER(std::string, target_id)
176 // The ID of the extension that initiated the request. May be empty if it
177 // wasn't initiated by an extension.
178 IPC_STRUCT_MEMBER(std::string, source_id)
180 // The URL of the frame that initiated the request.
181 IPC_STRUCT_MEMBER(GURL, source_url)
183 // The ID of the frame that is the target of the request.
184 IPC_STRUCT_MEMBER(int, target_frame_id)
186 // The process ID of the webview that initiated the request.
187 IPC_STRUCT_MEMBER(int, guest_process_id)
189 // The render frame routing ID of the webview that initiated the request.
190 IPC_STRUCT_MEMBER(int, guest_render_frame_routing_id)
191 IPC_STRUCT_END()
193 IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion)
194 IPC_STRUCT_TRAITS_MEMBER(draggable)
195 IPC_STRUCT_TRAITS_MEMBER(bounds)
196 IPC_STRUCT_TRAITS_END()
198 IPC_STRUCT_TRAITS_BEGIN(content::SocketPermissionRequest)
199 IPC_STRUCT_TRAITS_MEMBER(type)
200 IPC_STRUCT_TRAITS_MEMBER(host)
201 IPC_STRUCT_TRAITS_MEMBER(port)
202 IPC_STRUCT_TRAITS_END()
204 IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionEntry)
205 IPC_STRUCT_TRAITS_MEMBER(pattern_)
206 IPC_STRUCT_TRAITS_MEMBER(match_subdomains_)
207 IPC_STRUCT_TRAITS_END()
209 IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionData)
210 IPC_STRUCT_TRAITS_MEMBER(entry())
211 IPC_STRUCT_TRAITS_END()
213 IPC_STRUCT_TRAITS_BEGIN(extensions::StackFrame)
214 IPC_STRUCT_TRAITS_MEMBER(line_number)
215 IPC_STRUCT_TRAITS_MEMBER(column_number)
216 IPC_STRUCT_TRAITS_MEMBER(source)
217 IPC_STRUCT_TRAITS_MEMBER(function)
218 IPC_STRUCT_TRAITS_END()
220 IPC_STRUCT_TRAITS_BEGIN(extensions::UsbDevicePermissionData)
221 IPC_STRUCT_TRAITS_MEMBER(vendor_id())
222 IPC_STRUCT_TRAITS_MEMBER(product_id())
223 IPC_STRUCT_TRAITS_END()
225 IPC_STRUCT_TRAITS_BEGIN(extensions::MediaGalleriesPermissionData)
226 IPC_STRUCT_TRAITS_MEMBER(permission())
227 IPC_STRUCT_TRAITS_END()
229 IPC_STRUCT_TRAITS_BEGIN(extensions::Message)
230 IPC_STRUCT_TRAITS_MEMBER(data)
231 IPC_STRUCT_TRAITS_MEMBER(user_gesture)
232 IPC_STRUCT_TRAITS_END()
234 // Singly-included section for custom IPC traits.
235 #ifndef EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
236 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
238 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need
239 // to typedef it to avoid that.
240 // Substitution map for l10n messages.
241 typedef std::map<std::string, std::string> SubstitutionMap;
243 // Map of extensions IDs to the executing script paths.
244 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap;
246 struct ExtensionMsg_PermissionSetStruct {
247 ExtensionMsg_PermissionSetStruct();
248 explicit ExtensionMsg_PermissionSetStruct(
249 const extensions::PermissionSet& permissions);
250 ~ExtensionMsg_PermissionSetStruct();
252 scoped_refptr<const extensions::PermissionSet> ToPermissionSet() const;
254 extensions::APIPermissionSet apis;
255 extensions::ManifestPermissionSet manifest_permissions;
256 extensions::URLPatternSet explicit_hosts;
257 extensions::URLPatternSet scriptable_hosts;
260 struct ExtensionMsg_Loaded_Params {
261 ExtensionMsg_Loaded_Params();
262 ~ExtensionMsg_Loaded_Params();
263 ExtensionMsg_Loaded_Params(const extensions::Extension* extension,
264 bool include_tab_permissions);
266 // Creates a new extension from the data in this object.
267 scoped_refptr<extensions::Extension> ConvertToExtension(
268 std::string* error) const;
270 // The subset of the extension manifest data we send to renderers.
271 linked_ptr<base::DictionaryValue> manifest;
273 // The location the extension was installed from.
274 extensions::Manifest::Location location;
276 // The path the extension was loaded from. This is used in the renderer only
277 // to generate the extension ID for extensions that are loaded unpacked.
278 base::FilePath path;
280 // The extension's active and withheld permissions.
281 ExtensionMsg_PermissionSetStruct active_permissions;
282 ExtensionMsg_PermissionSetStruct withheld_permissions;
283 std::map<int, ExtensionMsg_PermissionSetStruct> tab_specific_permissions;
285 // We keep this separate so that it can be used in logging.
286 std::string id;
288 // Send creation flags so extension is initialized identically.
289 int creation_flags;
292 struct ExtensionHostMsg_AutomationQuerySelector_Error {
293 enum Value { kNone, kNoMainFrame, kNoDocument, kNodeDestroyed };
295 ExtensionHostMsg_AutomationQuerySelector_Error() : value(kNone) {}
297 Value value;
300 namespace IPC {
302 template <>
303 struct ParamTraits<URLPattern> {
304 typedef URLPattern param_type;
305 static void Write(Message* m, const param_type& p);
306 static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
307 static void Log(const param_type& p, std::string* l);
310 template <>
311 struct ParamTraits<extensions::URLPatternSet> {
312 typedef extensions::URLPatternSet param_type;
313 static void Write(Message* m, const param_type& p);
314 static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
315 static void Log(const param_type& p, std::string* l);
318 template <>
319 struct ParamTraits<extensions::APIPermission::ID> {
320 typedef extensions::APIPermission::ID param_type;
321 static void Write(Message* m, const param_type& p);
322 static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
323 static void Log(const param_type& p, std::string* l);
326 template <>
327 struct ParamTraits<extensions::APIPermissionSet> {
328 typedef extensions::APIPermissionSet param_type;
329 static void Write(Message* m, const param_type& p);
330 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
331 static void Log(const param_type& p, std::string* l);
334 template <>
335 struct ParamTraits<extensions::ManifestPermissionSet> {
336 typedef extensions::ManifestPermissionSet param_type;
337 static void Write(Message* m, const param_type& p);
338 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
339 static void Log(const param_type& p, std::string* l);
342 template <>
343 struct ParamTraits<HostID> {
344 typedef HostID param_type;
345 static void Write(Message* m, const param_type& p);
346 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
347 static void Log(const param_type& p, std::string* l);
350 template <>
351 struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
352 typedef ExtensionMsg_PermissionSetStruct param_type;
353 static void Write(Message* m, const param_type& p);
354 static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
355 static void Log(const param_type& p, std::string* l);
358 template <>
359 struct ParamTraits<ExtensionMsg_Loaded_Params> {
360 typedef ExtensionMsg_Loaded_Params param_type;
361 static void Write(Message* m, const param_type& p);
362 static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
363 static void Log(const param_type& p, std::string* l);
366 } // namespace IPC
368 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
370 IPC_ENUM_TRAITS_MAX_VALUE(
371 ExtensionHostMsg_AutomationQuerySelector_Error::Value,
372 ExtensionHostMsg_AutomationQuerySelector_Error::kNodeDestroyed)
374 IPC_STRUCT_TRAITS_BEGIN(ExtensionHostMsg_AutomationQuerySelector_Error)
375 IPC_STRUCT_TRAITS_MEMBER(value)
376 IPC_STRUCT_TRAITS_END()
378 // Parameters structure for ExtensionMsg_UpdatePermissions.
379 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params)
380 IPC_STRUCT_MEMBER(std::string, extension_id)
381 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions)
382 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions)
383 IPC_STRUCT_END()
385 // Messages sent from the browser to the renderer:
387 // The browser sends this message in response to all extension api calls. The
388 // response data (if any) is one of the base::Value subclasses, wrapped as the
389 // first element in a ListValue.
390 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response,
391 int /* request_id */,
392 bool /* success */,
393 base::ListValue /* response wrapper (see comment above) */,
394 std::string /* error */)
396 // This message is optionally routed. If used as a control message, it will
397 // call a javascript function |function_name| from module |module_name| in
398 // every registered context in the target process. If routed, it will be
399 // restricted to the contexts that are part of the target RenderView.
401 // If |extension_id| is non-empty, the function will be invoked only in
402 // contexts owned by the extension. |args| is a list of primitive Value types
403 // that are passed to the function.
404 IPC_MESSAGE_ROUTED5(ExtensionMsg_MessageInvoke,
405 std::string /* extension_id */,
406 std::string /* module_name */,
407 std::string /* function_name */,
408 base::ListValue /* args */,
409 bool /* delivered as part of a user gesture */)
411 // Set the top-level frame to the provided name.
412 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetFrameName,
413 std::string /* frame_name */)
415 // Tell the renderer process the platforms system font.
416 IPC_MESSAGE_CONTROL2(ExtensionMsg_SetSystemFont,
417 std::string /* font_family */,
418 std::string /* font_size */)
420 // Marks an extension as 'active' in an extension process. 'Active' extensions
421 // have more privileges than other extension content that might end up running
422 // in the process (e.g. because of iframes or content scripts).
423 IPC_MESSAGE_CONTROL1(ExtensionMsg_ActivateExtension,
424 std::string /* extension_id */)
426 // Notifies the renderer that extensions were loaded in the browser.
427 IPC_MESSAGE_CONTROL1(ExtensionMsg_Loaded,
428 std::vector<ExtensionMsg_Loaded_Params>)
430 // Notifies the renderer that an extension was unloaded in the browser.
431 IPC_MESSAGE_CONTROL1(ExtensionMsg_Unloaded,
432 std::string)
434 // Updates the scripting whitelist for extensions in the render process. This is
435 // only used for testing.
436 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetScriptingWhitelist,
437 // extension ids
438 extensions::ExtensionsClient::ScriptingWhitelist)
440 // Notification that renderer should run some JavaScript code.
441 IPC_MESSAGE_ROUTED1(ExtensionMsg_ExecuteCode,
442 ExtensionMsg_ExecuteCode_Params)
444 // Notification that the user scripts have been updated. It has one
445 // SharedMemoryHandle argument consisting of the pickled script data. This
446 // handle is valid in the context of the renderer.
447 // If |owner| is not empty, then the shared memory handle refers to |owner|'s
448 // programmatically-defined scripts. Otherwise, the handle refers to all
449 // hosts' statically defined scripts. So far, only extension-hosts support
450 // statically defined scripts; WebUI-hosts don't.
451 // If |changed_hosts| is not empty, only the host in that set will
452 // be updated. Otherwise, all hosts that have scripts in the shared memory
453 // region will be updated. Note that the empty set => all hosts case is not
454 // supported for per-extension programmatically-defined script regions; in such
455 // regions, the owner is expected to list itself as the only changed host.
456 // If |whitelisted_only| is true, this process should only run whitelisted
457 // scripts and not all user scripts.
458 IPC_MESSAGE_CONTROL4(ExtensionMsg_UpdateUserScripts,
459 base::SharedMemoryHandle,
460 HostID /* owner */,
461 std::set<HostID> /* changed hosts */,
462 bool /* whitelisted_only */)
464 // Trigger to execute declarative content script under browser control.
465 IPC_MESSAGE_ROUTED4(ExtensionMsg_ExecuteDeclarativeScript,
466 int /* tab identifier */,
467 extensions::ExtensionId /* extension identifier */,
468 int /* script identifier */,
469 GURL /* page URL where script should be injected */)
471 // Tell the render view which browser window it's being attached to.
472 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId,
473 int /* id of browser window */)
475 // Tell the render view what its tab ID is.
476 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetTabId,
477 int /* id of tab */)
479 // Tell the renderer to update an extension's permission set.
480 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdatePermissions,
481 ExtensionMsg_UpdatePermissions_Params)
483 // Tell the render view about new tab-specific permissions for an extension.
484 IPC_MESSAGE_CONTROL5(ExtensionMsg_UpdateTabSpecificPermissions,
485 GURL /* url */,
486 std::string /* extension_id */,
487 extensions::URLPatternSet /* hosts */,
488 bool /* update origin whitelist */,
489 int /* tab_id */)
491 // Tell the render view to clear tab-specific permissions for some extensions.
492 IPC_MESSAGE_CONTROL3(ExtensionMsg_ClearTabSpecificPermissions,
493 std::vector<std::string> /* extension_ids */,
494 bool /* update origin whitelist */,
495 int /* tab_id */)
497 // Tell the renderer which type this view is.
498 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType,
499 extensions::ViewType /* view_type */)
501 // Deliver a message sent with ExtensionHostMsg_PostMessage.
502 IPC_MESSAGE_CONTROL1(ExtensionMsg_UsingWebRequestAPI,
503 bool /* webrequest_used */)
505 // The browser's response to the ExtensionMsg_WakeEventPage IPC.
506 IPC_MESSAGE_CONTROL2(ExtensionMsg_WakeEventPageResponse,
507 int /* request_id */,
508 bool /* success */)
510 // Ask the lazy background page if it is ready to be suspended. This is sent
511 // when the page is considered idle. The renderer will reply with the same
512 // sequence_id so that we can tell which message it is responding to.
513 IPC_MESSAGE_CONTROL2(ExtensionMsg_ShouldSuspend,
514 std::string /* extension_id */,
515 uint64 /* sequence_id */)
517 // If we complete a round of ShouldSuspend->ShouldSuspendAck messages without
518 // the lazy background page becoming active again, we are ready to unload. This
519 // message tells the page to dispatch the suspend event.
520 IPC_MESSAGE_CONTROL1(ExtensionMsg_Suspend,
521 std::string /* extension_id */)
523 // The browser changed its mind about suspending this extension.
524 IPC_MESSAGE_CONTROL1(ExtensionMsg_CancelSuspend,
525 std::string /* extension_id */)
527 // Response to the renderer for ExtensionHostMsg_GetAppInstallState.
528 IPC_MESSAGE_ROUTED2(ExtensionMsg_GetAppInstallStateResponse,
529 std::string /* state */,
530 int32 /* callback_id */)
532 // Dispatch the Port.onConnect event for message channels.
533 IPC_MESSAGE_ROUTED5(ExtensionMsg_DispatchOnConnect,
534 int /* target_port_id */,
535 std::string /* channel_name */,
536 ExtensionMsg_TabConnectionInfo /* source */,
537 ExtensionMsg_ExternalConnectionInfo,
538 std::string /* tls_channel_id */)
540 // Deliver a message sent with ExtensionHostMsg_PostMessage.
541 IPC_MESSAGE_ROUTED2(ExtensionMsg_DeliverMessage,
542 int /* target_port_id */,
543 extensions::Message)
545 // Dispatch the Port.onDisconnect event for message channels.
546 IPC_MESSAGE_ROUTED2(ExtensionMsg_DispatchOnDisconnect,
547 int /* port_id */,
548 std::string /* error_message */)
550 // Informs the renderer what channel (dev, beta, stable, etc) is running.
551 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetChannel,
552 int /* channel */)
554 // Notify the renderer that its window has closed.
555 IPC_MESSAGE_ROUTED0(ExtensionMsg_AppWindowClosed)
557 // Notify the renderer that an extension wants notifications when certain
558 // searches match the active page. This message replaces the old set of
559 // searches, and triggers ExtensionHostMsg_OnWatchedPageChange messages from
560 // each tab to keep the browser updated about changes.
561 IPC_MESSAGE_CONTROL1(ExtensionMsg_WatchPages,
562 std::vector<std::string> /* CSS selectors */)
564 // Send by the browser to indicate a Blob handle has been transferred to the
565 // renderer. This is sent after the actual extension response, and depends on
566 // the sequential nature of IPCs so that the blob has already been caught.
567 // This is a separate control message, so that the renderer process will send
568 // an acknowledgement even if the RenderView has closed or navigated away.
569 IPC_MESSAGE_CONTROL1(ExtensionMsg_TransferBlobs,
570 std::vector<std::string> /* blob_uuids */)
572 // Report the WebView partition ID to the WebView guest renderer process.
573 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetWebViewPartitionID,
574 std::string /* webview_partition_id */)
576 // Messages sent from the renderer to the browser:
578 // A renderer sends this message when an extension process starts an API
579 // request. The browser will always respond with a ExtensionMsg_Response.
580 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request,
581 ExtensionHostMsg_Request_Params)
583 // A renderer sends this message when an extension process starts an API
584 // request. The browser will always respond with a ExtensionMsg_Response.
585 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_RequestForIOThread,
586 int /* routing_id */,
587 ExtensionHostMsg_Request_Params)
589 // Notify the browser that the given extension added a listener to an event.
590 IPC_MESSAGE_CONTROL3(ExtensionHostMsg_AddListener,
591 std::string /* extension_id */,
592 GURL /* listener_url */,
593 std::string /* name */)
595 // Notify the browser that the given extension removed a listener from an
596 // event.
597 IPC_MESSAGE_CONTROL3(ExtensionHostMsg_RemoveListener,
598 std::string /* extension_id */,
599 GURL /* listener_url */,
600 std::string /* name */)
602 // Notify the browser that the given extension added a listener to an event from
603 // a lazy background page.
604 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddLazyListener,
605 std::string /* extension_id */,
606 std::string /* name */)
608 // Notify the browser that the given extension is no longer interested in
609 // receiving the given event from a lazy background page.
610 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_RemoveLazyListener,
611 std::string /* extension_id */,
612 std::string /* name */)
614 // Notify the browser that the given extension added a listener to instances of
615 // the named event that satisfy the filter.
616 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_AddFilteredListener,
617 std::string /* extension_id */,
618 std::string /* name */,
619 base::DictionaryValue /* filter */,
620 bool /* lazy */)
622 // Notify the browser that the given extension is no longer interested in
623 // instances of the named event that satisfy the filter.
624 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_RemoveFilteredListener,
625 std::string /* extension_id */,
626 std::string /* name */,
627 base::DictionaryValue /* filter */,
628 bool /* lazy */)
630 // Notify the browser that an event has finished being dispatched.
631 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_EventAck, int /* message_id */)
633 // Open a channel to all listening contexts owned by the extension with
634 // the given ID. This always returns a valid port ID which can be used for
635 // sending messages. If an error occurred, the opener will be notified
636 // asynchronously.
637 IPC_SYNC_MESSAGE_CONTROL4_1(ExtensionHostMsg_OpenChannelToExtension,
638 int /* routing_id */,
639 ExtensionMsg_ExternalConnectionInfo,
640 std::string /* channel_name */,
641 bool /* include_tls_channel_id */,
642 int /* port_id */)
644 IPC_SYNC_MESSAGE_CONTROL3_1(ExtensionHostMsg_OpenChannelToNativeApp,
645 int /* routing_id */,
646 std::string /* source_extension_id */,
647 std::string /* native_app_name */,
648 int /* port_id */)
650 // Get a port handle to the given tab. The handle can be used for sending
651 // messages to the extension.
652 IPC_SYNC_MESSAGE_CONTROL3_1(ExtensionHostMsg_OpenChannelToTab,
653 ExtensionMsg_TabTargetConnectionInfo,
654 std::string /* extension_id */,
655 std::string /* channel_name */,
656 int /* port_id */)
658 // Send a message to an extension process. The handle is the value returned
659 // by ViewHostMsg_OpenChannelTo*.
660 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_PostMessage,
661 int /* port_id */,
662 extensions::Message)
664 // Send a message to an extension process. The handle is the value returned
665 // by ViewHostMsg_OpenChannelTo*.
666 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_CloseChannel,
667 int /* port_id */,
668 std::string /* error_message */)
670 // Used to get the extension message bundle.
671 IPC_SYNC_MESSAGE_CONTROL1_1(ExtensionHostMsg_GetMessageBundle,
672 std::string /* extension id */,
673 SubstitutionMap /* message bundle */)
675 // Sent from the renderer to the browser to return the script running result.
676 IPC_MESSAGE_ROUTED4(
677 ExtensionHostMsg_ExecuteCodeFinished,
678 int /* request id */,
679 std::string /* error; empty implies success */,
680 GURL /* URL of the code executed on. May be empty if unsuccessful. */,
681 base::ListValue /* result of the script */)
683 // Sent from the renderer to the browser to notify that content scripts are
684 // running in the renderer that the IPC originated from.
685 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_ContentScriptsExecuting,
686 ExecutingScriptsMap,
687 GURL /* url of the _topmost_ frame */)
689 // Sent from the renderer to the browser to request permission for a script
690 // injection.
691 // If request id is -1, this signals that the request has already ran, and this
692 // merely serves as a notification. This happens when the feature to disable
693 // scripts running without user consent is not enabled.
694 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_RequestScriptInjectionPermission,
695 std::string /* extension id */,
696 extensions::UserScript::InjectionType /* script type */,
697 int64 /* request id */)
699 // Sent from the browser to the renderer in reply to a
700 // RequestScriptInjectionPermission message, granting permission for a script
701 // script to run.
702 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection,
703 int64 /* request id */)
705 // Sent by the renderer when a web page is checking if its app is installed.
706 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState,
707 GURL /* requestor_url */,
708 int32 /* return_route_id */,
709 int32 /* callback_id */)
711 // Optional Ack message sent to the browser to notify that the response to a
712 // function has been processed.
713 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_ResponseAck,
714 int /* request_id */)
716 // Response to ExtensionMsg_ShouldSuspend.
717 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_ShouldSuspendAck,
718 std::string /* extension_id */,
719 uint64 /* sequence_id */)
721 // Response to ExtensionMsg_Suspend, after we dispatch the suspend event.
722 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_SuspendAck,
723 std::string /* extension_id */)
725 // Informs the browser to increment the keepalive count for the lazy background
726 // page, keeping it alive.
727 IPC_MESSAGE_ROUTED0(ExtensionHostMsg_IncrementLazyKeepaliveCount)
729 // Informs the browser there is one less thing keeping the lazy background page
730 // alive.
731 IPC_MESSAGE_ROUTED0(ExtensionHostMsg_DecrementLazyKeepaliveCount)
733 // Fetches a globally unique ID (for the lifetime of the browser) from the
734 // browser process.
735 IPC_SYNC_MESSAGE_CONTROL0_1(ExtensionHostMsg_GenerateUniqueID,
736 int /* unique_id */)
738 // Notify the browser that an app window is ready and can resume resource
739 // requests.
740 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_AppWindowReady, int /* route_id */)
742 // Sent by the renderer when the draggable regions are updated.
743 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_UpdateDraggableRegions,
744 std::vector<extensions::DraggableRegion> /* regions */)
746 // Sent by the renderer to log an API action to the extension activity log.
747 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddAPIActionToActivityLog,
748 std::string /* extension_id */,
749 ExtensionHostMsg_APIActionOrEvent_Params)
751 // Sent by the renderer to log an event to the extension activity log.
752 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddEventToActivityLog,
753 std::string /* extension_id */,
754 ExtensionHostMsg_APIActionOrEvent_Params)
756 // Sent by the renderer to log a DOM action to the extension activity log.
757 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddDOMActionToActivityLog,
758 std::string /* extension_id */,
759 ExtensionHostMsg_DOMAction_Params)
761 // Notifies the browser process that a tab has started or stopped matching
762 // certain conditions. This message is sent in response to several events:
764 // * ExtensionMsg_WatchPages was received, updating the set of conditions.
765 // * A new page is loaded. This will be sent after
766 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the
767 // main frame.
768 // * Something changed on an existing frame causing the set of matching searches
769 // to change.
770 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange,
771 std::vector<std::string> /* Matching CSS selectors */)
773 // Sent by the renderer when it has received a Blob handle from the browser.
774 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck,
775 std::vector<std::string> /* blob_uuids */)
777 // Asks the browser to wake the event page of an extension.
778 // The browser will reply with ExtensionHostMsg_WakeEventPageResponse.
779 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_WakeEventPage,
780 int /* request_id */,
781 std::string /* extension_id */)
783 // Tells listeners that a detailed message was reported to the console by
784 // WebKit.
785 IPC_MESSAGE_ROUTED4(ExtensionHostMsg_DetailedConsoleMessageAdded,
786 base::string16 /* message */,
787 base::string16 /* source */,
788 extensions::StackTrace /* stack trace */,
789 int32 /* severity level */)
791 // Sent when a query selector request is made from the automation API.
792 // acc_obj_id is the accessibility tree ID of the starting element.
793 IPC_MESSAGE_ROUTED3(ExtensionMsg_AutomationQuerySelector,
794 int /* request_id */,
795 int /* acc_obj_id */,
796 base::string16 /* selector */)
798 // Result of a query selector request.
799 // result_acc_obj_id is the accessibility tree ID of the result element; 0
800 // indicates no result.
801 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_AutomationQuerySelector_Result,
802 int /* request_id */,
803 ExtensionHostMsg_AutomationQuerySelector_Error /* error */,
804 int /* result_acc_obj_id */)