Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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()).SetUsesDefaultHostRestrictions( | |
| 1220 extension.get()); | |
| 1221 } else { | |
| 1222 extensions::PermissionsUpdater(profile()).SetPolicyHostRestrictions( | |
| 1223 extension.get(), management->GetRuntimeBlockedHosts(extension.get()), | |
| 1224 management->GetRuntimeAllowedHosts(extension.get())); | |
| 1225 } | |
| 1226 } | |
| 1227 extensions::PermissionsUpdater(profile()).SetDefaultPolicyHostRestrictions( | |
|
Devlin
2017/04/07 00:40:26
nit: let's put this call first, so that existing r
nrpeter
2017/04/12 23:35:44
Done.
| |
| 1228 management->GetDefaultRuntimeBlockedHosts(), | |
| 1229 management->GetDefaultRuntimeAllowedHosts()); | |
| 1215 | 1230 |
| 1216 // Loop through the disabled extension list, find extensions to re-enable | 1231 // Loop through the disabled extension list, find extensions to re-enable |
| 1217 // automatically. These extensions are exclusive from the |to_disable| and | 1232 // automatically. These extensions are exclusive from the |to_disable| and |
| 1218 // |to_unload| lists constructed above, since disabled_extensions() and | 1233 // |to_unload| lists constructed above, since disabled_extensions() and |
| 1219 // enabled_extensions() are supposed to be mutually exclusive. | 1234 // enabled_extensions() are supposed to be mutually exclusive. |
| 1220 for (const auto& extension : registry_->disabled_extensions()) { | 1235 for (const auto& extension : registry_->disabled_extensions()) { |
| 1221 // Find all disabled extensions disabled due to minimum version requirement, | 1236 // Find all disabled extensions disabled due to minimum version requirement, |
| 1222 // but now satisfying it. | 1237 // but now satisfying it. |
| 1223 if (management->CheckMinimumVersion(extension.get(), nullptr) && | 1238 if (management->CheckMinimumVersion(extension.get(), nullptr) && |
| 1224 extension_prefs_->HasDisableReason( | 1239 extension_prefs_->HasDisableReason( |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2477 } | 2492 } |
| 2478 | 2493 |
| 2479 void ExtensionService::OnProfileDestructionStarted() { | 2494 void ExtensionService::OnProfileDestructionStarted() { |
| 2480 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2495 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2481 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2496 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2482 it != ids_to_unload.end(); | 2497 it != ids_to_unload.end(); |
| 2483 ++it) { | 2498 ++it) { |
| 2484 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2499 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2485 } | 2500 } |
| 2486 } | 2501 } |
| OLD | NEW |