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

Side by Side Diff: chrome/browser/host_content_settings_map.cc

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 2 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
« no previous file with comments | « chrome/browser/host_content_settings_map.h ('k') | chrome/browser/host_zoom_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/host_content_settings_map.h" 5 #include "chrome/browser/host_content_settings_map.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 if (prefs->GetInteger(prefs::kContentSettingsVersion) > 224 if (prefs->GetInteger(prefs::kContentSettingsVersion) >
225 kContentSettingsPatternVersion) { 225 kContentSettingsPatternVersion) {
226 LOG(ERROR) << "Unknown content settings version in preferences."; 226 LOG(ERROR) << "Unknown content settings version in preferences.";
227 return; 227 return;
228 } 228 }
229 229
230 // Read exceptions. 230 // Read exceptions.
231 ReadExceptions(false); 231 ReadExceptions(false);
232 232
233 prefs->AddPrefObserver(prefs::kDefaultContentSettings, this); 233 pref_change_registrar_.Init(prefs);
234 prefs->AddPrefObserver(prefs::kContentSettingsPatterns, this); 234 pref_change_registrar_.Add(prefs::kDefaultContentSettings, this);
235 prefs->AddPrefObserver(prefs::kBlockThirdPartyCookies, this); 235 pref_change_registrar_.Add(prefs::kContentSettingsPatterns, this);
236 prefs->AddPrefObserver(prefs::kBlockNonsandboxedPlugins, this); 236 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this);
237 pref_change_registrar_.Add(prefs::kBlockNonsandboxedPlugins, this);
237 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 238 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
238 Source<Profile>(profile_)); 239 Source<Profile>(profile_));
239 } 240 }
240 241
241 // static 242 // static
242 void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) { 243 void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) {
243 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings); 244 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings);
244 prefs->RegisterIntegerPref(prefs::kContentSettingsVersion, 245 prefs->RegisterIntegerPref(prefs::kContentSettingsVersion,
245 kContentSettingsPatternVersion); 246 kContentSettingsPatternVersion);
246 prefs->RegisterDictionaryPref(prefs::kContentSettingsPatterns); 247 prefs->RegisterDictionaryPref(prefs::kContentSettingsPatterns);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 NotificationService::current()->Notify( 903 NotificationService::current()->Notify(
903 NotificationType::CONTENT_SETTINGS_CHANGED, 904 NotificationType::CONTENT_SETTINGS_CHANGED,
904 Source<HostContentSettingsMap>(this), 905 Source<HostContentSettingsMap>(this),
905 Details<const ContentSettingsDetails>(&details)); 906 Details<const ContentSettingsDetails>(&details));
906 } 907 }
907 908
908 void HostContentSettingsMap::UnregisterObservers() { 909 void HostContentSettingsMap::UnregisterObservers() {
909 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 910 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
910 if (!profile_) 911 if (!profile_)
911 return; 912 return;
912 PrefService* prefs = profile_->GetPrefs(); 913 pref_change_registrar_.RemoveAll();
913 prefs->RemovePrefObserver(prefs::kDefaultContentSettings, this);
914 prefs->RemovePrefObserver(prefs::kContentSettingsPatterns, this);
915 prefs->RemovePrefObserver(prefs::kBlockThirdPartyCookies, this);
916 prefs->RemovePrefObserver(prefs::kBlockNonsandboxedPlugins, this);
917 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, 914 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED,
918 Source<Profile>(profile_)); 915 Source<Profile>(profile_));
919 profile_ = NULL; 916 profile_ = NULL;
920 } 917 }
OLDNEW
« no previous file with comments | « chrome/browser/host_content_settings_map.h ('k') | chrome/browser/host_zoom_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698