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 d8e601beb50ac115f6528daf73bf231b02b4ae96..55afb018d8fa97238d97ece098ac9f0331e029be 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -857,6 +857,7 @@ void ExtensionService::DisableExtension( |
| // preferences. |
| if (extension && |
| disable_reason != Extension::DISABLE_RELOAD && |
| + disable_reason != Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY && |
| !system_->management_policy()->UserMayModifySettings(extension, NULL) && |
| extension->location() != Manifest::EXTERNAL_COMPONENT) { |
| return; |
| @@ -1118,15 +1119,13 @@ void ExtensionService::CheckManagementPolicy() { |
| // Loop through the extensions list, finding extensions we need to unload or |
| // disable. |
| - const ExtensionSet& extensions = registry_->enabled_extensions(); |
| - for (ExtensionSet::const_iterator iter = extensions.begin(); |
| - iter != extensions.end(); ++iter) { |
| - const Extension* extension = (iter->get()); |
| - if (!system_->management_policy()->UserMayLoad(extension, NULL)) |
| + for (scoped_refptr<const Extension> extension : |
| + registry_->enabled_extensions()) { |
| + if (!system_->management_policy()->UserMayLoad(extension.get(), nullptr)) |
| to_unload.push_back(extension->id()); |
| Extension::DisableReason disable_reason = Extension::DISABLE_NONE; |
| if (system_->management_policy()->MustRemainDisabled( |
| - extension, &disable_reason, NULL)) |
| + extension.get(), &disable_reason, nullptr)) |
| to_disable[extension->id()] = disable_reason; |
| } |
| @@ -1136,6 +1135,21 @@ void ExtensionService::CheckManagementPolicy() { |
| for (std::map<std::string, Extension::DisableReason>::const_iterator i = |
| to_disable.begin(); i != to_disable.end(); ++i) |
| DisableExtension(i->first, i->second); |
| + |
| + if (updater_.get()) { |
| + // Find all extensions (including the ones got disabled just now) disabled |
|
pastarmovj
2014/11/11 12:50:55
nit: ...ones _that_ got...
binjin
2014/11/11 19:10:37
Done.
|
| + // due to minimum version requirement from policy, and check for update. |
| + extensions::ExtensionUpdater::CheckParams params; |
| + for (scoped_refptr<const Extension> extension : |
| + registry_->disabled_extensions()) { |
| + if (extension_prefs_->HasDisableReason( |
| + extension->id(), Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY)) { |
| + params.ids.push_back(extension->id()); |
| + } |
| + } |
| + if (!params.ids.empty()) |
| + updater_->CheckNow(params); |
| + } |
| } |
| void ExtensionService::CheckForUpdatesSoon() { |
| @@ -1622,6 +1636,17 @@ void ExtensionService::OnExtensionInstalled( |
| extension_prefs_->ClearDisableReasons(id); |
| } |
| + // If the extension was disabled because of the minimum version requirements |
| + // from enterprise policy, and now satisfies it now and there are not other |
|
pastarmovj
2014/11/11 12:50:55
nit: remove the first "now". Also s/not/no/
binjin
2014/11/11 19:10:37
Done.
|
| + // disable reasons, enable it. |
| + if (extension_prefs_->GetDisableReasons(id) == |
| + Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY && |
| + extensions::ExtensionManagementFactory::GetForBrowserContext(profile()) |
| + ->CheckMinimumVersion(extension, nullptr)) { |
| + initial_enable = true; |
| + extension_prefs_->ClearDisableReasons(id); |
| + } |
| + |
| if (install_flags & extensions::kInstallFlagIsBlacklistedForMalware) { |
| // Installation of a blacklisted extension can happen from sync, policy, |
| // etc, where to maintain consistency we need to install it, just never |
| @@ -1654,6 +1679,8 @@ void ExtensionService::OnExtensionInstalled( |
| } |
| } |
| + // WIP(binjin): need to figure out a way to check MustRemainDisabled here and |
|
pastarmovj
2014/11/11 12:50:55
nit: AFAIK WIP is not officially used in Chromium
binjin
2014/11/11 19:10:37
It's a mark for myself, reminding that there are u
|
| + // pass reasons to extension prefs. |
| const Extension::State initial_state = |
| initial_enable ? Extension::ENABLED : Extension::DISABLED; |
| if (ShouldDelayExtensionUpdate( |