Don't show a "new background extension" warning when reinstalling an existing extension

Currently, we show a notification bubble whenever we upgrade or reload an extension.  This change checks to see if an extension is in the process of being reloaded or upgraded
before showing the notice.

BUG=157464

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209075 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index ab91a0b..2458305f 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -669,7 +669,7 @@
   return true;
 }
 
-void ExtensionService::ReloadExtension(const std::string& extension_id) {
+void ExtensionService::ReloadExtension(const std::string extension_id) {
   CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
 
   // If the extension is already reloading, don't reload again.
@@ -713,12 +713,15 @@
   // If we're reloading a component extension, use the component extension
   // loader's reloader.
   if (component_loader_->Exists(extension_id)) {
+    SetBeingReloaded(extension_id, true);
     component_loader_->Reload(extension_id);
+    SetBeingReloaded(extension_id, false);
     return;
   }
 
   // Check the installed extensions to see if what we're reloading was already
   // installed.
+  SetBeingReloaded(extension_id, true);
   scoped_ptr<ExtensionInfo> installed_extension(
       extension_prefs_->GetInstalledExtensionInfo(extension_id));
   if (installed_extension.get() &&
@@ -731,6 +734,8 @@
     CHECK(!path.empty());
     extensions::UnpackedInstaller::Create(this)->Load(path);
   }
+  // When reloading is done, mark this extension as done reloading.
+  SetBeingReloaded(extension_id, false);
 }
 
 bool ExtensionService::UninstallExtension(
@@ -2863,6 +2868,27 @@
   extension_runtime_data_[extension->id()].being_upgraded = value;
 }
 
+bool ExtensionService::IsBeingReloaded(
+    const std::string& extension_id) const {
+  return ContainsKey(extensions_being_reloaded_, extension_id);
+}
+
+void ExtensionService::SetBeingReloaded(const std::string& extension_id,
+                                         bool isBeingReloaded) {
+  LOG(INFO) << "****** " << __FUNCTION__;
+  LOG(INFO) << "****** " << __FUNCTION__ << " extension_id is: "
+            << extension_id << " and isBeingReloaded is " << isBeingReloaded;
+  LOG(INFO) << "****** " << __FUNCTION__ << " Set size is "
+            << extensions_being_reloaded_.size();
+  if (isBeingReloaded) {
+    extensions_being_reloaded_.insert(extension_id);
+    LOG(INFO) << "****** " << __FUNCTION__ << " insert succeeded.";
+  } else {
+    extensions_being_reloaded_.erase(extension_id);
+    LOG(INFO) << "****** " << __FUNCTION__ << " erase succeeded.";
+  }
+}
+
 bool ExtensionService::HasUsedWebRequest(const Extension* extension) const {
   ExtensionRuntimeDataMap::const_iterator it =
       extension_runtime_data_.find(extension->id());