Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2311)

Unified Diff: chrome/browser/extensions/extensions_service.cc

Issue 164151: Fix "crashed extension" infobar browser crashes.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: sync with trunk Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/views/extensions/extension_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service.cc
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 6dcc0150156b44e68de3537a18d338ba258687f9..c78b24e7f110930c9024ef191405083d096e3770 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -107,6 +107,9 @@ ExtensionsService::ExtensionsService(Profile* profile,
}
backend_ = new ExtensionsServiceBackend(install_directory_, frontend_loop);
+
+ registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED,
+ Source<ExtensionsService>(this));
}
ExtensionsService::~ExtensionsService() {
@@ -159,11 +162,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,
@@ -509,6 +514,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
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/views/extensions/extension_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698