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

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: address sky comments 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::Source<Profile>(profile_));
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 OnProfileDestructionStarted();
2160 break;
2161 }
2155 2162
2156 default: 2163 default:
2157 NOTREACHED() << "Unexpected notification type."; 2164 NOTREACHED() << "Unexpected notification type.";
2158 } 2165 }
2159 } 2166 }
2160 2167
2161 void ExtensionService::OnExtensionInstallPrefChanged() { 2168 void ExtensionService::OnExtensionInstallPrefChanged() {
2162 error_controller_->ShowErrorIfNeeded(); 2169 error_controller_->ShowErrorIfNeeded();
2163 CheckManagementPolicy(); 2170 CheckManagementPolicy();
2164 } 2171 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 void ExtensionService::UnloadAllExtensionsInternal() { 2415 void ExtensionService::UnloadAllExtensionsInternal() {
2409 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2416 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2410 2417
2411 registry_->ClearAll(); 2418 registry_->ClearAll();
2412 system_->runtime_data()->ClearAll(); 2419 system_->runtime_data()->ClearAll();
2413 2420
2414 // TODO(erikkay) should there be a notification for this? We can't use 2421 // 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 2422 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2416 // or uninstalled. 2423 // or uninstalled.
2417 } 2424 }
2425
2426 void ExtensionService::OnProfileDestructionStarted() {
2427 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2428 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2429 it != ids_to_unload.end();
2430 ++it) {
2431 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2432 }
2433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698