summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 23:21:10 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 23:21:10 +0000
commitf17dbd463d5066732782aacdb85432bf072fa597 (patch)
tree0acf962efa7c0da39204640994934937c6fe74ee /chrome
parent402d7302df101e6a40ef3b9cc618e129a8a5ac67 (diff)
downloadchromium_src-f17dbd463d5066732782aacdb85432bf072fa597.zip
chromium_src-f17dbd463d5066732782aacdb85432bf072fa597.tar.gz
chromium_src-f17dbd463d5066732782aacdb85432bf072fa597.tar.bz2
Upon a bad reload of an extension, leave the original disabled instead of blasting it away.
BUG=26888 TEST=TBD Review URL: http://codereview.chromium.org/3106015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extensions_service.cc22
-rw-r--r--chrome/browser/extensions/extensions_service.h8
2 files changed, 22 insertions, 8 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 22c4270..a79384b 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -329,7 +329,7 @@ void ExtensionsService::ReloadExtension(const std::string& extension_id) {
FilePath path;
Extension* current_extension = GetExtensionById(extension_id, false);
- // Unload the extension if it's loaded. It might not be loaded if it crashed.
+ // Disable the extension if it's loaded. It might not be loaded if it crashed.
if (current_extension) {
// If the extension has an inspector open for its background page, detach
// the inspector and hang onto a cookie for it, so that we can reattach
@@ -346,7 +346,8 @@ void ExtensionsService::ReloadExtension(const std::string& extension_id) {
}
path = current_extension->path();
- UnloadExtension(extension_id);
+ DisableExtension(extension_id);
+ disabled_extension_paths_[extension_id] = path;
} else {
path = unloaded_extension_paths_[extension_id];
}
@@ -620,11 +621,11 @@ void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info,
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(
- backend_.get(),
- &ExtensionsServiceBackend::CheckExternalUninstall,
- scoped_refptr<ExtensionsService>(this),
- info.extension_id,
- info.extension_location));
+ backend_.get(),
+ &ExtensionsServiceBackend::CheckExternalUninstall,
+ scoped_refptr<ExtensionsService>(this),
+ info.extension_id,
+ info.extension_location));
}
}
@@ -841,6 +842,9 @@ void ExtensionsService::UnloadExtension(const std::string& extension_id) {
// even if it's not permanently installed.
unloaded_extension_paths_[extension->id()] = extension->path();
+ // Clean up if the extension is meant to be enabled after a reload.
+ disabled_extension_paths_.erase(extension->id());
+
ExtensionDOMUI::UnregisterChromeURLOverrides(profile_,
extension->GetChromeURLOverrides());
@@ -920,6 +924,10 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension,
// The extension is now loaded, remove its data from unloaded extension map.
unloaded_extension_paths_.erase(extension->id());
+ // If the extension was disabled for a reload, then enable it.
+ if (disabled_extension_paths_.erase(extension->id()) > 0)
+ EnableExtension(extension->id());
+
// TODO(aa): Need to re-evaluate this branch. Does this still make sense now
// that extensions are enabled by default?
if (extensions_enabled() ||
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index e5f15d2..25182ee 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -379,7 +379,7 @@ class ExtensionsService
void UpdateActiveExtensionsInCrashReporter();
// Helper method. Loads extension from prefs.
- void LoadInstalledExtension(const ExtensionInfo& info, bool relocalize);
+ void LoadInstalledExtension(const ExtensionInfo& info, bool write_to_prefs);
// Helper methods to configure the storage services accordingly.
void GrantUnlimitedStorage(Extension* extension);
@@ -430,6 +430,12 @@ class ExtensionsService
typedef std::map<std::string, FilePath> UnloadedExtensionPathMap;
UnloadedExtensionPathMap unloaded_extension_paths_;
+ // Map disabled extensions' ids to their paths. When a temporarily loaded
+ // extension is disabled before it is reloaded, keep track of the path so that
+ // it can be re-enabled upon a successful load.
+ typedef std::map<std::string, FilePath> DisabledExtensionPathMap;
+ DisabledExtensionPathMap disabled_extension_paths_;
+
// Map of inspector cookies that are detached, waiting for an extension to be
// reloaded.
typedef std::map<std::string, int> OrphanedDevTools;