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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: URLPatternSets use shared memory for IPC. Default scope patterns sent once per renderer. Created 4 years 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
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_ 251 #define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
252 252
253 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need 253 // IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need
254 // to typedef it to avoid that. 254 // to typedef it to avoid that.
255 // Substitution map for l10n messages. 255 // Substitution map for l10n messages.
256 typedef std::map<std::string, std::string> SubstitutionMap; 256 typedef std::map<std::string, std::string> SubstitutionMap;
257 257
258 // Map of extensions IDs to the executing script paths. 258 // Map of extensions IDs to the executing script paths.
259 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; 259 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap;
260 260
261 // Define hosts extension may or may not interact with. This is used as part of
262 // the ExtensionSetitngs policy. Since there is no limit to the amount of
263 // URLPatterns in a URLPatternSet we're using shared memory. This object
264 // includes functions to pickle/unpickle and allocate shared memory as this is
265 // used from various parts in the code.
266 struct ExtensionMsg_RuntimeBlockedAllowedHostsStruct {
267 ExtensionMsg_RuntimeBlockedAllowedHostsStruct();
268 explicit ExtensionMsg_RuntimeBlockedAllowedHostsStruct(
269 const extensions::URLPatternSet& runtime_blocked_hosts,
270 const extensions::URLPatternSet& runtime_allowed_hosts,
271 const base::ProcessHandle host);
272 ExtensionMsg_RuntimeBlockedAllowedHostsStruct(
273 const ExtensionMsg_RuntimeBlockedAllowedHostsStruct& other);
274 ~ExtensionMsg_RuntimeBlockedAllowedHostsStruct();
275
276 void Unpickle(extensions::URLPatternSet* runtime_blocked_hosts,
277 extensions::URLPatternSet* runtime_allowed_hosts) const;
278
279 base::SharedMemoryHandle hosts;
280 };
281
261 struct ExtensionMsg_PermissionSetStruct { 282 struct ExtensionMsg_PermissionSetStruct {
262 ExtensionMsg_PermissionSetStruct(); 283 ExtensionMsg_PermissionSetStruct();
263 explicit ExtensionMsg_PermissionSetStruct( 284 explicit ExtensionMsg_PermissionSetStruct(
264 const extensions::PermissionSet& permissions); 285 const extensions::PermissionSet& permissions);
265 ExtensionMsg_PermissionSetStruct( 286 ExtensionMsg_PermissionSetStruct(
266 const ExtensionMsg_PermissionSetStruct& other); 287 const ExtensionMsg_PermissionSetStruct& other);
267 ~ExtensionMsg_PermissionSetStruct(); 288 ~ExtensionMsg_PermissionSetStruct();
268 289
269 std::unique_ptr<const extensions::PermissionSet> ToPermissionSet() const; 290 std::unique_ptr<const extensions::PermissionSet> ToPermissionSet() const;
270 291
271 extensions::APIPermissionSet apis; 292 extensions::APIPermissionSet apis;
272 extensions::ManifestPermissionSet manifest_permissions; 293 extensions::ManifestPermissionSet manifest_permissions;
273 extensions::URLPatternSet explicit_hosts; 294 extensions::URLPatternSet explicit_hosts;
274 extensions::URLPatternSet scriptable_hosts; 295 extensions::URLPatternSet scriptable_hosts;
275 }; 296 };
276 297
277 struct ExtensionMsg_Loaded_Params { 298 struct ExtensionMsg_Loaded_Params {
278 ExtensionMsg_Loaded_Params(); 299 ExtensionMsg_Loaded_Params();
279 ~ExtensionMsg_Loaded_Params(); 300 ~ExtensionMsg_Loaded_Params();
280 ExtensionMsg_Loaded_Params(const extensions::Extension* extension, 301 ExtensionMsg_Loaded_Params(const extensions::Extension* extension,
281 bool include_tab_permissions); 302 bool include_tab_permissions,
303 const base::ProcessHandle handle);
282 ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other); 304 ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other);
283 305
284 // Creates a new extension from the data in this object. 306 // Creates a new extension from the data in this object.
285 scoped_refptr<extensions::Extension> ConvertToExtension( 307 scoped_refptr<extensions::Extension> ConvertToExtension(
286 std::string* error) const; 308 std::string* error) const;
287 309
288 // The subset of the extension manifest data we send to renderers. 310 // The subset of the extension manifest data we send to renderers.
289 linked_ptr<base::DictionaryValue> manifest; 311 linked_ptr<base::DictionaryValue> manifest;
290 312
291 // The location the extension was installed from. 313 // The location the extension was installed from.
292 extensions::Manifest::Location location; 314 extensions::Manifest::Location location;
293 315
294 // The path the extension was loaded from. This is used in the renderer only 316 // The path the extension was loaded from. This is used in the renderer only
295 // to generate the extension ID for extensions that are loaded unpacked. 317 // to generate the extension ID for extensions that are loaded unpacked.
296 base::FilePath path; 318 base::FilePath path;
297 319
298 // The extension's active and withheld permissions. 320 // The extension's active and withheld permissions.
299 ExtensionMsg_PermissionSetStruct active_permissions; 321 ExtensionMsg_PermissionSetStruct active_permissions;
300 ExtensionMsg_PermissionSetStruct withheld_permissions; 322 ExtensionMsg_PermissionSetStruct withheld_permissions;
301 std::map<int, ExtensionMsg_PermissionSetStruct> tab_specific_permissions; 323 std::map<int, ExtensionMsg_PermissionSetStruct> tab_specific_permissions;
302 324
325 // Contians URLPatternSets defining which URLs an extension may not interact
326 // with by policy. This is mapped to shared memory to deal with large lists.
327 ExtensionMsg_RuntimeBlockedAllowedHostsStruct hosts;
328
329 // If the extension uses the default list of blocked / allowed URLs. If false,
330 // then the 'hosts' struct in this struct must be populated with a valid
331 // shared memory handle.
332 bool is_default_runtime_blocked_allowed_hosts;
333
303 // We keep this separate so that it can be used in logging. 334 // We keep this separate so that it can be used in logging.
304 std::string id; 335 std::string id;
305 336
306 // Send creation flags so extension is initialized identically. 337 // Send creation flags so extension is initialized identically.
307 int creation_flags; 338 int creation_flags;
308 }; 339 };
309 340
310 struct ExtensionHostMsg_AutomationQuerySelector_Error { 341 struct ExtensionHostMsg_AutomationQuerySelector_Error {
311 enum Value { kNone, kNoMainFrame, kNoDocument, kNodeDestroyed }; 342 enum Value { kNone, kNoMainFrame, kNoDocument, kNodeDestroyed };
312 343
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 typedef HostID param_type; 408 typedef HostID param_type;
378 static void GetSize(base::PickleSizer* s, const param_type& p); 409 static void GetSize(base::PickleSizer* s, const param_type& p);
379 static void Write(base::Pickle* m, const param_type& p); 410 static void Write(base::Pickle* m, const param_type& p);
380 static bool Read(const base::Pickle* m, 411 static bool Read(const base::Pickle* m,
381 base::PickleIterator* iter, 412 base::PickleIterator* iter,
382 param_type* r); 413 param_type* r);
383 static void Log(const param_type& p, std::string* l); 414 static void Log(const param_type& p, std::string* l);
384 }; 415 };
385 416
386 template <> 417 template <>
418 struct ParamTraits<ExtensionMsg_RuntimeBlockedAllowedHostsStruct> {
419 typedef ExtensionMsg_RuntimeBlockedAllowedHostsStruct param_type;
420 static void GetSize(base::PickleSizer* s, const param_type& p);
421 static void Write(base::Pickle* m, const param_type& p);
422 static bool Read(const base::Pickle* m,
423 base::PickleIterator* iter,
424 param_type* p);
425 static void Log(const param_type& p, std::string* l);
426 };
427
428 template <>
387 struct ParamTraits<ExtensionMsg_PermissionSetStruct> { 429 struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
388 typedef ExtensionMsg_PermissionSetStruct param_type; 430 typedef ExtensionMsg_PermissionSetStruct param_type;
389 static void GetSize(base::PickleSizer* s, const param_type& p); 431 static void GetSize(base::PickleSizer* s, const param_type& p);
390 static void Write(base::Pickle* m, const param_type& p); 432 static void Write(base::Pickle* m, const param_type& p);
391 static bool Read(const base::Pickle* m, 433 static bool Read(const base::Pickle* m,
392 base::PickleIterator* iter, 434 base::PickleIterator* iter,
393 param_type* p); 435 param_type* p);
394 static void Log(const param_type& p, std::string* l); 436 static void Log(const param_type& p, std::string* l);
395 }; 437 };
396 438
(...skipping 19 matching lines...) Expand all
416 IPC_STRUCT_TRAITS_MEMBER(value) 458 IPC_STRUCT_TRAITS_MEMBER(value)
417 IPC_STRUCT_TRAITS_END() 459 IPC_STRUCT_TRAITS_END()
418 460
419 // Parameters structure for ExtensionMsg_UpdatePermissions. 461 // Parameters structure for ExtensionMsg_UpdatePermissions.
420 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params) 462 IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params)
421 IPC_STRUCT_MEMBER(std::string, extension_id) 463 IPC_STRUCT_MEMBER(std::string, extension_id)
422 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions) 464 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, active_permissions)
423 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions) 465 IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions)
424 IPC_STRUCT_END() 466 IPC_STRUCT_END()
425 467
468 // Parameters structure for ExtensionMsg_UpdateAllowedAndBlockedHosts.
469 IPC_STRUCT_BEGIN(ExtensionMsg_UpdateAllowedAndBlockedHosts_Params)
470 IPC_STRUCT_MEMBER(std::string, extension_id)
471 IPC_STRUCT_MEMBER(ExtensionMsg_RuntimeBlockedAllowedHostsStruct, hosts)
472 IPC_STRUCT_MEMBER(bool, is_default)
473 IPC_STRUCT_END()
474
475 // Parameters structure for ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts.
476 IPC_STRUCT_BEGIN(ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts_Params)
477 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, default_runtime_blocked_hosts)
478 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, default_runtime_allowed_hosts)
479 IPC_STRUCT_END()
480
426 // Messages sent from the browser to the renderer: 481 // Messages sent from the browser to the renderer:
427 482
428 // The browser sends this message in response to all extension api calls. The 483 // The browser sends this message in response to all extension api calls. The
429 // response data (if any) is one of the base::Value subclasses, wrapped as the 484 // response data (if any) is one of the base::Value subclasses, wrapped as the
430 // first element in a ListValue. 485 // first element in a ListValue.
431 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, 486 IPC_MESSAGE_ROUTED4(ExtensionMsg_Response,
432 int /* request_id */, 487 int /* request_id */,
433 bool /* success */, 488 bool /* success */,
434 base::ListValue /* response wrapper (see comment above) */, 489 base::ListValue /* response wrapper (see comment above) */,
435 std::string /* error */) 490 std::string /* error */)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 int /* id of browser window */) 569 int /* id of browser window */)
515 570
516 // Tell the render view what its tab ID is. 571 // Tell the render view what its tab ID is.
517 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetTabId, 572 IPC_MESSAGE_ROUTED1(ExtensionMsg_SetTabId,
518 int /* id of tab */) 573 int /* id of tab */)
519 574
520 // Tell the renderer to update an extension's permission set. 575 // Tell the renderer to update an extension's permission set.
521 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdatePermissions, 576 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdatePermissions,
522 ExtensionMsg_UpdatePermissions_Params) 577 ExtensionMsg_UpdatePermissions_Params)
523 578
579 // Tell the renderer to update an extension's runtime_blocked_hosts set.
580 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdateAllowedAndBlockedHosts,
581 ExtensionMsg_UpdateAllowedAndBlockedHosts_Params)
582
583 // Tell the renderer to update an extension's runtime_blocked_hosts set.
584 IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts,
585 ExtensionMsg_RuntimeBlockedAllowedHostsStruct)
586
524 // Tell the render view about new tab-specific permissions for an extension. 587 // Tell the render view about new tab-specific permissions for an extension.
525 IPC_MESSAGE_CONTROL5(ExtensionMsg_UpdateTabSpecificPermissions, 588 IPC_MESSAGE_CONTROL5(ExtensionMsg_UpdateTabSpecificPermissions,
526 GURL /* url */, 589 GURL /* url */,
527 std::string /* extension_id */, 590 std::string /* extension_id */,
528 extensions::URLPatternSet /* hosts */, 591 extensions::URLPatternSet /* hosts */,
529 bool /* update origin whitelist */, 592 bool /* update origin whitelist */,
530 int /* tab_id */) 593 int /* tab_id */)
531 594
532 // Tell the render view to clear tab-specific permissions for some extensions. 595 // Tell the render view to clear tab-specific permissions for some extensions.
533 IPC_MESSAGE_CONTROL3(ExtensionMsg_ClearTabSpecificPermissions, 596 IPC_MESSAGE_CONTROL3(ExtensionMsg_ClearTabSpecificPermissions,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 int64_t /* service_worker_version_id */, 957 int64_t /* service_worker_version_id */,
895 std::string /* request_uuid */) 958 std::string /* request_uuid */)
896 959
897 // Asks the browser to decrement the pending activity count for 960 // Asks the browser to decrement the pending activity count for
898 // the worker with version id |service_worker_version_id|. 961 // the worker with version id |service_worker_version_id|.
899 // |request_uuid| must match the GUID of a previous request, otherwise the 962 // |request_uuid| must match the GUID of a previous request, otherwise the
900 // browser process ignores the IPC. 963 // browser process ignores the IPC.
901 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_DecrementServiceWorkerActivity, 964 IPC_MESSAGE_CONTROL2(ExtensionHostMsg_DecrementServiceWorkerActivity,
902 int64_t /* service_worker_version_id */, 965 int64_t /* service_worker_version_id */,
903 std::string /* request_uuid */) 966 std::string /* request_uuid */)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698