Extension white and force lists (set by policy) should have priority over auto-updated Google blacklist.


BUG=93246
TEST=unit_tests

Review URL: https://chromiumcodereview.appspot.com/10854009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152548 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5e99cb9d..5e6fd54c 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1125,26 +1125,11 @@
   // Use this set to indicate if an extension in the blacklist has been used.
   std::set<std::string> blacklist_set;
   for (unsigned int i = 0; i < blacklist.size(); ++i) {
-    if (Extension::IdIsValid(blacklist[i])) {
+    if (Extension::IdIsValid(blacklist[i]))
       blacklist_set.insert(blacklist[i]);
-    }
   }
   extension_prefs_->UpdateBlacklist(blacklist_set);
-  std::vector<std::string> to_be_removed;
-  // Loop current extensions, unload installed extensions.
-  for (ExtensionSet::const_iterator iter = extensions_.begin();
-       iter != extensions_.end(); ++iter) {
-    const Extension* extension = (*iter);
-    if (blacklist_set.find(extension->id()) != blacklist_set.end()) {
-      to_be_removed.push_back(extension->id());
-    }
-  }
-
-  // UnloadExtension will change the extensions_ list. So, we should
-  // call it outside the iterator loop.
-  for (unsigned int i = 0; i < to_be_removed.size(); ++i) {
-    UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE);
-  }
+  CheckManagementPolicy();
 }
 
 Profile* ExtensionService::profile() {
@@ -1171,15 +1156,14 @@
   return updater_.get();
 }
 
-void ExtensionService::CheckAdminBlacklist() {
+void ExtensionService::CheckManagementPolicy() {
   std::vector<std::string> to_be_removed;
   // Loop through extensions list, unload installed extensions.
   for (ExtensionSet::const_iterator iter = extensions_.begin();
        iter != extensions_.end(); ++iter) {
     const Extension* extension = (*iter);
-    if (!system_->management_policy()->UserMayLoad(extension, NULL)) {
+    if (!system_->management_policy()->UserMayLoad(extension, NULL))
       to_be_removed.push_back(extension->id());
-    }
   }
 
   // UnloadExtension will change the extensions_ list. So, we should
@@ -1747,7 +1731,7 @@
         }
       }
     }
-    if (extension_prefs_->IsExtensionBlacklisted(e->id())) {
+    if (!extension_prefs_->UserMayLoad(e, NULL)) {
       if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) {
         extension_error_ui->AddBlacklistedExtension(e->id());
         needs_alert = true;
@@ -2429,7 +2413,8 @@
       std::string* pref_name = content::Details<std::string>(details).ptr();
       if (*pref_name == prefs::kExtensionInstallAllowList ||
           *pref_name == prefs::kExtensionInstallDenyList) {
-        CheckAdminBlacklist();
+        IdentifyAlertableExtensions();
+        CheckManagementPolicy();
       } else {
         NOTREACHED() << "Unexpected preference name.";
       }