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