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