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