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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: extensions/common/extension_messages.h
diff --git a/extensions/common/extension_messages.h b/extensions/common/extension_messages.h
index e2a9c9172b0807f617548139fcf39486540a8ebb..6860ce33b02aec529549f1b0828de77363af9132 100644
--- a/extensions/common/extension_messages.h
+++ b/extensions/common/extension_messages.h
@@ -258,6 +258,27 @@ typedef std::map<std::string, std::string> SubstitutionMap;
// Map of extensions IDs to the executing script paths.
typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap;
+// Define hosts extension may or may not interact with. This is used as part of
+// the ExtensionSetitngs policy. Since there is no limit to the amount of
+// URLPatterns in a URLPatternSet we're using shared memory. This object
+// includes functions to pickle/unpickle and allocate shared memory as this is
+// used from various parts in the code.
+struct ExtensionMsg_RuntimeBlockedAllowedHostsStruct {
+ ExtensionMsg_RuntimeBlockedAllowedHostsStruct();
+ explicit ExtensionMsg_RuntimeBlockedAllowedHostsStruct(
+ const extensions::URLPatternSet& runtime_blocked_hosts,
+ const extensions::URLPatternSet& runtime_allowed_hosts,
+ const base::ProcessHandle host);
+ ExtensionMsg_RuntimeBlockedAllowedHostsStruct(
+ const ExtensionMsg_RuntimeBlockedAllowedHostsStruct& other);
+ ~ExtensionMsg_RuntimeBlockedAllowedHostsStruct();
+
+ void Unpickle(extensions::URLPatternSet* runtime_blocked_hosts,
+ extensions::URLPatternSet* runtime_allowed_hosts) const;
+
+ base::SharedMemoryHandle hosts;
+};
+
struct ExtensionMsg_PermissionSetStruct {
ExtensionMsg_PermissionSetStruct();
explicit ExtensionMsg_PermissionSetStruct(
@@ -278,7 +299,8 @@ struct ExtensionMsg_Loaded_Params {
ExtensionMsg_Loaded_Params();
~ExtensionMsg_Loaded_Params();
ExtensionMsg_Loaded_Params(const extensions::Extension* extension,
- bool include_tab_permissions);
+ bool include_tab_permissions,
+ const base::ProcessHandle handle);
ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other);
// Creates a new extension from the data in this object.
@@ -300,6 +322,15 @@ struct ExtensionMsg_Loaded_Params {
ExtensionMsg_PermissionSetStruct withheld_permissions;
std::map<int, ExtensionMsg_PermissionSetStruct> tab_specific_permissions;
+ // Contians URLPatternSets defining which URLs an extension may not interact
+ // with by policy. This is mapped to shared memory to deal with large lists.
+ ExtensionMsg_RuntimeBlockedAllowedHostsStruct hosts;
+
+ // If the extension uses the default list of blocked / allowed URLs. If false,
+ // then the 'hosts' struct in this struct must be populated with a valid
+ // shared memory handle.
+ bool is_default_runtime_blocked_allowed_hosts;
+
// We keep this separate so that it can be used in logging.
std::string id;
@@ -384,6 +415,17 @@ struct ParamTraits<HostID> {
};
template <>
+struct ParamTraits<ExtensionMsg_RuntimeBlockedAllowedHostsStruct> {
+ typedef ExtensionMsg_RuntimeBlockedAllowedHostsStruct param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template <>
struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
typedef ExtensionMsg_PermissionSetStruct param_type;
static void GetSize(base::PickleSizer* s, const param_type& p);
@@ -423,6 +465,19 @@ IPC_STRUCT_BEGIN(ExtensionMsg_UpdatePermissions_Params)
IPC_STRUCT_MEMBER(ExtensionMsg_PermissionSetStruct, withheld_permissions)
IPC_STRUCT_END()
+// Parameters structure for ExtensionMsg_UpdateAllowedAndBlockedHosts.
+IPC_STRUCT_BEGIN(ExtensionMsg_UpdateAllowedAndBlockedHosts_Params)
+ IPC_STRUCT_MEMBER(std::string, extension_id)
+ IPC_STRUCT_MEMBER(ExtensionMsg_RuntimeBlockedAllowedHostsStruct, hosts)
+ IPC_STRUCT_MEMBER(bool, is_default)
+IPC_STRUCT_END()
+
+// Parameters structure for ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts.
+IPC_STRUCT_BEGIN(ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts_Params)
+ IPC_STRUCT_MEMBER(base::SharedMemoryHandle, default_runtime_blocked_hosts)
+ IPC_STRUCT_MEMBER(base::SharedMemoryHandle, default_runtime_allowed_hosts)
+IPC_STRUCT_END()
+
// Messages sent from the browser to the renderer:
// The browser sends this message in response to all extension api calls. The
@@ -521,6 +576,14 @@ IPC_MESSAGE_ROUTED1(ExtensionMsg_SetTabId,
IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdatePermissions,
ExtensionMsg_UpdatePermissions_Params)
+// Tell the renderer to update an extension's runtime_blocked_hosts set.
+IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdateAllowedAndBlockedHosts,
+ ExtensionMsg_UpdateAllowedAndBlockedHosts_Params)
+
+// Tell the renderer to update an extension's runtime_blocked_hosts set.
+IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts,
+ ExtensionMsg_RuntimeBlockedAllowedHostsStruct)
+
// Tell the render view about new tab-specific permissions for an extension.
IPC_MESSAGE_CONTROL5(ExtensionMsg_UpdateTabSpecificPermissions,
GURL /* url */,

Powered by Google App Engine
This is Rietveld 408576698