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

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

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 3 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/extensions_service.cc
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index e2e6342c4eae061db991e5818610034fd54899ea..017890ff28583135d77a27337d9199cd90077784 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -528,11 +528,11 @@ bool ExtensionsService::IsDownloadFromMiniGallery(const GURL& download_url) {
ExtensionsService::ExtensionsService(Profile* profile,
const CommandLine* command_line,
- PrefService* prefs,
const FilePath& install_directory,
bool autoupdate_enabled)
: profile_(profile),
- extension_prefs_(new ExtensionPrefs(prefs, install_directory)),
+ extension_prefs_(new ExtensionPrefs(profile->GetPrefs(),
+ install_directory)),
install_directory_(install_directory),
extensions_enabled_(true),
show_extensions_prompts_(true),
@@ -547,8 +547,9 @@ ExtensionsService::ExtensionsService(Profile* profile,
registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED,
NotificationService::AllSources());
- prefs->AddPrefObserver(prefs::kExtensionInstallAllowList, this);
- prefs->AddPrefObserver(prefs::kExtensionInstallDenyList, this);
+ pref_change_registrar_.Init(profile->GetPrefs());
+ pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this);
+ pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this);
// Set up the ExtensionUpdater
if (autoupdate_enabled) {
@@ -558,7 +559,9 @@ ExtensionsService::ExtensionsService(Profile* profile,
switches::kExtensionsUpdateFrequency),
&update_frequency);
}
- updater_ = new ExtensionUpdater(this, prefs, update_frequency);
+ updater_ = new ExtensionUpdater(this,
+ profile->GetPrefs(),
+ update_frequency);
}
backend_ = new ExtensionsServiceBackend(install_directory_,
@@ -572,6 +575,7 @@ ExtensionsService::ExtensionsService(Profile* profile,
}
ExtensionsService::~ExtensionsService() {
+ DCHECK(!profile_); // Profile should have told us it's going away.
UnloadAllExtensions();
if (updater_.get()) {
updater_->Stop();
@@ -1186,12 +1190,9 @@ void ExtensionsService::UpdateExtensionBlacklist(
}
void ExtensionsService::DestroyingProfile() {
- profile_->GetPrefs()->RemovePrefObserver(
- prefs::kExtensionInstallAllowList, this);
- profile_->GetPrefs()->RemovePrefObserver(
- prefs::kExtensionInstallDenyList, this);
-
+ pref_change_registrar_.RemoveAll();
profile_ = NULL;
+ toolbar_model_.DestroyingProfile();
}
void ExtensionsService::CheckAdminBlacklist() {
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/extensions_service_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698