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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: -Removed old includes, added lock check to SetUsesDefaultHostRestrictions 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 if (!system_->management_policy()->UserMayLoad(extension.get(), nullptr)) 1205 if (!system_->management_policy()->UserMayLoad(extension.get(), nullptr))
1206 to_unload.push_back(extension->id()); 1206 to_unload.push_back(extension->id());
1207 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; 1207 Extension::DisableReason disable_reason = Extension::DISABLE_NONE;
1208 if (system_->management_policy()->MustRemainDisabled( 1208 if (system_->management_policy()->MustRemainDisabled(
1209 extension.get(), &disable_reason, nullptr)) 1209 extension.get(), &disable_reason, nullptr))
1210 to_disable[extension->id()] = disable_reason; 1210 to_disable[extension->id()] = disable_reason;
1211 } 1211 }
1212 1212
1213 extensions::ExtensionManagement* management = 1213 extensions::ExtensionManagement* management =
1214 extensions::ExtensionManagementFactory::GetForBrowserContext(profile()); 1214 extensions::ExtensionManagementFactory::GetForBrowserContext(profile());
1215 for (const auto& extension : registry_->enabled_extensions()) {
1216 bool uses_default =
1217 management->UsesDefaultRuntimeHostRestrictions(extension.get());
1218 if (!uses_default) {
1219 extensions::PermissionsUpdater(profile()).SetPolicyHostRestrictions(
1220 extension.get(), management->GetRuntimeBlockedHosts(extension.get()),
1221 management->GetRuntimeAllowedHosts(extension.get()));
1222 }
1223 extensions::PermissionsUpdater(profile()).SetUsesDefaultHostRestrictions(
Devlin 2017/04/03 15:52:23 this should be in an else. As I've mentioned here
nrpeter 2017/04/03 22:35:48 Done.
1224 extension.get(), uses_default);
1225 }
1226 extensions::PermissionsUpdater(profile()).SetDefaultPolicyHostRestrictions(
1227 management->GetDefaultRuntimeBlockedHosts(),
1228 management->GetDefaultRuntimeAllowedHosts());
1215 1229
1216 // Loop through the disabled extension list, find extensions to re-enable 1230 // Loop through the disabled extension list, find extensions to re-enable
1217 // automatically. These extensions are exclusive from the |to_disable| and 1231 // automatically. These extensions are exclusive from the |to_disable| and
1218 // |to_unload| lists constructed above, since disabled_extensions() and 1232 // |to_unload| lists constructed above, since disabled_extensions() and
1219 // enabled_extensions() are supposed to be mutually exclusive. 1233 // enabled_extensions() are supposed to be mutually exclusive.
1220 for (const auto& extension : registry_->disabled_extensions()) { 1234 for (const auto& extension : registry_->disabled_extensions()) {
1221 // Find all disabled extensions disabled due to minimum version requirement, 1235 // Find all disabled extensions disabled due to minimum version requirement,
1222 // but now satisfying it. 1236 // but now satisfying it.
1223 if (management->CheckMinimumVersion(extension.get(), nullptr) && 1237 if (management->CheckMinimumVersion(extension.get(), nullptr) &&
1224 extension_prefs_->HasDisableReason( 1238 extension_prefs_->HasDisableReason(
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 } 2491 }
2478 2492
2479 void ExtensionService::OnProfileDestructionStarted() { 2493 void ExtensionService::OnProfileDestructionStarted() {
2480 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2494 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2481 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2495 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2482 it != ids_to_unload.end(); 2496 it != ids_to_unload.end();
2483 ++it) { 2497 ++it) {
2484 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2498 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2485 } 2499 }
2486 } 2500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698