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. 4 5 // IPC messages for extensions. 6 // Multiply-included message file, hence no include guard. 7 8 #include <string> 9 #include <vector> 10 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/permissions/media_galleries_permission_data.h" 20 #include "extensions/common/permissions/permission_set.h" 21 #include "extensions/common/permissions/socket_permission_data.h" 22 #include "extensions/common/permissions/usb_device_permission_data.h" 23 #include "extensions/common/stack_frame.h" 24 #include "extensions/common/url_pattern.h" 25 #include "extensions/common/url_pattern_set.h" 26 #include "extensions/common/user_script.h" 27 #include "extensions/common/view_type.h" 28 #include "ipc/ipc_message_macros.h" 29 #include "ui/gfx/ipc/gfx_param_traits.h" 30 #include "url/gurl.h" 31 32 #define IPC_MESSAGE_START ExtensionMsgStart 33 34 IPC_ENUM_TRAITS_MAX_VALUE(extensions::ViewType, extensions::VIEW_TYPE_LAST) 35 IPC_ENUM_TRAITS_MAX_VALUE(content::SocketPermissionRequest::OperationType, 36 content::SocketPermissionRequest::OPERATION_TYPE_LAST) 37 38 IPC_ENUM_TRAITS_MAX_VALUE(extensions::UserScript::InjectionType, 39 extensions::UserScript::INJECTION_TYPE_LAST) 40 41 // Parameters structure for ExtensionHostMsg_AddAPIActionToActivityLog and 42 // ExtensionHostMsg_AddEventToActivityLog. 43 IPC_STRUCT_BEGIN(ExtensionHostMsg_APIActionOrEvent_Params) 44 // API name. 45 IPC_STRUCT_MEMBER(std::string, api_call) 46 47 // List of arguments. 48 IPC_STRUCT_MEMBER(base::ListValue, arguments) 49 50 // Extra logging information. 51 IPC_STRUCT_MEMBER(std::string, extra) 52 IPC_STRUCT_END() 53 54 // Parameters structure for ExtensionHostMsg_AddDOMActionToActivityLog. 55 IPC_STRUCT_BEGIN(ExtensionHostMsg_DOMAction_Params) 56 // URL of the page. 57 IPC_STRUCT_MEMBER(GURL, url) 58 59 // Title of the page. 60 IPC_STRUCT_MEMBER(base::string16, url_title) 61 62 // API name. 63 IPC_STRUCT_MEMBER(std::string, api_call) 64 65 // List of arguments. 66 IPC_STRUCT_MEMBER(base::ListValue, arguments) 67 68 // Type of DOM API call. 69 IPC_STRUCT_MEMBER(int, call_type) 70 IPC_STRUCT_END() 71 72 // Parameters structure for ExtensionHostMsg_Request. 73 IPC_STRUCT_BEGIN(ExtensionHostMsg_Request_Params) 74 // Message name. 75 IPC_STRUCT_MEMBER(std::string, name) 76 77 // List of message arguments. 78 IPC_STRUCT_MEMBER(base::ListValue, arguments) 79 80 // Extension ID this request was sent from. This can be empty, in the case 81 // where we expose APIs to normal web pages using the extension function 82 // system. 83 IPC_STRUCT_MEMBER(std::string, extension_id) 84 85 // URL of the frame the request was sent from. This isn't necessarily an 86 // extension url. Extension requests can also originate from content scripts, 87 // in which case extension_id will indicate the ID of the associated 88 // extension. Or, they can originate from hosted apps or normal web pages. 89 IPC_STRUCT_MEMBER(GURL, source_url) 90 91 // The id of the tab that sent this request, or -1 if there is no source tab. 92 IPC_STRUCT_MEMBER(int, source_tab_id) 93 94 // Unique request id to match requests and responses. 95 IPC_STRUCT_MEMBER(int, request_id) 96 97 // True if request has a callback specified. 98 IPC_STRUCT_MEMBER(bool, has_callback) 99 100 // True if request is executed in response to an explicit user gesture. 101 IPC_STRUCT_MEMBER(bool, user_gesture) 102 IPC_STRUCT_END() 103 104 // Allows an extension to execute code in a tab. 105 IPC_STRUCT_BEGIN(ExtensionMsg_ExecuteCode_Params) 106 // The extension API request id, for responding. 107 IPC_STRUCT_MEMBER(int, request_id) 108 109 // The ID of the requesting extension. To know which isolated world to 110 // execute the code inside of. 111 IPC_STRUCT_MEMBER(std::string, extension_id) 112 113 // Whether the code is JavaScript or CSS. 114 IPC_STRUCT_MEMBER(bool, is_javascript) 115 116 // String of code to execute. 117 IPC_STRUCT_MEMBER(std::string, code) 118 119 // The webview guest source who calls to execute code. 120 IPC_STRUCT_MEMBER(GURL, webview_src) 121 122 // Whether to inject into all frames, or only the root frame. 123 IPC_STRUCT_MEMBER(bool, all_frames) 124 125 // Whether to inject into about:blank (sub)frames. 126 IPC_STRUCT_MEMBER(bool, match_about_blank) 127 128 // When to inject the code. 129 IPC_STRUCT_MEMBER(int, run_at) 130 131 // Whether to execute code in the main world (as opposed to an isolated 132 // world). 133 IPC_STRUCT_MEMBER(bool, in_main_world) 134 135 // Whether the request is coming from a <webview>. 136 IPC_STRUCT_MEMBER(bool, is_web_view) 137 138 // Whether the caller is interested in the result value. Manifest-declared 139 // content scripts and executeScript() calls without a response callback 140 // are examples of when this will be false. 141 IPC_STRUCT_MEMBER(bool, wants_result) 142 143 // The URL of the file that was injected, if any. 144 IPC_STRUCT_MEMBER(GURL, file_url) 145 146 // Whether the code to be executed should be associated with a user gesture. 147 IPC_STRUCT_MEMBER(bool, user_gesture) 148 IPC_STRUCT_END() 149 150 // Struct containing the data for external connections to extensions. Used to 151 // handle the IPCs initiated by both connect() and onConnect(). 152 IPC_STRUCT_BEGIN(ExtensionMsg_ExternalConnectionInfo) 153 // The ID of the extension that is the target of the request. 154 IPC_STRUCT_MEMBER(std::string, target_id) 155 156 // The ID of the extension that initiated the request. May be empty if it 157 // wasn't initiated by an extension. 158 IPC_STRUCT_MEMBER(std::string, source_id) 159 160 // The URL of the frame that initiated the request. 161 IPC_STRUCT_MEMBER(GURL, source_url) 162 IPC_STRUCT_END() 163 164 IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion) 165 IPC_STRUCT_TRAITS_MEMBER(draggable) 166 IPC_STRUCT_TRAITS_MEMBER(bounds) 167 IPC_STRUCT_TRAITS_END() 168 169 IPC_STRUCT_TRAITS_BEGIN(content::SocketPermissionRequest) 170 IPC_STRUCT_TRAITS_MEMBER(type) 171 IPC_STRUCT_TRAITS_MEMBER(host) 172 IPC_STRUCT_TRAITS_MEMBER(port) 173 IPC_STRUCT_TRAITS_END() 174 175 IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionEntry) 176 IPC_STRUCT_TRAITS_MEMBER(pattern_) 177 IPC_STRUCT_TRAITS_MEMBER(match_subdomains_) 178 IPC_STRUCT_TRAITS_END() 179 180 IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionData) 181 IPC_STRUCT_TRAITS_MEMBER(entry()) 182 IPC_STRUCT_TRAITS_END() 183 184 IPC_STRUCT_TRAITS_BEGIN(extensions::StackFrame) 185 IPC_STRUCT_TRAITS_MEMBER(line_number) 186 IPC_STRUCT_TRAITS_MEMBER(column_number) 187 IPC_STRUCT_TRAITS_MEMBER(source) 188 IPC_STRUCT_TRAITS_MEMBER(function) 189 IPC_STRUCT_TRAITS_END() 190 191 IPC_STRUCT_TRAITS_BEGIN(extensions::UsbDevicePermissionData) 192 IPC_STRUCT_TRAITS_MEMBER(vendor_id()) 193 IPC_STRUCT_TRAITS_MEMBER(product_id()) 194 IPC_STRUCT_TRAITS_END() 195 196 IPC_STRUCT_TRAITS_BEGIN(extensions::MediaGalleriesPermissionData) 197 IPC_STRUCT_TRAITS_MEMBER(permission()) 198 IPC_STRUCT_TRAITS_END() 199 200 IPC_STRUCT_TRAITS_BEGIN(extensions::Message) 201 IPC_STRUCT_TRAITS_MEMBER(data) 202 IPC_STRUCT_TRAITS_MEMBER(user_gesture) 203 IPC_STRUCT_TRAITS_END() 204 205 // Singly-included section for custom IPC traits. 206 #ifndef EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ 207 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ 208 209 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need 210 // to typedef it to avoid that. 211 // Substitution map for l10n messages. 212 typedef std::map<std::string, std::string> SubstitutionMap; 213 214 // Map of extensions IDs to the executing script paths. 215 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; 216 217 struct ExtensionMsg_PermissionSetStruct { 218 ExtensionMsg_PermissionSetStruct(); 219 explicit ExtensionMsg_PermissionSetStruct( 220 const extensions::PermissionSet& permissions); 221 ~ExtensionMsg_PermissionSetStruct(); 222 223 scoped_refptr<const extensions::PermissionSet> ToPermissionSet() const; 224 225 extensions::APIPermissionSet apis; 226 extensions::ManifestPermissionSet manifest_permissions; 227 extensions::URLPatternSet explicit_hosts; 228 extensions::URLPatternSet scriptable_hosts; 229 }; 230 231 struct ExtensionMsg_Loaded_Params { 232 ExtensionMsg_Loaded_Params(); 233 ~ExtensionMsg_Loaded_Params(); 234 explicit ExtensionMsg_Loaded_Params(const extensions::Extension* extension); 235 236 // Creates a new extension from the data in this object. 237 scoped_refptr<extensions::Extension> ConvertToExtension( 238 std::string* error) const; 239 240 // The subset of the extension manifest data we send to renderers. 241 linked_ptr<base::DictionaryValue> manifest; 242 243 // The location the extension was installed from. 244 extensions::Manifest::Location location; 245 246 // The path the extension was loaded from. This is used in the renderer only 247 // to generate the extension ID for extensions that are loaded unpacked. 248 base::FilePath path; 249 250 // The extension's active and withheld permissions. 251 ExtensionMsg_PermissionSetStruct active_permissions; 252 ExtensionMsg_PermissionSetStruct withheld_permissions; 253 254 // We keep this separate so that it can be used in logging. 255 std::string id; 256 257 // Send creation flags so extension is initialized identically. 258 int creation_flags; 259 }; 260 261 namespace IPC { 262 263 template <> 264 struct ParamTraits<URLPattern> { 265 typedef URLPattern param_type; 266 static void Write(Message* m, const param_type& p); 267 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 268 static void Log(const param_type& p, std::string* l); 269 }; 270 271 template <> 272 struct ParamTraits<extensions::URLPatternSet> { 273 typedef extensions::URLPatternSet param_type; 274 static void Write(Message* m, const param_type& p); 275 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 276 static void Log(const param_type& p, std::string* l); 277 }; 278 279 template <> 280 struct ParamTraits<extensions::APIPermission::ID> { 281 typedef extensions::APIPermission::ID param_type; 282 static void Write(Message* m, const param_type& p); 283 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 284 static void Log(const param_type& p, std::string* l); 285 }; 286 287 template <> 288 struct ParamTraits<extensions::APIPermissionSet> { 289 typedef extensions::APIPermissionSet param_type; 290 static void Write(Message* m, const param_type& p); 291 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 292 static void Log(const param_type& p, std::string* l); 293 }; 294 295 template <> 296 struct ParamTraits<extensions::ManifestPermissionSet> { 297 typedef extensions::ManifestPermissionSet param_type; 298 static void Write(Message* m, const param_type& p); 299 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 300 static void Log(const param_type& p, std::string* l); 301 }; 302 303 template <> 304 struct ParamTraits<ExtensionMsg_PermissionSetStruct> { 305 typedef ExtensionMsg_PermissionSetStruct param_type; 306 static void Write(Message* m, const param_type& p); 307 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 308 static void Log(const param_type& p, std::string* l); 309 }; 310 311 template <> 312 struct ParamTraits<ExtensionMsg_Loaded_Params> { 313 typedef ExtensionMsg_Loaded_Params param_type; 314 static void Write(Message* m, const param_type& p); 315 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 316 static void Log(const param_type& p, std::string* l); 317 }; 318 319 } // namespace IPC 320 321 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ 322 323 // Parameters structure for ExtensionMsg_UpdatePermissions. 324 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params) 325 IPC_STRUCT_MEMBER(std::string, extension_id) 326 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions) 327 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions) 328 IPC_STRUCT_END() 329 330 // Messages sent from the browser to the renderer. 331 332 // The browser sends this message in response to all extension api calls. The 333 // response data (if any) is one of the base::Value subclasses, wrapped as the 334 // first element in a ListValue. 335 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, 336 int /* request_id */, 337 bool /* success */, 338 base::ListValue /* response wrapper (see comment above) */, 339 std::string /* error */) 340 341 // This message is optionally routed. If used as a control message, it will 342 // call a javascript function |function_name| from module |module_name| in 343 // every registered context in the target process. If routed, it will be 344 // restricted to the contexts that are part of the target RenderView. 345 // 346 // If |extension_id| is non-empty, the function will be invoked only in 347 // contexts owned by the extension. |args| is a list of primitive Value types 348 // that are passed to the function. 349 IPC_MESSAGE_ROUTED5(ExtensionMsg_MessageInvoke, 350 std::string /* extension_id */, 351 std::string /* module_name */, 352 std::string /* function_name */, 353 base::ListValue /* args */, 354 bool /* delivered as part of a user gesture */) 355 356 // Tell the renderer process all known extension function names. 357 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetFunctionNames, 358 std::vector<std::string>) 359 360 // Set the top-level frame to the provided name. 361 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetFrameName, 362 std::string /* frame_name */) 363 364 // Tell the renderer process the platforms system font. 365 IPC_MESSAGE_CONTROL2(ExtensionMsg_SetSystemFont, 366 std::string /* font_family */, 367 std::string /* font_size */) 368 369 // Marks an extension as 'active' in an extension process. 'Active' extensions 370 // have more privileges than other extension content that might end up running 371 // in the process (e.g. because of iframes or content scripts). 372 IPC_MESSAGE_CONTROL1(ExtensionMsg_ActivateExtension, 373 std::string /* extension_id */) 374 375 // Notifies the renderer that extensions were loaded in the browser. 376 IPC_MESSAGE_CONTROL1(ExtensionMsg_Loaded, 377 std::vector<ExtensionMsg_Loaded_Params>) 378 379 // Notifies the renderer that an extension was unloaded in the browser. 380 IPC_MESSAGE_CONTROL1(ExtensionMsg_Unloaded, 381 std::string) 382 383 // Updates the scripting whitelist for extensions in the render process. This is 384 // only used for testing. 385 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetScriptingWhitelist, 386 // extension ids 387 extensions::ExtensionsClient::ScriptingWhitelist) 388 389 // Notification that renderer should run some JavaScript code. 390 IPC_MESSAGE_ROUTED1(ExtensionMsg_ExecuteCode, 391 ExtensionMsg_ExecuteCode_Params) 392 393 // Notification that the user scripts have been updated. It has one 394 // SharedMemoryHandle argument consisting of the pickled script data. This 395 // handle is valid in the context of the renderer. 396 // If |owner| is not empty, then the shared memory handle refers to |owner|'s 397 // programmatically-defined scripts. Otherwise, the handle refers to all 398 // extensions' statically defined scripts. 399 // If |changed_extensions| is not empty, only the extensions in that set will 400 // be updated. Otherwise, all extensions that have scripts in the shared memory 401 // region will be updated. Note that the empty set => all extensions case is not 402 // supported for per-extension programmatically-defined script regions; in such 403 // regions, the owner is expected to list itself as the only changed extension. 404 IPC_MESSAGE_CONTROL3(ExtensionMsg_UpdateUserScripts, 405 base::SharedMemoryHandle, 406 extensions::ExtensionId /* owner */, 407 std::set<std::string> /* changed extensions */) 408 409 // Trigger to execute declarative content script under browser control. 410 IPC_MESSAGE_ROUTED4(ExtensionMsg_ExecuteDeclarativeScript, 411 int /* tab identifier */, 412 extensions::ExtensionId /* extension identifier */, 413 int /* script identifier */, 414 GURL /* page URL where script should be injected */) 415 416 // Tell the render view which browser window it's being attached to. 417 IPC_MESSAGE_ROUTED1(ExtensionMsg_UpdateBrowserWindowId, 418 int /* id of browser window */) 419 420 // Tell the render view what its tab ID is. 421 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetTabId, 422 int /* id of tab */) 423 424 // Tell the renderer to update an extension's permission set. 425 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdatePermissions, 426 ExtensionMsg_UpdatePermissions_Params) 427 428 // Tell the renderer about new tab-specific permissions for an extension. 429 IPC_MESSAGE_CONTROL4(ExtensionMsg_UpdateTabSpecificPermissions, 430 GURL /* url */, 431 int /* tab_id */, 432 std::string /* extension_id */, 433 extensions::URLPatternSet /* hosts */) 434 435 // Tell the renderer to clear tab-specific permissions for some extensions. 436 IPC_MESSAGE_CONTROL2(ExtensionMsg_ClearTabSpecificPermissions, 437 int /* tab_id */, 438 std::vector<std::string> /* extension_ids */) 439 440 // Tell the renderer which type this view is. 441 IPC_MESSAGE_ROUTED1(ExtensionMsg_NotifyRenderViewType, 442 extensions::ViewType /* view_type */) 443 444 // Deliver a message sent with ExtensionHostMsg_PostMessage. 445 IPC_MESSAGE_CONTROL1(ExtensionMsg_UsingWebRequestAPI, 446 bool /* webrequest_used */) 447 448 // Ask the lazy background page if it is ready to be suspended. This is sent 449 // when the page is considered idle. The renderer will reply with the same 450 // sequence_id so that we can tell which message it is responding to. 451 IPC_MESSAGE_CONTROL2(ExtensionMsg_ShouldSuspend, 452 std::string /* extension_id */, 453 uint64 /* sequence_id */) 454 455 // If we complete a round of ShouldSuspend->ShouldSuspendAck messages without 456 // the lazy background page becoming active again, we are ready to unload. This 457 // message tells the page to dispatch the suspend event. 458 IPC_MESSAGE_CONTROL1(ExtensionMsg_Suspend, 459 std::string /* extension_id */) 460 461 // The browser changed its mind about suspending this extension. 462 IPC_MESSAGE_CONTROL1(ExtensionMsg_CancelSuspend, 463 std::string /* extension_id */) 464 465 // Response to the renderer for ExtensionHostMsg_GetAppInstallState. 466 IPC_MESSAGE_ROUTED2(ExtensionMsg_GetAppInstallStateResponse, 467 std::string /* state */, 468 int32 /* callback_id */) 469 470 // Dispatch the Port.onConnect event for message channels. 471 IPC_MESSAGE_ROUTED5(ExtensionMsg_DispatchOnConnect, 472 int /* target_port_id */, 473 std::string /* channel_name */, 474 base::DictionaryValue /* source_tab */, 475 ExtensionMsg_ExternalConnectionInfo, 476 std::string /* tls_channel_id */) 477 478 // Deliver a message sent with ExtensionHostMsg_PostMessage. 479 IPC_MESSAGE_ROUTED2(ExtensionMsg_DeliverMessage, 480 int /* target_port_id */, 481 extensions::Message) 482 483 // Dispatch the Port.onDisconnect event for message channels. 484 IPC_MESSAGE_ROUTED2(ExtensionMsg_DispatchOnDisconnect, 485 int /* port_id */, 486 std::string /* error_message */) 487 488 // Informs the renderer what channel (dev, beta, stable, etc) is running. 489 IPC_MESSAGE_CONTROL1(ExtensionMsg_SetChannel, 490 int /* channel */) 491 492 // Adds a logging message to the renderer's root frame DevTools console. 493 IPC_MESSAGE_ROUTED2(ExtensionMsg_AddMessageToConsole, 494 content::ConsoleMessageLevel /* level */, 495 std::string /* message */) 496 497 // Notify the renderer that its window has closed. 498 IPC_MESSAGE_ROUTED0(ExtensionMsg_AppWindowClosed) 499 500 // Notify the renderer that an extension wants notifications when certain 501 // searches match the active page. This message replaces the old set of 502 // searches, and triggers ExtensionHostMsg_OnWatchedPageChange messages from 503 // each tab to keep the browser updated about changes. 504 IPC_MESSAGE_CONTROL1(ExtensionMsg_WatchPages, 505 std::vector<std::string> /* CSS selectors */) 506 507 // Send by the browser to indicate a Blob handle has been transferred to the 508 // renderer. This is sent after the actual extension response, and depends on 509 // the sequential nature of IPCs so that the blob has already been caught. 510 // This is a separate control message, so that the renderer process will send 511 // an acknowledgement even if the RenderView has closed or navigated away. 512 IPC_MESSAGE_CONTROL1(ExtensionMsg_TransferBlobs, 513 std::vector<std::string> /* blob_uuids */) 514 515 // The ACK for ExtensionHostMsg_CreateMimeHandlerViewGuest. 516 IPC_MESSAGE_CONTROL1(ExtensionMsg_CreateMimeHandlerViewGuestACK, 517 int /* element_instance_id */) 518 519 // Once a RenderView proxy has been created for the guest in the embedder render 520 // process, this IPC informs the embedder of the proxy's routing ID. 521 IPC_MESSAGE_ROUTED2(ExtensionMsg_GuestAttached, 522 int /* element_instance_id */, 523 int /* source_routing_id */) 524 525 // Messages sent from the renderer to the browser. 526 527 // A renderer sends this message when an extension process starts an API 528 // request. The browser will always respond with a ExtensionMsg_Response. 529 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_Request, 530 ExtensionHostMsg_Request_Params) 531 532 // A renderer sends this message when an extension process starts an API 533 // request. The browser will always respond with a ExtensionMsg_Response. 534 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_RequestForIOThread, 535 int /* routing_id */, 536 ExtensionHostMsg_Request_Params) 537 538 // Notify the browser that the given extension added a listener to an event. 539 IPC_MESSAGE_CONTROL3(ExtensionHostMsg_AddListener, 540 std::string /* extension_id */, 541 GURL /* listener_url */, 542 std::string /* name */) 543 544 // Notify the browser that the given extension removed a listener from an 545 // event. 546 IPC_MESSAGE_CONTROL3(ExtensionHostMsg_RemoveListener, 547 std::string /* extension_id */, 548 GURL /* listener_url */, 549 std::string /* name */) 550 551 // Notify the browser that the given extension added a listener to an event from 552 // a lazy background page. 553 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddLazyListener, 554 std::string /* extension_id */, 555 std::string /* name */) 556 557 // Notify the browser that the given extension is no longer interested in 558 // receiving the given event from a lazy background page. 559 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_RemoveLazyListener, 560 std::string /* extension_id */, 561 std::string /* name */) 562 563 // Notify the browser that the given extension added a listener to instances of 564 // the named event that satisfy the filter. 565 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_AddFilteredListener, 566 std::string /* extension_id */, 567 std::string /* name */, 568 base::DictionaryValue /* filter */, 569 bool /* lazy */) 570 571 // Notify the browser that the given extension is no longer interested in 572 // instances of the named event that satisfy the filter. 573 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_RemoveFilteredListener, 574 std::string /* extension_id */, 575 std::string /* name */, 576 base::DictionaryValue /* filter */, 577 bool /* lazy */) 578 579 // Notify the browser that an event has finished being dispatched. 580 IPC_MESSAGE_ROUTED0(ExtensionHostMsg_EventAck) 581 582 // Open a channel to all listening contexts owned by the extension with 583 // the given ID. This always returns a valid port ID which can be used for 584 // sending messages. If an error occurred, the opener will be notified 585 // asynchronously. 586 IPC_SYNC_MESSAGE_CONTROL4_1(ExtensionHostMsg_OpenChannelToExtension, 587 int /* routing_id */, 588 ExtensionMsg_ExternalConnectionInfo, 589 std::string /* channel_name */, 590 bool /* include_tls_channel_id */, 591 int /* port_id */) 592 593 IPC_SYNC_MESSAGE_CONTROL3_1(ExtensionHostMsg_OpenChannelToNativeApp, 594 int /* routing_id */, 595 std::string /* source_extension_id */, 596 std::string /* native_app_name */, 597 int /* port_id */) 598 599 // Get a port handle to the given tab. The handle can be used for sending 600 // messages to the extension. 601 IPC_SYNC_MESSAGE_CONTROL4_1(ExtensionHostMsg_OpenChannelToTab, 602 int /* routing_id */, 603 int /* tab_id */, 604 std::string /* extension_id */, 605 std::string /* channel_name */, 606 int /* port_id */) 607 608 // Send a message to an extension process. The handle is the value returned 609 // by ViewHostMsg_OpenChannelTo*. 610 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_PostMessage, 611 int /* port_id */, 612 extensions::Message) 613 614 // Send a message to an extension process. The handle is the value returned 615 // by ViewHostMsg_OpenChannelTo*. 616 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_CloseChannel, 617 int /* port_id */, 618 std::string /* error_message */) 619 620 // Used to get the extension message bundle. 621 IPC_SYNC_MESSAGE_CONTROL1_1(ExtensionHostMsg_GetMessageBundle, 622 std::string /* extension id */, 623 SubstitutionMap /* message bundle */) 624 625 // Sent from the renderer to the browser to return the script running result. 626 IPC_MESSAGE_ROUTED4( 627 ExtensionHostMsg_ExecuteCodeFinished, 628 int /* request id */, 629 std::string /* error; empty implies success */, 630 GURL /* URL of the code executed on. May be empty if unsuccessful. */, 631 base::ListValue /* result of the script */) 632 633 // Sent from the renderer to the browser to notify that content scripts are 634 // running in the renderer that the IPC originated from. 635 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_ContentScriptsExecuting, 636 ExecutingScriptsMap, 637 GURL /* url of the _topmost_ frame */) 638 639 // Sent from the renderer to the browser to request permission for a script 640 // injection. 641 // If request id is -1, this signals that the request has already ran, and this 642 // merely serves as a notification. This happens when the feature to disable 643 // scripts running without user consent is not enabled. 644 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_RequestScriptInjectionPermission, 645 std::string /* extension id */, 646 extensions::UserScript::InjectionType /* script type */, 647 int64 /* request id */) 648 649 // Sent from the browser to the renderer in reply to a 650 // RequestScriptInjectionPermission message, granting permission for a script 651 // script to run. 652 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection, 653 int64 /* request id */) 654 655 // Sent by the renderer when a web page is checking if its app is installed. 656 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState, 657 GURL /* requestor_url */, 658 int32 /* return_route_id */, 659 int32 /* callback_id */) 660 661 // Optional Ack message sent to the browser to notify that the response to a 662 // function has been processed. 663 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_ResponseAck, 664 int /* request_id */) 665 666 // Response to ExtensionMsg_ShouldSuspend. 667 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_ShouldSuspendAck, 668 std::string /* extension_id */, 669 uint64 /* sequence_id */) 670 671 // Response to ExtensionMsg_Suspend, after we dispatch the suspend event. 672 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_SuspendAck, 673 std::string /* extension_id */) 674 675 // Informs the browser to increment the keepalive count for the lazy background 676 // page, keeping it alive. 677 IPC_MESSAGE_ROUTED0(ExtensionHostMsg_IncrementLazyKeepaliveCount) 678 679 // Informs the browser there is one less thing keeping the lazy background page 680 // alive. 681 IPC_MESSAGE_ROUTED0(ExtensionHostMsg_DecrementLazyKeepaliveCount) 682 683 // Fetches a globally unique ID (for the lifetime of the browser) from the 684 // browser process. 685 IPC_SYNC_MESSAGE_CONTROL0_1(ExtensionHostMsg_GenerateUniqueID, 686 int /* unique_id */) 687 688 // Resumes resource requests for a newly created app window. 689 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_ResumeRequests, int /* route_id */) 690 691 // Sent by the renderer when the draggable regions are updated. 692 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_UpdateDraggableRegions, 693 std::vector<extensions::DraggableRegion> /* regions */) 694 695 // Sent by the renderer to log an API action to the extension activity log. 696 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddAPIActionToActivityLog, 697 std::string /* extension_id */, 698 ExtensionHostMsg_APIActionOrEvent_Params) 699 700 // Sent by the renderer to log an event to the extension activity log. 701 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddEventToActivityLog, 702 std::string /* extension_id */, 703 ExtensionHostMsg_APIActionOrEvent_Params) 704 705 // Sent by the renderer to log a DOM action to the extension activity log. 706 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_AddDOMActionToActivityLog, 707 std::string /* extension_id */, 708 ExtensionHostMsg_DOMAction_Params) 709 710 // Notifies the browser process that a tab has started or stopped matching 711 // certain conditions. This message is sent in response to several events: 712 // 713 // * ExtensionMsg_WatchPages was received, updating the set of conditions. 714 // * A new page is loaded. This will be sent after 715 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the 716 // main frame. 717 // * Something changed on an existing frame causing the set of matching searches 718 // to change. 719 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange, 720 std::vector<std::string> /* Matching CSS selectors */) 721 722 // Sent by the renderer when it has received a Blob handle from the browser. 723 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck, 724 std::vector<std::string> /* blob_uuids */) 725 726 // Informs of updated frame names. 727 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_FrameNameChanged, 728 bool /* is_top_level */, 729 std::string /* name */) 730 731 // Tells listeners that a detailed message was reported to the console by 732 // WebKit. 733 IPC_MESSAGE_ROUTED4(ExtensionHostMsg_DetailedConsoleMessageAdded, 734 base::string16 /* message */, 735 base::string16 /* source */, 736 extensions::StackTrace /* stack trace */, 737 int32 /* severity level */) 738 739 // Sent by the renderer to set initialization parameters of a Browser Plugin 740 // that is identified by |element_instance_id|. 741 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_AttachGuest, 742 int /* routing_id */, 743 int /* element_instance_id */, 744 int /* guest_instance_id */, 745 base::DictionaryValue /* attach_params */) 746 747 // Tells the browser to create a mime handler guest view for a plugin. 748 IPC_MESSAGE_CONTROL4(ExtensionHostMsg_CreateMimeHandlerViewGuest, 749 int /* render_frame_id */, 750 std::string /* embedder_url */, 751 std::string /* mime_type */, 752 int /* element_instance_id */) 753