Correct the flag: is_extension_upgrade, which denote whether the extension is being upgrading.

In the function BrowserActionsContainer::BrowserActionAdded of chrome/browser/ui/views/browser_actions_container.cc, if the extension is marked as upgrading, it will stop enlarge the container if it was already at maximum size. The upgrading extension didn't remove the browser action, so it works correctly. However, when a extension is crashed (The browser action will be removed if it has) and reloaded (will  add the browser action icon back if it has), it shouldn't be marked as upgrading. The bug is introduced by http://src.chromium.org/viewvc/chrome?revision=196634&view=revision. 

BUG=261996
TEST=On Windows, reload a crashed extension shouldn't resize the browser action container of browser. For more detail, please refer to the bug.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216407 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 4deba6c..0bdc3f5 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2035,13 +2035,17 @@
   }
 
   bool is_extension_upgrade = false;
-  if (const Extension* old = GetInstalledExtension(extension->id())) {
-    is_extension_upgrade = true;
-    DCHECK_NE(extension, old);
+  bool is_extension_installed = false;
+  const Extension* old = GetInstalledExtension(extension->id());
+  if (old) {
+    is_extension_installed = true;
+    int version_compare_result =
+        extension->version()->CompareTo(*(old->version()));
+    is_extension_upgrade = version_compare_result > 0;
     // Other than for unpacked extensions, CrxInstaller should have guaranteed
     // that we aren't downgrading.
     if (!Manifest::IsUnpackedLocation(extension->location()))
-      CHECK_GE(extension->version()->CompareTo(*(old->version())), 0);
+      CHECK_GE(version_compare_result, 0);
   }
   SetBeingUpgraded(extension, is_extension_upgrade);
 
@@ -2056,9 +2060,9 @@
 
   // Check if the extension's privileges have changed and mark the
   // extension disabled if necessary.
-  CheckPermissionsIncrease(extension, is_extension_upgrade);
+  CheckPermissionsIncrease(extension, is_extension_installed);
 
-  if (is_extension_upgrade && !reloading) {
+  if (is_extension_installed && !reloading) {
     // To upgrade an extension in place, unload the old one and then load the
     // new one.  ReloadExtension disables the extension, which is sufficient.
     UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_UPDATE);
@@ -2161,7 +2165,7 @@
 }
 
 void ExtensionService::CheckPermissionsIncrease(const Extension* extension,
-                                                bool is_extension_upgrade) {
+                                                bool is_extension_installed) {
   UpdateActivePermissions(extension);
 
   // We keep track of all permissions the user has granted each extension.
@@ -2188,7 +2192,7 @@
   int disable_reasons = extension_prefs_->GetDisableReasons(extension->id());
 
   bool auto_grant_permission =
-      (!is_extension_upgrade && extension->was_installed_by_default()) ||
+      (!is_extension_installed && extension->was_installed_by_default()) ||
       chrome::IsRunningInForcedAppMode();
   // Silently grant all active permissions to default apps only on install.
   // After install they should behave like other apps.
@@ -2216,7 +2220,7 @@
         extension->GetActivePermissions().get(), extension->GetType());
   }
 
-  if (is_extension_upgrade) {
+  if (is_extension_installed) {
     // If the extension was already disabled, suppress any alerts for becoming
     // disabled on permissions increase.
     bool previously_disabled =