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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 extensions_enabled_ = false; 294 extensions_enabled_ = false;
295 295
296 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 296 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
297 content::NotificationService::AllBrowserContextsAndSources()); 297 content::NotificationService::AllBrowserContextsAndSources());
298 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 298 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
299 content::NotificationService::AllBrowserContextsAndSources()); 299 content::NotificationService::AllBrowserContextsAndSources());
300 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 300 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
301 content::NotificationService::AllBrowserContextsAndSources()); 301 content::NotificationService::AllBrowserContextsAndSources());
302 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 302 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
303 content::NotificationService::AllBrowserContextsAndSources()); 303 content::NotificationService::AllBrowserContextsAndSources());
304 registrar_.Add(this,
305 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
306 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.
304 pref_change_registrar_.Init(profile->GetPrefs()); 307 pref_change_registrar_.Init(profile->GetPrefs());
305 base::Closure callback = 308 base::Closure callback =
306 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, 309 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged,
307 base::Unretained(this)); 310 base::Unretained(this));
308 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList, 311 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList,
309 callback); 312 callback);
310 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList, 313 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList,
311 callback); 314 callback);
312 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback); 315 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback);
313 316
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 system_->info_map(), 2148 system_->info_map(),
2146 process->GetID())); 2149 process->GetID()));
2147 break; 2150 break;
2148 } 2151 }
2149 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 2152 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
2150 // Notify observers that chrome update is available. 2153 // Notify observers that chrome update is available.
2151 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_, 2154 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_,
2152 OnChromeUpdateAvailable()); 2155 OnChromeUpdateAvailable());
2153 break; 2156 break;
2154 } 2157 }
2158 case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: {
2159 if (profile_ == content::Source<Profile>(source).ptr()) {
2160 OnProfileDestructionStarted();
2161 }
2162 break;
2163 }
2155 2164
2156 default: 2165 default:
2157 NOTREACHED() << "Unexpected notification type."; 2166 NOTREACHED() << "Unexpected notification type.";
2158 } 2167 }
2159 } 2168 }
2160 2169
2161 void ExtensionService::OnExtensionInstallPrefChanged() { 2170 void ExtensionService::OnExtensionInstallPrefChanged() {
2162 error_controller_->ShowErrorIfNeeded(); 2171 error_controller_->ShowErrorIfNeeded();
2163 CheckManagementPolicy(); 2172 CheckManagementPolicy();
2164 } 2173 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 void ExtensionService::UnloadAllExtensionsInternal() { 2417 void ExtensionService::UnloadAllExtensionsInternal() {
2409 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2418 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2410 2419
2411 registry_->ClearAll(); 2420 registry_->ClearAll();
2412 system_->runtime_data()->ClearAll(); 2421 system_->runtime_data()->ClearAll();
2413 2422
2414 // TODO(erikkay) should there be a notification for this? We can't use 2423 // TODO(erikkay) should there be a notification for this? We can't use
2415 // EXTENSION_UNLOADED since that implies that the extension has been disabled 2424 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2416 // or uninstalled. 2425 // or uninstalled.
2417 } 2426 }
2427
2428 void ExtensionService::OnProfileDestructionStarted() {
2429 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2430 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2431 it != ids_to_unload.end();
2432 ++it) {
2433 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2434 }
2435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698