OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |