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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: URLPatternSets use shared memory for IPC. Default scope patterns sent once per renderer. Created 3 years, 12 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
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 #include "extensions/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, 927 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist,
928 OnSetScriptingWhitelist) 928 OnSetScriptingWhitelist)
929 IPC_MESSAGE_HANDLER(ExtensionMsg_SetSystemFont, OnSetSystemFont) 929 IPC_MESSAGE_HANDLER(ExtensionMsg_SetSystemFont, OnSetSystemFont)
930 IPC_MESSAGE_HANDLER(ExtensionMsg_SetWebViewPartitionID, 930 IPC_MESSAGE_HANDLER(ExtensionMsg_SetWebViewPartitionID,
931 OnSetWebViewPartitionID) 931 OnSetWebViewPartitionID)
932 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldSuspend, OnShouldSuspend) 932 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldSuspend, OnShouldSuspend)
933 IPC_MESSAGE_HANDLER(ExtensionMsg_Suspend, OnSuspend) 933 IPC_MESSAGE_HANDLER(ExtensionMsg_Suspend, OnSuspend)
934 IPC_MESSAGE_HANDLER(ExtensionMsg_TransferBlobs, OnTransferBlobs) 934 IPC_MESSAGE_HANDLER(ExtensionMsg_TransferBlobs, OnTransferBlobs)
935 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded) 935 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded)
936 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) 936 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions)
937 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateAllowedAndBlockedHosts,
938 OnUpdateAllowedAndBlockedHosts)
939 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateDefaultAllowedAndBlockedHosts,
940 OnUpdateDefaultAllowedAndBlockedHosts)
937 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions, 941 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
938 OnUpdateTabSpecificPermissions) 942 OnUpdateTabSpecificPermissions)
939 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions, 943 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
940 OnClearTabSpecificPermissions) 944 OnClearTabSpecificPermissions)
941 IPC_MESSAGE_HANDLER(ExtensionMsg_SetActivityLoggingEnabled, 945 IPC_MESSAGE_HANDLER(ExtensionMsg_SetActivityLoggingEnabled,
942 OnSetActivityLoggingEnabled) 946 OnSetActivityLoggingEnabled)
943 IPC_MESSAGE_FORWARD(ExtensionMsg_WatchPages, 947 IPC_MESSAGE_FORWARD(ExtensionMsg_WatchPages,
944 content_watcher_.get(), 948 content_watcher_.get(),
945 ContentWatcher::OnWatchPages) 949 ContentWatcher::OnWatchPages)
946 IPC_MESSAGE_UNHANDLED(handled = false) 950 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 // figure out why - but cost/benefit won. 1077 // figure out why - but cost/benefit won.
1074 // 2. The browser only sends this IPC to RenderProcessHosts once, but the 1078 // 2. The browser only sends this IPC to RenderProcessHosts once, but the
1075 // Dispatcher is attached to a RenderThread. Presumably there is a 1079 // Dispatcher is attached to a RenderThread. Presumably there is a
1076 // mismatch there. In theory one would think it's possible for the 1080 // mismatch there. In theory one would think it's possible for the
1077 // browser to figure this out itself - but again, cost/benefit. 1081 // browser to figure this out itself - but again, cost/benefit.
1078 if (!extension_registry->Insert(extension)) { 1082 if (!extension_registry->Insert(extension)) {
1079 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and 1083 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1080 // consider making this a release CHECK. 1084 // consider making this a release CHECK.
1081 NOTREACHED(); 1085 NOTREACHED();
1082 } 1086 }
1087 URLPatternSet runtime_allowed_hosts;
1088 URLPatternSet runtime_blocked_hosts;
1089 if (!param.is_default_runtime_blocked_allowed_hosts) {
1090 if (!base::SharedMemory::IsHandleValid(param.hosts.hosts))
1091 return;
1092 param.hosts.Unpickle(&runtime_blocked_hosts, &runtime_allowed_hosts);
1093 }
1094 extension->permissions_data()->SetRuntimeBlockedAllowedHosts(
1095 runtime_blocked_hosts, runtime_allowed_hosts,
1096 param.is_default_runtime_blocked_allowed_hosts);
1083 } 1097 }
1084 1098
1085 // Update the available bindings for all contexts. These may have changed if 1099 // Update the available bindings for all contexts. These may have changed if
1086 // an externally_connectable extension was loaded that can connect to an 1100 // an externally_connectable extension was loaded that can connect to an
1087 // open webpage. 1101 // open webpage.
1088 UpdateBindings(""); 1102 UpdateBindings("");
1089 } 1103 }
1090 1104
1091 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 1105 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
1092 const std::string& module_name, 1106 const std::string& module_name,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1194
1181 // Invalidates the messages map for the extension in case the extension is 1195 // Invalidates the messages map for the extension in case the extension is
1182 // reloaded with a new messages map. 1196 // reloaded with a new messages map.
1183 EraseL10nMessagesMap(id); 1197 EraseL10nMessagesMap(id);
1184 1198
1185 // We don't do anything with existing platform-app stylesheets. They will 1199 // We don't do anything with existing platform-app stylesheets. They will
1186 // stay resident, but the URL pattern corresponding to the unloaded 1200 // stay resident, but the URL pattern corresponding to the unloaded
1187 // extension's URL just won't match anything anymore. 1201 // extension's URL just won't match anything anymore.
1188 } 1202 }
1189 1203
1204 void Dispatcher::OnUpdateAllowedAndBlockedHosts(
1205 const ExtensionMsg_UpdateAllowedAndBlockedHosts_Params& params) {
1206 const Extension* extension =
1207 RendererExtensionRegistry::Get()->GetByID(params.extension_id);
1208 if (!extension)
1209 return;
1210
1211 URLPatternSet runtime_allowed_hosts;
1212 URLPatternSet runtime_blocked_hosts;
1213 // We don't bother mapping memory if extension uses default
1214 if (!params.is_default) {
1215 if (!base::SharedMemory::IsHandleValid(params.hosts.hosts))
1216 return;
1217 params.hosts.Unpickle(&runtime_blocked_hosts, &runtime_allowed_hosts);
1218 }
1219
1220 extension->permissions_data()->SetRuntimeBlockedAllowedHosts(
Devlin 2017/01/09 23:30:57 Do we need to be able to support runtime extension
nrpeter 2017/01/10 17:48:05 We do need to support changes to the policy during
1221 runtime_blocked_hosts, runtime_allowed_hosts, params.is_default);
1222
1223 UpdateBindings(extension->id());
1224 }
1225
1226 void Dispatcher::OnUpdateDefaultAllowedAndBlockedHosts(
1227 const ExtensionMsg_RuntimeBlockedAllowedHostsStruct& params) {
1228 URLPatternSet default_runtime_allowed_hosts;
1229 URLPatternSet default_runtime_blocked_hosts;
1230 if (!base::SharedMemory::IsHandleValid(params.hosts))
1231 return;
1232 params.Unpickle(&default_runtime_blocked_hosts,
1233 &default_runtime_allowed_hosts);
1234 PermissionsData::SetDefaultRuntimeBlockedAllowedHosts(
1235 default_runtime_blocked_hosts, default_runtime_allowed_hosts);
1236
1237 UpdateBindings("");
1238 }
1239
1190 void Dispatcher::OnUpdatePermissions( 1240 void Dispatcher::OnUpdatePermissions(
1191 const ExtensionMsg_UpdatePermissions_Params& params) { 1241 const ExtensionMsg_UpdatePermissions_Params& params) {
1192 const Extension* extension = 1242 const Extension* extension =
1193 RendererExtensionRegistry::Get()->GetByID(params.extension_id); 1243 RendererExtensionRegistry::Get()->GetByID(params.extension_id);
1194 if (!extension) 1244 if (!extension)
1195 return; 1245 return;
1196 1246
1197 std::unique_ptr<const PermissionSet> active = 1247 std::unique_ptr<const PermissionSet> active =
1198 params.active_permissions.ToPermissionSet(); 1248 params.active_permissions.ToPermissionSet();
1199 std::unique_ptr<const PermissionSet> withheld = 1249 std::unique_ptr<const PermissionSet> withheld =
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 // The "guestViewDeny" module must always be loaded last. It registers 1700 // The "guestViewDeny" module must always be loaded last. It registers
1651 // error-providing custom elements for the GuestView types that are not 1701 // error-providing custom elements for the GuestView types that are not
1652 // available, and thus all of those types must have been checked and loaded 1702 // available, and thus all of those types must have been checked and loaded
1653 // (or not loaded) beforehand. 1703 // (or not loaded) beforehand.
1654 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1704 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1655 module_system->Require("guestViewDeny"); 1705 module_system->Require("guestViewDeny");
1656 } 1706 }
1657 } 1707 }
1658 1708
1659 } // namespace extensions 1709 } // namespace extensions
OLDNEW
« extensions/common/permissions/permissions_data.cc ('K') | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698