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

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

Issue 11293249: Remove PrefObserver usage, batch 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // Read content settings exceptions. 114 // Read content settings exceptions.
115 ReadContentSettingsFromPref(false); 115 ReadContentSettingsFromPref(false);
116 116
117 if (!is_incognito_) { 117 if (!is_incognito_) {
118 UMA_HISTOGRAM_COUNTS("ContentSettings.NumberOfExceptions", 118 UMA_HISTOGRAM_COUNTS("ContentSettings.NumberOfExceptions",
119 value_map_.size()); 119 value_map_.size());
120 } 120 }
121 121
122 pref_change_registrar_.Init(prefs_); 122 pref_change_registrar_.Init(prefs_);
123 pref_change_registrar_.Add(prefs::kContentSettingsPatternPairs, this); 123 pref_change_registrar_.Add(
124 prefs::kContentSettingsPatternPairs,
125 base::Bind(&PrefProvider::OnContentSettingsPatternPairsChanged,
126 base::Unretained(this)));
124 } 127 }
125 128
126 bool PrefProvider::SetWebsiteSetting( 129 bool PrefProvider::SetWebsiteSetting(
127 const ContentSettingsPattern& primary_pattern, 130 const ContentSettingsPattern& primary_pattern,
128 const ContentSettingsPattern& secondary_pattern, 131 const ContentSettingsPattern& secondary_pattern,
129 ContentSettingsType content_type, 132 ContentSettingsType content_type,
130 const ResourceIdentifier& resource_identifier, 133 const ResourceIdentifier& resource_identifier,
131 Value* in_value) { 134 Value* in_value) {
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
133 DCHECK(prefs_); 136 DCHECK(prefs_);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 content_type, 213 content_type,
211 "", 214 "",
212 NULL); 215 NULL);
213 } 216 }
214 NotifyObservers(ContentSettingsPattern(), 217 NotifyObservers(ContentSettingsPattern(),
215 ContentSettingsPattern(), 218 ContentSettingsPattern(),
216 content_type, 219 content_type,
217 std::string()); 220 std::string());
218 } 221 }
219 222
220 void PrefProvider::OnPreferenceChanged(PrefServiceBase* service,
221 const std::string& name) {
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
223 DCHECK_EQ(prefs_, service);
224 DCHECK_EQ(std::string(prefs::kContentSettingsPatternPairs), name);
225
226 if (updating_preferences_)
227 return;
228
229 ReadContentSettingsFromPref(true);
230
231 NotifyObservers(ContentSettingsPattern(),
232 ContentSettingsPattern(),
233 CONTENT_SETTINGS_TYPE_DEFAULT,
234 std::string());
235 }
236
237 PrefProvider::~PrefProvider() { 223 PrefProvider::~PrefProvider() {
238 DCHECK(!prefs_); 224 DCHECK(!prefs_);
239 } 225 }
240 226
241 RuleIterator* PrefProvider::GetRuleIterator( 227 RuleIterator* PrefProvider::GetRuleIterator(
242 ContentSettingsType content_type, 228 ContentSettingsType content_type,
243 const ResourceIdentifier& resource_identifier, 229 const ResourceIdentifier& resource_identifier,
244 bool incognito) const { 230 bool incognito) const {
245 if (incognito) 231 if (incognito)
246 return incognito_value_map_.GetRuleIterator(content_type, 232 return incognito_value_map_.GetRuleIterator(content_type,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 value_map_.SetValue(pattern_pair.first, 363 value_map_.SetValue(pattern_pair.first,
378 pattern_pair.second, 364 pattern_pair.second,
379 content_type, 365 content_type,
380 ResourceIdentifier(""), 366 ResourceIdentifier(""),
381 value); 367 value);
382 } 368 }
383 } 369 }
384 } 370 }
385 } 371 }
386 372
373 void PrefProvider::OnContentSettingsPatternPairsChanged() {
374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
375
376 if (updating_preferences_)
377 return;
378
379 ReadContentSettingsFromPref(true);
380
381 NotifyObservers(ContentSettingsPattern(),
382 ContentSettingsPattern(),
383 CONTENT_SETTINGS_TYPE_DEFAULT,
384 std::string());
385 }
386
387 void PrefProvider::UpdatePatternPairsSettings( 387 void PrefProvider::UpdatePatternPairsSettings(
388 const ContentSettingsPattern& primary_pattern, 388 const ContentSettingsPattern& primary_pattern,
389 const ContentSettingsPattern& secondary_pattern, 389 const ContentSettingsPattern& secondary_pattern,
390 ContentSettingsType content_type, 390 ContentSettingsType content_type,
391 const ResourceIdentifier& resource_identifier, 391 const ResourceIdentifier& resource_identifier,
392 const base::Value* value, 392 const base::Value* value,
393 DictionaryValue* pattern_pairs_settings) { 393 DictionaryValue* pattern_pairs_settings) {
394 // Get settings dictionary for the given patterns. 394 // Get settings dictionary for the given patterns.
395 std::string pattern_str(CreatePatternString(primary_pattern, 395 std::string pattern_str(CreatePatternString(primary_pattern,
396 secondary_pattern)); 396 secondary_pattern));
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 690
691 void PrefProvider::AssertLockNotHeld() const { 691 void PrefProvider::AssertLockNotHeld() const {
692 #if !defined(NDEBUG) 692 #if !defined(NDEBUG)
693 // |Lock::Acquire()| will assert if the lock is held by this thread. 693 // |Lock::Acquire()| will assert if the lock is held by this thread.
694 lock_.Acquire(); 694 lock_.Acquire();
695 lock_.Release(); 695 lock_.Release();
696 #endif 696 #endif
697 } 697 }
698 698
699 } // namespace content_settings 699 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698