Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: extensions/common/extension_messages.h

Issue 348313003: Create withheld permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/constants.h"
16 #include "extensions/common/draggable_region.h" 17 #include "extensions/common/draggable_region.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
18 #include "extensions/common/extensions_client.h" 19 #include "extensions/common/extensions_client.h"
19 #include "extensions/common/permissions/media_galleries_permission_data.h" 20 #include "extensions/common/permissions/media_galleries_permission_data.h"
20 #include "extensions/common/permissions/permission_set.h" 21 #include "extensions/common/permissions/permission_set.h"
21 #include "extensions/common/permissions/socket_permission_data.h" 22 #include "extensions/common/permissions/socket_permission_data.h"
22 #include "extensions/common/permissions/usb_device_permission_data.h" 23 #include "extensions/common/permissions/usb_device_permission_data.h"
23 #include "extensions/common/url_pattern.h" 24 #include "extensions/common/url_pattern.h"
24 #include "extensions/common/url_pattern_set.h" 25 #include "extensions/common/url_pattern_set.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(extension_misc::InjectedScriptType,
38 extension_misc::PROGRAMMATIC_SCRIPT)
not at google - send to devlin 2014/06/27 23:24:34 define a constant like INJECTED_SCRIPT_LAST as PRO
Devlin 2014/06/30 17:06:10 Done.
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
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
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 {
not at google - send to devlin 2014/06/27 23:24:33 can you instead implement IPC serialization for Pe
Devlin 2014/06/30 17:06:10 Yeah, it is. But we can't do it on PermissionSet
not at google - send to devlin 2014/07/01 00:28:35 ok... why does that mean you can't implement IPCs
not at google - send to devlin 2014/07/01 02:56:50 my comment might have been nonsensical; what does
Devlin 2014/07/01 16:27:05 Sorry, I should have said that PermissionSets are
not at google - send to devlin 2014/07/01 17:02:11 I still don't really follow why this implies you n
Devlin 2014/07/01 18:34:08 Resolved offline; we'll keep the IPC struct until
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
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<extensions::PermissionSet> {
297 typedef extensions::PermissionSet param_type;
298 static void Write(Message* m, const param_type& p);
299 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
300 static void Log(const param_type& p, std::string* l);
301 };
302
303 template <>
304 struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
305 typedef ExtensionMsg_PermissionSetStruct param_type;
306 static void Write(Message* m, const param_type& p);
307 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
308 static void Log(const param_type& p, std::string* l);
309 };
310
311 template <>
290 struct ParamTraits<ExtensionMsg_Loaded_Params> { 312 struct ParamTraits<ExtensionMsg_Loaded_Params> {
291 typedef ExtensionMsg_Loaded_Params param_type; 313 typedef ExtensionMsg_Loaded_Params param_type;
292 static void Write(Message* m, const param_type& p); 314 static void Write(Message* m, const param_type& p);
293 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 315 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
294 static void Log(const param_type& p, std::string* l); 316 static void Log(const param_type& p, std::string* l);
295 }; 317 };
296 318
297 } // namespace IPC 319 } // namespace IPC
298 320
299 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ 321 #endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
300 322
323 // Parameters structure for ExtensionMsg_UpdatePermissions.
324 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params)
325 IPC_STRUCT_MEMBER(std::string, extension_id)
326 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions)
327 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions)
328 IPC_STRUCT_END()
329
301 // Messages sent from the browser to the renderer. 330 // Messages sent from the browser to the renderer.
302 331
303 // The browser sends this message in response to all extension api calls. The 332 // 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 333 // response data (if any) is one of the base::Value subclasses, wrapped as the
305 // first element in a ListValue. 334 // first element in a ListValue.
306 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, 335 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response,
307 int /* request_id */, 336 int /* request_id */,
308 bool /* success */, 337 bool /* success */,
309 base::ListValue /* response wrapper (see comment above) */, 338 base::ListValue /* response wrapper (see comment above) */,
310 std::string /* error */) 339 std::string /* error */)
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_ContentScriptsExecuting, 609 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_ContentScriptsExecuting,
581 ExecutingScriptsMap, 610 ExecutingScriptsMap,
582 int32 /* page_id of the _topmost_ frame */, 611 int32 /* page_id of the _topmost_ frame */,
583 GURL /* url of the _topmost_ frame */) 612 GURL /* url of the _topmost_ frame */)
584 613
585 // Sent from the renderer to the browser to request permission for a script 614 // Sent from the renderer to the browser to request permission for a script
586 // injection. 615 // injection.
587 // If request id is -1, this signals that the request has already ran, and this 616 // If request id is -1, this signals that the request has already ran, and this
588 // merely serves as a notification. This happens when the feature to disable 617 // merely serves as a notification. This happens when the feature to disable
589 // scripts running without user consent is not enabled. 618 // scripts running without user consent is not enabled.
590 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_RequestScriptInjectionPermission, 619 IPC_MESSAGE_ROUTED4(ExtensionHostMsg_RequestScriptInjectionPermission,
591 std::string /* extension id */, 620 std::string /* extension id */,
621 extension_misc::InjectedScriptType /* script type */,
592 int /* page id */, 622 int /* page id */,
593 int /* request id */) 623 int /* request id */)
594 624
595 // Sent from the browser to the renderer in reply to a 625 // Sent from the browser to the renderer in reply to a
596 // RequestScriptInjectionPermission message, granting permission for a script 626 // RequestScriptInjectionPermission message, granting permission for a script
597 // script to run. 627 // script to run.
598 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection, int /* request id */) 628 IPC_MESSAGE_ROUTED1(ExtensionMsg_PermitScriptInjection, int /* request id */)
599 629
600 // Sent by the renderer when a web page is checking if its app is installed. 630 // Sent by the renderer when a web page is checking if its app is installed.
601 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState, 631 IPC_MESSAGE_ROUTED3(ExtensionHostMsg_GetAppInstallState,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the 690 // FrameHostMsg_DidCommitProvisionalLoad. Currently this only fires for the
661 // main frame. 691 // main frame.
662 // * Something changed on an existing frame causing the set of matching searches 692 // * Something changed on an existing frame causing the set of matching searches
663 // to change. 693 // to change.
664 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange, 694 IPC_MESSAGE_ROUTED1(ExtensionHostMsg_OnWatchedPageChange,
665 std::vector<std::string> /* Matching CSS selectors */) 695 std::vector<std::string> /* Matching CSS selectors */)
666 696
667 // Sent by the renderer when it has received a Blob handle from the browser. 697 // Sent by the renderer when it has received a Blob handle from the browser.
668 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck, 698 IPC_MESSAGE_CONTROL1(ExtensionHostMsg_TransferBlobsAck,
669 std::vector<std::string> /* blob_uuids */) 699 std::vector<std::string> /* blob_uuids */)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698