Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 037abdbbdbe63e221bd4e4d1888fafcbb310cb18..84cba2eaea10ddaeff56381dd9968cef807a11b5 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::NotificationService::AllBrowserContextsAndSources()); |
|
sky
2014/05/07 22:17:32
nit: seems like you could add for the source you c
scheib
2014/05/08 15:17:52
Done.
|
| pref_change_registrar_.Init(profile->GetPrefs()); |
| base::Closure callback = |
| base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, |
| @@ -2152,6 +2155,12 @@ void ExtensionService::Observe(int type, |
| OnChromeUpdateAvailable()); |
| break; |
| } |
| + case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: { |
| + if (profile_ == content::Source<Profile>(source).ptr()) { |
| + OnProfileDestructionStarted(); |
| + } |
| + break; |
| + } |
| default: |
| NOTREACHED() << "Unexpected notification type."; |
| @@ -2415,3 +2424,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); |
| + } |
| +} |