Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 2db9801aecec9c266746d7f0991ae56683675ae8..964929a37bcc0305666218f668d47196d5b00237 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -119,6 +119,7 @@ using extensions::Extension; |
| using extensions::ExtensionIdSet; |
| using extensions::ExtensionInfo; |
| using extensions::FeatureSwitch; |
| +using extensions::ManagementPolicy; |
| using extensions::Manifest; |
| using extensions::PermissionMessage; |
| using extensions::PermissionMessages; |
| @@ -891,16 +892,21 @@ void ExtensionService::EnableExtension(const std::string& extension_id) { |
| if (IsExtensionEnabled(extension_id)) |
| return; |
| + const Extension* extension = disabled_extensions_.GetByID(extension_id); |
| + |
| + ManagementPolicy* policy = system_->management_policy(); |
| + if (extension && policy->MustRemainDisabled(extension, NULL, NULL)) |
|
miket_OOO
2013/11/04 23:18:10
I can't tell for sure whether this is always calle
asargent_no_longer_on_chrome
2013/11/05 00:20:44
The InstalledLoader should catch cases during init
|
| + return; |
| extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED); |
| extension_prefs_->ClearDisableReasons(extension_id); |
| - const Extension* extension = disabled_extensions_.GetByID(extension_id); |
| // This can happen if sync enables an extension that is not |
| // installed yet. |
| if (!extension) |
| return; |
| + |
|
miket_OOO
2013/11/04 23:18:10
WHA?!
asargent_no_longer_on_chrome
2013/11/05 00:20:44
oops, fixed.
|
| if (IsUnacknowledgedExternalExtension(extension)) { |
| UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", |
| EXTERNAL_EXTENSION_REENABLED, |
| @@ -1205,20 +1211,28 @@ extensions::ExtensionUpdater* ExtensionService::updater() { |
| } |
| void ExtensionService::CheckManagementPolicy() { |
| - std::vector<std::string> to_be_removed; |
| + std::vector<std::string> to_unload; |
| + std::map<std::string, Extension::DisableReason> to_disable; |
| - // Loop through extensions list, unload installed extensions. |
| + // Loop through the extensions list, finding extensions we need to unload or |
| + // disable. |
| for (ExtensionSet::const_iterator iter = extensions_.begin(); |
| iter != extensions_.end(); ++iter) { |
| const Extension* extension = (iter->get()); |
| if (!system_->management_policy()->UserMayLoad(extension, NULL)) |
| - to_be_removed.push_back(extension->id()); |
| + to_unload.push_back(extension->id()); |
| + Extension::DisableReason disable_reason = Extension::DISABLE_NONE; |
| + if (!system_->management_policy()->MustRemainDisabled( |
| + extension, &disable_reason, NULL)) |
| + to_disable[extension->id()] = disable_reason; |
|
miket_OOO
2013/11/04 23:18:10
Check logic.
asargent_no_longer_on_chrome
2013/11/05 00:20:44
Good catch. The "!" was a typo.
Fixed.
|
| } |
| - // UnloadExtension will change the extensions_ list. So, we should |
| - // call it outside the iterator loop. |
| - for (size_t i = 0; i < to_be_removed.size(); ++i) |
| - UnloadExtension(to_be_removed[i], UnloadedExtensionInfo::REASON_DISABLE); |
| + for (size_t i = 0; i < to_unload.size(); ++i) |
| + UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE); |
| + |
| + for (std::map<std::string, Extension::DisableReason>::const_iterator i = |
| + to_disable.begin(); i != to_disable.end(); ++i) |
| + DisableExtension(i->first, i->second); |
| } |
| void ExtensionService::CheckForUpdatesSoon() { |