Fix support for --disable-extensions flag.

BUG=65137
TEST=ExtensionsServiceTest

Review URL: http://codereview.chromium.org/5533005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68560 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index f6fb71d..6b89f7a4 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -1560,8 +1560,16 @@
   if (disabled_extension_paths_.erase(extension->id()) > 0)
     EnableExtension(extension->id());
 
-  // Check if the extension's privileges have changed and disable the extension
-  // if necessary.
+  // TODO(jstritar): We may be able to get rid of this branch by overriding the
+  // default extension state to DISABLED when the --disable-extensions flag
+  // is set (http://crbug.com/29067).
+  if (!extensions_enabled() &&
+      !extension->is_theme() &&
+      extension->location() != Extension::COMPONENT)
+    return;
+
+  // Check if the extension's privileges have changed and disable the
+  // extension if necessary.
   DisableIfPrivilegeIncrease(extension);
 
   switch (extension_prefs_->GetExtensionState(extension->id())) {