| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // IPC messages for extensions. | 5 // IPC messages for extensions. |
| 6 // Multiply-included message file, hence no include guard. | 6 // Multiply-included message file, hence no include guard. |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/public/common/common_param_traits.h" | 13 #include "content/public/common/common_param_traits.h" |
| 14 #include "content/public/common/socket_permission_request.h" | 14 #include "content/public/common/socket_permission_request.h" |
| 15 #include "extensions/common/api/messaging/message.h" | 15 #include "extensions/common/api/messaging/message.h" |
| 16 #include "extensions/common/draggable_region.h" | 16 #include "extensions/common/draggable_region.h" |
| 17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 18 #include "extensions/common/extensions_client.h" | 18 #include "extensions/common/extensions_client.h" |
| 19 #include "extensions/common/permissions/media_galleries_permission_data.h" | 19 #include "extensions/common/permissions/media_galleries_permission_data.h" |
| 20 #include "extensions/common/permissions/permission_set.h" | 20 #include "extensions/common/permissions/permission_set.h" |
| 21 #include "extensions/common/permissions/socket_permission_data.h" | 21 #include "extensions/common/permissions/socket_permission_data.h" |
| 22 #include "extensions/common/permissions/usb_device_permission_data.h" | 22 #include "extensions/common/permissions/usb_device_permission_data.h" |
| 23 #include "extensions/common/url_pattern.h" | 23 #include "extensions/common/url_pattern.h" |
| 24 #include "extensions/common/url_pattern_set.h" | 24 #include "extensions/common/url_pattern_set.h" |
| 25 #include "extensions/common/user_script.h" |
| 25 #include "extensions/common/view_type.h" | 26 #include "extensions/common/view_type.h" |
| 26 #include "ipc/ipc_message_macros.h" | 27 #include "ipc/ipc_message_macros.h" |
| 27 #include "ui/gfx/ipc/gfx_param_traits.h" | 28 #include "ui/gfx/ipc/gfx_param_traits.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 | 30 |
| 30 #define IPC_MESSAGE_START ExtensionMsgStart | 31 #define IPC_MESSAGE_START ExtensionMsgStart |
| 31 | 32 |
| 32 IPC_ENUM_TRAITS_MAX_VALUE(extensions::ViewType, extensions::VIEW_TYPE_LAST) | 33 IPC_ENUM_TRAITS_MAX_VALUE(extensions::ViewType, extensions::VIEW_TYPE_LAST) |
| 33 IPC_ENUM_TRAITS_MAX_VALUE(content::SocketPermissionRequest::OperationType, | 34 IPC_ENUM_TRAITS_MAX_VALUE(content::SocketPermissionRequest::OperationType, |
| 34 content::SocketPermissionRequest::OPERATION_TYPE_LAST) | 35 content::SocketPermissionRequest::OPERATION_TYPE_LAST) |
| 35 | 36 |
| 37 IPC_ENUM_TRAITS_MAX_VALUE(extensions::UserScript::InjectionType, |
| 38 extensions::UserScript::INJECTION_TYPE_LAST) |
| 39 |
| 36 // Parameters structure for ExtensionHostMsg_AddAPIActionToActivityLog and | 40 // Parameters structure for ExtensionHostMsg_AddAPIActionToActivityLog and |
| 37 // ExtensionHostMsg_AddEventToActivityLog. | 41 // ExtensionHostMsg_AddEventToActivityLog. |
| 38 IPC_STRUCT_BEGIN(ExtensionHostMsg_APIActionOrEvent_Params) | 42 IPC_STRUCT_BEGIN(ExtensionHostMsg_APIActionOrEvent_Params) |
| 39 // API name. | 43 // API name. |
| 40 IPC_STRUCT_MEMBER(std::string, api_call) | 44 IPC_STRUCT_MEMBER(std::string, api_call) |
| 41 | 45 |
| 42 // List of arguments. | 46 // List of arguments. |
| 43 IPC_STRUCT_MEMBER(base::ListValue, arguments) | 47 IPC_STRUCT_MEMBER(base::ListValue, arguments) |
| 44 | 48 |
| 45 // Extra logging information. | 49 // Extra logging information. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 IPC_STRUCT_MEMBER(std::string, target_id) | 153 IPC_STRUCT_MEMBER(std::string, target_id) |
| 150 | 154 |
| 151 // The ID of the extension that initiated the request. May be empty if it | 155 // The ID of the extension that initiated the request. May be empty if it |
| 152 // wasn't initiated by an extension. | 156 // wasn't initiated by an extension. |
| 153 IPC_STRUCT_MEMBER(std::string, source_id) | 157 IPC_STRUCT_MEMBER(std::string, source_id) |
| 154 | 158 |
| 155 // The URL of the frame that initiated the request. | 159 // The URL of the frame that initiated the request. |
| 156 IPC_STRUCT_MEMBER(GURL, source_url) | 160 IPC_STRUCT_MEMBER(GURL, source_url) |
| 157 IPC_STRUCT_END() | 161 IPC_STRUCT_END() |
| 158 | 162 |
| 159 // Parameters structure for ExtensionMsg_UpdatePermissions. | |
| 160 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params) | |
| 161 IPC_STRUCT_MEMBER(int /* UpdateExtensionPermissionsInfo::REASON */, reason_id) | |
| 162 IPC_STRUCT_MEMBER(std::string, extension_id) | |
| 163 IPC_STRUCT_MEMBER(extensions::APIPermissionSet, apis) | |
| 164 IPC_STRUCT_MEMBER(extensions::ManifestPermissionSet, manifest_permissions) | |
| 165 IPC_STRUCT_MEMBER(extensions::URLPatternSet, explicit_hosts) | |
| 166 IPC_STRUCT_MEMBER(extensions::URLPatternSet, scriptable_hosts) | |
| 167 IPC_STRUCT_END() | |
| 168 | |
| 169 IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion) | 163 IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion) |
| 170 IPC_STRUCT_TRAITS_MEMBER(draggable) | 164 IPC_STRUCT_TRAITS_MEMBER(draggable) |
| 171 IPC_STRUCT_TRAITS_MEMBER(bounds) | 165 IPC_STRUCT_TRAITS_MEMBER(bounds) |
| 172 IPC_STRUCT_TRAITS_END() | 166 IPC_STRUCT_TRAITS_END() |
| 173 | 167 |
| 174 IPC_STRUCT_TRAITS_BEGIN(content::SocketPermissionRequest) | 168 IPC_STRUCT_TRAITS_BEGIN(content::SocketPermissionRequest) |
| 175 IPC_STRUCT_TRAITS_MEMBER(type) | 169 IPC_STRUCT_TRAITS_MEMBER(type) |
| 176 IPC_STRUCT_TRAITS_MEMBER(host) | 170 IPC_STRUCT_TRAITS_MEMBER(host) |
| 177 IPC_STRUCT_TRAITS_MEMBER(port) | 171 IPC_STRUCT_TRAITS_MEMBER(port) |
| 178 IPC_STRUCT_TRAITS_END() | 172 IPC_STRUCT_TRAITS_END() |
| (...skipping 26 matching lines...) Expand all Loading... |
| 205 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ | 199 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ |
| 206 | 200 |
| 207 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need | 201 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need |
| 208 // to typedef it to avoid that. | 202 // to typedef it to avoid that. |
| 209 // Substitution map for l10n messages. | 203 // Substitution map for l10n messages. |
| 210 typedef std::map<std::string, std::string> SubstitutionMap; | 204 typedef std::map<std::string, std::string> SubstitutionMap; |
| 211 | 205 |
| 212 // Map of extensions IDs to the executing script paths. | 206 // Map of extensions IDs to the executing script paths. |
| 213 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; | 207 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; |
| 214 | 208 |
| 209 struct ExtensionMsg_PermissionSetStruct { |
| 210 ExtensionMsg_PermissionSetStruct(); |
| 211 explicit ExtensionMsg_PermissionSetStruct( |
| 212 const extensions::PermissionSet* permissions); |
| 213 ~ExtensionMsg_PermissionSetStruct(); |
| 214 |
| 215 scoped_refptr<const extensions::PermissionSet> ToPermissionSet() const; |
| 216 |
| 217 extensions::APIPermissionSet apis; |
| 218 extensions::ManifestPermissionSet manifest_permissions; |
| 219 extensions::URLPatternSet explicit_hosts; |
| 220 extensions::URLPatternSet scriptable_hosts; |
| 221 }; |
| 222 |
| 215 struct ExtensionMsg_Loaded_Params { | 223 struct ExtensionMsg_Loaded_Params { |
| 216 ExtensionMsg_Loaded_Params(); | 224 ExtensionMsg_Loaded_Params(); |
| 217 ~ExtensionMsg_Loaded_Params(); | 225 ~ExtensionMsg_Loaded_Params(); |
| 218 explicit ExtensionMsg_Loaded_Params(const extensions::Extension* extension); | 226 explicit ExtensionMsg_Loaded_Params(const extensions::Extension* extension); |
| 219 | 227 |
| 220 // Creates a new extension from the data in this object. | 228 // Creates a new extension from the data in this object. |
| 221 scoped_refptr<extensions::Extension> ConvertToExtension( | 229 scoped_refptr<extensions::Extension> ConvertToExtension( |
| 222 std::string* error) const; | 230 std::string* error) const; |
| 223 | 231 |
| 224 // The subset of the extension manifest data we send to renderers. | 232 // The subset of the extension manifest data we send to renderers. |
| 225 linked_ptr<base::DictionaryValue> manifest; | 233 linked_ptr<base::DictionaryValue> manifest; |
| 226 | 234 |
| 227 // The location the extension was installed from. | 235 // The location the extension was installed from. |
| 228 extensions::Manifest::Location location; | 236 extensions::Manifest::Location location; |
| 229 | 237 |
| 230 // The path the extension was loaded from. This is used in the renderer only | 238 // 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. | 239 // to generate the extension ID for extensions that are loaded unpacked. |
| 232 base::FilePath path; | 240 base::FilePath path; |
| 233 | 241 |
| 234 // The extension's active permissions. | 242 // The extension's active and withheld permissions. |
| 235 extensions::APIPermissionSet apis; | 243 ExtensionMsg_PermissionSetStruct active_permissions; |
| 236 extensions::ManifestPermissionSet manifest_permissions; | 244 ExtensionMsg_PermissionSetStruct withheld_permissions; |
| 237 extensions::URLPatternSet explicit_hosts; | |
| 238 extensions::URLPatternSet scriptable_hosts; | |
| 239 | 245 |
| 240 // We keep this separate so that it can be used in logging. | 246 // We keep this separate so that it can be used in logging. |
| 241 std::string id; | 247 std::string id; |
| 242 | 248 |
| 243 // Send creation flags so extension is initialized identically. | 249 // Send creation flags so extension is initialized identically. |
| 244 int creation_flags; | 250 int creation_flags; |
| 245 }; | 251 }; |
| 246 | 252 |
| 247 namespace IPC { | 253 namespace IPC { |
| 248 | 254 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 286 |
| 281 template <> | 287 template <> |
| 282 struct ParamTraits<extensions::ManifestPermissionSet> { | 288 struct ParamTraits<extensions::ManifestPermissionSet> { |
| 283 typedef extensions::ManifestPermissionSet param_type; | 289 typedef extensions::ManifestPermissionSet param_type; |
| 284 static void Write(Message* m, const param_type& p); | 290 static void Write(Message* m, const param_type& p); |
| 285 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | 291 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
| 286 static void Log(const param_type& p, std::string* l); | 292 static void Log(const param_type& p, std::string* l); |
| 287 }; | 293 }; |
| 288 | 294 |
| 289 template <> | 295 template <> |
| 296 struct ParamTraits<ExtensionMsg_PermissionSetStruct> { |
| 297 typedef ExtensionMsg_PermissionSetStruct param_type; |
| 298 static void Write(Message* m, const param_type& p); |
| 299 static bool Read(const Message* m, PickleIterator* iter, param_type* p); |
| 300 static void Log(const param_type& p, std::string* l); |
| 301 }; |
| 302 |
| 303 template <> |
| 290 struct ParamTraits<ExtensionMsg_Loaded_Params> { | 304 struct ParamTraits<ExtensionMsg_Loaded_Params> { |
| 291 typedef ExtensionMsg_Loaded_Params param_type; | 305 typedef ExtensionMsg_Loaded_Params param_type; |
| 292 static void Write(Message* m, const param_type& p); | 306 static void Write(Message* m, const param_type& p); |
| 293 static bool Read(const Message* m, PickleIterator* iter, param_type* p); | 307 static bool Read(const Message* m, PickleIterator* iter, param_type* p); |
| 294 static void Log(const param_type& p, std::string* l); | 308 static void Log(const param_type& p, std::string* l); |
| 295 }; | 309 }; |
| 296 | 310 |
| 297 } // namespace IPC | 311 } // namespace IPC |
| 298 | 312 |
| 299 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ | 313 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ |
| 300 | 314 |
| 315 // Parameters structure for ExtensionMsg_UpdatePermissions. |
| 316 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params) |
| 317 IPC_STRUCT_MEMBER(std::string, extension_id) |
| 318 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions) |
| 319 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions) |
| 320 IPC_STRUCT_END() |
| 321 |
| 301 // Messages sent from the browser to the renderer. | 322 // Messages sent from the browser to the renderer. |
| 302 | 323 |
| 303 // The browser sends this message in response to all extension api calls. The | 324 // The browser sends this message in response to all extension api calls. The |
| 304 // response data (if any) is one of the base::Value subclasses, wrapped as the | 325 // response data (if any) is one of the base::Value subclasses, wrapped as the |
| 305 // first element in a ListValue. | 326 // first element in a ListValue. |
| 306 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, | 327 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, |
| 307 int /* request_id */, | 328 int /* request_id */, |
| 308 bool /* success */, | 329 bool /* success */, |
| 309 base::ListValue /* response wrapper (see comment above) */, | 330 base::ListValue /* response wrapper (see comment above) */, |
| 310 std::string /* error */) | 331 std::string /* error */) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 // running in the renderer that the IPC originated from. | 596 // running in the renderer that the IPC originated from. |
| 576 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_ContentScriptsExecuting, | 597 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_ContentScriptsExecuting, |
| 577 ExecutingScriptsMap, | 598 ExecutingScriptsMap, |
| 578 GURL /* url of the _topmost_ frame */) | 599 GURL /* url of the _topmost_ frame */) |
| 579 | 600 |
| 580 // Sent from the renderer to the browser to request permission for a script | 601 // Sent from the renderer to the browser to request permission for a script |
| 581 // injection. | 602 // injection. |
| 582 // If request id is -1, this signals that the request has already ran, and this | 603 // If request id is -1, this signals that the request has already ran, and this |
| 583 // merely serves as a notification. This happens when the feature to disable | 604 // merely serves as a notification. This happens when the feature to disable |
| 584 // scripts running without user consent is not enabled. | 605 // scripts running without user consent is not enabled. |
| 585 IPC_MESSAGE_ROUTED2(ExtensionHostMsg_RequestScriptInjectionPermission, | 606 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_RequestScriptInjectionPermission, |
| 586 std::string /* extension id */, | 607 std::string /* extension id */, |
| 608 extensions::UserScript::InjectionType /* script type */, |
| 587 int64 /* request id */) | 609 int64 /* request id */) |
| 588 | 610 |
| 589 // Sent from the browser to the renderer in reply to a | 611 // Sent from the browser to the renderer in reply to a |
| 590 // RequestScriptInjectionPermission message, granting permission for a script | 612 // RequestScriptInjectionPermission message, granting permission for a script |
| 591 // script to run. | 613 // script to run. |
| 592 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection, | 614 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection, |
| 593 int64 /* request id */) | 615 int64 /* request id */) |
| 594 | 616 |
| 595 // Sent by the renderer when a web page is checking if its app is installed. | 617 // Sent by the renderer when a web page is checking if its app is installed. |
| 596 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState, | 618 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the | 677 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the |
| 656 // main frame. | 678 // main frame. |
| 657 // * Something changed on an existing frame causing the set of matching searches | 679 // * Something changed on an existing frame causing the set of matching searches |
| 658 // to change. | 680 // to change. |
| 659 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange, | 681 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange, |
| 660 std::vector<std::string> /* Matching CSS selectors */) | 682 std::vector<std::string> /* Matching CSS selectors */) |
| 661 | 683 |
| 662 // Sent by the renderer when it has received a Blob handle from the browser. | 684 // Sent by the renderer when it has received a Blob handle from the browser. |
| 663 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck, | 685 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck, |
| 664 std::vector<std::string> /* blob_uuids */) | 686 std::vector<std::string> /* blob_uuids */) |
| OLD | NEW |