summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extensions_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extensions_service.cc')
-rw-r--r--chrome/browser/extensions/extensions_service.cc32
1 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 1b83a61..7e4c87f 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -80,6 +80,9 @@ ExtensionsService::ExtensionsService(Profile* profile,
}
backend_ = new ExtensionsServiceBackend(install_directory_, frontend_loop);
+
+ registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED,
+ Source<ExtensionsService>(this));
}
ExtensionsService::~ExtensionsService() {
@@ -132,11 +135,13 @@ void ExtensionsService::UpdateExtension(const std::string& id,
}
void ExtensionsService::ReloadExtension(const std::string& extension_id) {
- Extension* extension = GetExtensionById(extension_id);
- FilePath extension_path = extension->path();
+ // Unload the extension if it's loaded.
+ if (GetExtensionById(extension_id))
+ UnloadExtension(extension_id);
- UnloadExtension(extension_id);
- LoadExtension(extension_path);
+ // At this point we have to reconstruct the path from prefs, because
+ // we have no information about this extension in memory.
+ LoadExtension(extension_prefs_->GetExtensionPath(extension_id));
}
void ExtensionsService::UninstallExtension(const std::string& extension_id,
@@ -387,6 +392,25 @@ void ExtensionsService::OnExternalExtensionFound(const std::string& id,
NULL); // no client (silent install)
}
+void ExtensionsService::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ switch (type.value) {
+ case NotificationType::EXTENSION_PROCESS_CRASHED: {
+ DCHECK_EQ(this, Source<ExtensionsService>(source).ptr());
+ ExtensionHost* host = Details<ExtensionHost>(details).ptr();
+
+ // Unload the entire extension to make sure its state is consistent
+ // (either fully operational, or fully unloaded, but not half-crashed).
+ UnloadExtension(host->extension()->id());
+ }
+ break;
+
+ default:
+ NOTREACHED();
+ }
+}
+
// ExtensionsServicesBackend