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

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

Issue 266343002: Unload all apps / extensions when deleting a profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not send NULL extension pointer in notifications. Created 6 years, 7 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
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 7a357fd17c85f2d3679652bbc2d68acbed82f528..702b7fc432c68d77f54708e92d9615f18c7168e7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -301,6 +301,9 @@ ExtensionService::ExtensionService(Profile* profile,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
+ content::Source<Profile>(profile_));
pref_change_registrar_.Init(profile->GetPrefs());
base::Closure callback =
base::Bind(&ExtensionService::OnExtensionInstallPrefChanged,
@@ -1398,10 +1401,12 @@ void ExtensionService::RemoveComponentExtension(
scoped_refptr<const Extension> extension(
GetExtensionById(extension_id, false));
UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
- content::Source<Profile>(profile_),
- content::Details<const Extension>(extension.get()));
+ if (extension.get()) {
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
+ content::Source<Profile>(profile_),
+ content::Details<const Extension>(extension.get()));
+ }
}
void ExtensionService::UnloadAllExtensionsForTest() {
@@ -2165,6 +2170,10 @@ void ExtensionService::Observe(int type,
OnChromeUpdateAvailable());
break;
}
+ case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: {
+ OnProfileDestructionStarted();
+ break;
+ }
default:
NOTREACHED() << "Unexpected notification type.";
@@ -2428,3 +2437,12 @@ void ExtensionService::UnloadAllExtensionsInternal() {
// EXTENSION_UNLOADED since that implies that the extension has been disabled
// or uninstalled.
}
+
+void ExtensionService::OnProfileDestructionStarted() {
+ ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
+ for (ExtensionIdSet::iterator it = ids_to_unload.begin();
+ it != ids_to_unload.end();
+ ++it) {
+ UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
+ }
+}
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698