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

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefNotifierImpl Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/content_settings/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 content_type, 210 content_type,
211 "", 211 "",
212 NULL); 212 NULL);
213 } 213 }
214 NotifyObservers(ContentSettingsPattern(), 214 NotifyObservers(ContentSettingsPattern(),
215 ContentSettingsPattern(), 215 ContentSettingsPattern(),
216 content_type, 216 content_type,
217 std::string()); 217 std::string());
218 } 218 }
219 219
220 void PrefProvider::Observe( 220 void PrefProvider::OnPreferenceChanged(PrefServiceBase* service,
221 int type, 221 const std::string& name) {
222 const content::NotificationSource& source,
223 const content::NotificationDetails& details) {
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
225 223
226 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 224 DCHECK_EQ(prefs_, service);
227 DCHECK_EQ(prefs_, content::Source<PrefService>(source).ptr()); 225 if (updating_preferences_)
228 if (updating_preferences_) 226 return;
229 return;
230 227
231 std::string* name = content::Details<std::string>(details).ptr(); 228 if (name != prefs::kContentSettingsPatternPairs) {
232 if (*name != prefs::kContentSettingsPatternPairs) { 229 NOTREACHED() << "Unexpected preference observed";
233 NOTREACHED() << "Unexpected preference observed"; 230 return;
234 return; 231 }
235 } 232 ReadContentSettingsFromPref(true);
236 ReadContentSettingsFromPref(true);
237 233
238 NotifyObservers(ContentSettingsPattern(), 234 NotifyObservers(ContentSettingsPattern(),
239 ContentSettingsPattern(), 235 ContentSettingsPattern(),
240 CONTENT_SETTINGS_TYPE_DEFAULT, 236 CONTENT_SETTINGS_TYPE_DEFAULT,
241 std::string()); 237 std::string());
242 } else {
243 NOTREACHED() << "Unexpected notification";
244 }
245 } 238 }
246 239
247 PrefProvider::~PrefProvider() { 240 PrefProvider::~PrefProvider() {
248 DCHECK(!prefs_); 241 DCHECK(!prefs_);
249 } 242 }
250 243
251 RuleIterator* PrefProvider::GetRuleIterator( 244 RuleIterator* PrefProvider::GetRuleIterator(
252 ContentSettingsType content_type, 245 ContentSettingsType content_type,
253 const ResourceIdentifier& resource_identifier, 246 const ResourceIdentifier& resource_identifier,
254 bool incognito) const { 247 bool incognito) const {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 693
701 void PrefProvider::AssertLockNotHeld() const { 694 void PrefProvider::AssertLockNotHeld() const {
702 #if !defined(NDEBUG) 695 #if !defined(NDEBUG)
703 // |Lock::Acquire()| will assert if the lock is held by this thread. 696 // |Lock::Acquire()| will assert if the lock is held by this thread.
704 lock_.Acquire(); 697 lock_.Acquire();
705 lock_.Release(); 698 lock_.Release();
706 #endif 699 #endif
707 } 700 }
708 701
709 } // namespace content_settings 702 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698