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

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

Issue 2820333003: Revert of Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, 915 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist,
916 OnSetScriptingWhitelist) 916 OnSetScriptingWhitelist)
917 IPC_MESSAGE_HANDLER(ExtensionMsg_SetSystemFont, OnSetSystemFont) 917 IPC_MESSAGE_HANDLER(ExtensionMsg_SetSystemFont, OnSetSystemFont)
918 IPC_MESSAGE_HANDLER(ExtensionMsg_SetWebViewPartitionID, 918 IPC_MESSAGE_HANDLER(ExtensionMsg_SetWebViewPartitionID,
919 OnSetWebViewPartitionID) 919 OnSetWebViewPartitionID)
920 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldSuspend, OnShouldSuspend) 920 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldSuspend, OnShouldSuspend)
921 IPC_MESSAGE_HANDLER(ExtensionMsg_Suspend, OnSuspend) 921 IPC_MESSAGE_HANDLER(ExtensionMsg_Suspend, OnSuspend)
922 IPC_MESSAGE_HANDLER(ExtensionMsg_TransferBlobs, OnTransferBlobs) 922 IPC_MESSAGE_HANDLER(ExtensionMsg_TransferBlobs, OnTransferBlobs)
923 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded) 923 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded)
924 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) 924 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions)
925 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateDefaultPolicyHostRestrictions,
926 OnUpdateDefaultPolicyHostRestrictions)
927 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions, 925 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
928 OnUpdateTabSpecificPermissions) 926 OnUpdateTabSpecificPermissions)
929 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions, 927 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
930 OnClearTabSpecificPermissions) 928 OnClearTabSpecificPermissions)
931 IPC_MESSAGE_HANDLER(ExtensionMsg_SetActivityLoggingEnabled, 929 IPC_MESSAGE_HANDLER(ExtensionMsg_SetActivityLoggingEnabled,
932 OnSetActivityLoggingEnabled) 930 OnSetActivityLoggingEnabled)
933 IPC_MESSAGE_FORWARD(ExtensionMsg_WatchPages, 931 IPC_MESSAGE_FORWARD(ExtensionMsg_WatchPages,
934 content_watcher_.get(), 932 content_watcher_.get(),
935 ContentWatcher::OnWatchPages) 933 ContentWatcher::OnWatchPages)
936 IPC_MESSAGE_UNHANDLED(handled = false) 934 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 for (const auto& param : loaded_extensions) { 1038 for (const auto& param : loaded_extensions) {
1041 std::string error; 1039 std::string error;
1042 scoped_refptr<const Extension> extension = param.ConvertToExtension(&error); 1040 scoped_refptr<const Extension> extension = param.ConvertToExtension(&error);
1043 if (!extension.get()) { 1041 if (!extension.get()) {
1044 NOTREACHED() << error; 1042 NOTREACHED() << error;
1045 // Note: in tests |param.id| has been observed to be empty (see comment 1043 // Note: in tests |param.id| has been observed to be empty (see comment
1046 // just below) so this isn't all that reliable. 1044 // just below) so this isn't all that reliable.
1047 extension_load_errors_[param.id] = error; 1045 extension_load_errors_[param.id] = error;
1048 continue; 1046 continue;
1049 } 1047 }
1048
1050 RendererExtensionRegistry* extension_registry = 1049 RendererExtensionRegistry* extension_registry =
1051 RendererExtensionRegistry::Get(); 1050 RendererExtensionRegistry::Get();
1052 // TODO(kalman): This test is deliberately not a CHECK (though I wish it 1051 // TODO(kalman): This test is deliberately not a CHECK (though I wish it
1053 // could be) and uses extension->id() not params.id: 1052 // could be) and uses extension->id() not params.id:
1054 // 1. For some reason params.id can be empty. I've only seen it with 1053 // 1. For some reason params.id can be empty. I've only seen it with
1055 // the webstore extension, in tests, and I've spent some time trying to 1054 // the webstore extension, in tests, and I've spent some time trying to
1056 // figure out why - but cost/benefit won. 1055 // figure out why - but cost/benefit won.
1057 // 2. The browser only sends this IPC to RenderProcessHosts once, but the 1056 // 2. The browser only sends this IPC to RenderProcessHosts once, but the
1058 // Dispatcher is attached to a RenderThread. Presumably there is a 1057 // Dispatcher is attached to a RenderThread. Presumably there is a
1059 // mismatch there. In theory one would think it's possible for the 1058 // mismatch there. In theory one would think it's possible for the
1060 // browser to figure this out itself - but again, cost/benefit. 1059 // browser to figure this out itself - but again, cost/benefit.
1061 if (!extension_registry->Insert(extension)) { 1060 if (!extension_registry->Insert(extension)) {
1062 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and 1061 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1063 // consider making this a release CHECK. 1062 // consider making this a release CHECK.
1064 NOTREACHED(); 1063 NOTREACHED();
1065 } 1064 }
1066 if (param.uses_default_policy_blocked_allowed_hosts) {
1067 extension->permissions_data()->SetUsesDefaultHostRestrictions();
1068 } else {
1069 extension->permissions_data()->SetPolicyHostRestrictions(
1070 param.policy_blocked_hosts, param.policy_allowed_hosts);
1071 }
1072 } 1065 }
1073 1066
1074 // Update the available bindings for all contexts. These may have changed if 1067 // Update the available bindings for all contexts. These may have changed if
1075 // an externally_connectable extension was loaded that can connect to an 1068 // an externally_connectable extension was loaded that can connect to an
1076 // open webpage. 1069 // open webpage.
1077 UpdateBindings(std::string()); 1070 UpdateBindings("");
1078 } 1071 }
1079 1072
1080 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 1073 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
1081 const std::string& module_name, 1074 const std::string& module_name,
1082 const std::string& function_name, 1075 const std::string& function_name,
1083 const base::ListValue& args) { 1076 const base::ListValue& args) {
1084 InvokeModuleSystemMethod(nullptr, extension_id, module_name, function_name, 1077 InvokeModuleSystemMethod(nullptr, extension_id, module_name, function_name,
1085 args); 1078 args);
1086 } 1079 }
1087 1080
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1187
1195 // Invalidates the messages map for the extension in case the extension is 1188 // Invalidates the messages map for the extension in case the extension is
1196 // reloaded with a new messages map. 1189 // reloaded with a new messages map.
1197 EraseL10nMessagesMap(id); 1190 EraseL10nMessagesMap(id);
1198 1191
1199 // We don't do anything with existing platform-app stylesheets. They will 1192 // We don't do anything with existing platform-app stylesheets. They will
1200 // stay resident, but the URL pattern corresponding to the unloaded 1193 // stay resident, but the URL pattern corresponding to the unloaded
1201 // extension's URL just won't match anything anymore. 1194 // extension's URL just won't match anything anymore.
1202 } 1195 }
1203 1196
1204 void Dispatcher::OnUpdateDefaultPolicyHostRestrictions(
1205 const ExtensionMsg_UpdateDefaultPolicyHostRestrictions_Params& params) {
1206 PermissionsData::SetDefaultPolicyHostRestrictions(
1207 params.default_policy_blocked_hosts, params.default_policy_allowed_hosts);
1208 UpdateBindings(std::string());
1209 }
1210
1211 void Dispatcher::OnUpdatePermissions( 1197 void Dispatcher::OnUpdatePermissions(
1212 const ExtensionMsg_UpdatePermissions_Params& params) { 1198 const ExtensionMsg_UpdatePermissions_Params& params) {
1213 const Extension* extension = 1199 const Extension* extension =
1214 RendererExtensionRegistry::Get()->GetByID(params.extension_id); 1200 RendererExtensionRegistry::Get()->GetByID(params.extension_id);
1215 if (!extension) 1201 if (!extension)
1216 return; 1202 return;
1217 1203
1218 std::unique_ptr<const PermissionSet> active = 1204 std::unique_ptr<const PermissionSet> active =
1219 params.active_permissions.ToPermissionSet(); 1205 params.active_permissions.ToPermissionSet();
1220 std::unique_ptr<const PermissionSet> withheld = 1206 std::unique_ptr<const PermissionSet> withheld =
1221 params.withheld_permissions.ToPermissionSet(); 1207 params.withheld_permissions.ToPermissionSet();
1222 1208
1223 UpdateOriginPermissions( 1209 UpdateOriginPermissions(
1224 extension->url(), 1210 extension->url(),
1225 extension->permissions_data()->GetEffectiveHostPermissions(), 1211 extension->permissions_data()->GetEffectiveHostPermissions(),
1226 active->effective_hosts()); 1212 active->effective_hosts());
1227 1213
1228 extension->permissions_data()->SetPermissions(std::move(active), 1214 extension->permissions_data()->SetPermissions(std::move(active),
1229 std::move(withheld)); 1215 std::move(withheld));
1230 if (params.uses_default_policy_host_restrictions) {
1231 extension->permissions_data()->SetUsesDefaultHostRestrictions();
1232 } else {
1233 extension->permissions_data()->SetPolicyHostRestrictions(
1234 params.policy_blocked_hosts, params.policy_allowed_hosts);
1235 }
1236 UpdateBindings(extension->id()); 1216 UpdateBindings(extension->id());
1237 } 1217 }
1238 1218
1239 void Dispatcher::OnUpdateTabSpecificPermissions(const GURL& visible_url, 1219 void Dispatcher::OnUpdateTabSpecificPermissions(const GURL& visible_url,
1240 const std::string& extension_id, 1220 const std::string& extension_id,
1241 const URLPatternSet& new_hosts, 1221 const URLPatternSet& new_hosts,
1242 bool update_origin_whitelist, 1222 bool update_origin_whitelist,
1243 int tab_id) { 1223 int tab_id) {
1244 const Extension* extension = 1224 const Extension* extension =
1245 RendererExtensionRegistry::Get()->GetByID(extension_id); 1225 RendererExtensionRegistry::Get()->GetByID(extension_id);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 // The "guestViewDeny" module must always be loaded last. It registers 1467 // The "guestViewDeny" module must always be loaded last. It registers
1488 // error-providing custom elements for the GuestView types that are not 1468 // error-providing custom elements for the GuestView types that are not
1489 // available, and thus all of those types must have been checked and loaded 1469 // available, and thus all of those types must have been checked and loaded
1490 // (or not loaded) beforehand. 1470 // (or not loaded) beforehand.
1491 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1471 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1492 module_system->Require("guestViewDeny"); 1472 module_system->Require("guestViewDeny");
1493 } 1473 }
1494 } 1474 }
1495 1475
1496 } // namespace extensions 1476 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698