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

Side by Side Diff: components/content_settings/core/browser/content_settings_pref_provider.cc

Issue 1005303003: Split the aggregate dictionary of content settings exceptions into per-type dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 "components/content_settings/core/browser/content_settings_pref_provide r.h" 5 #include "components/content_settings/core/browser/content_settings_pref_provide r.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/auto_reset.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/prefs/scoped_user_pref_update.h"
15 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
16 #include "base/time/clock.h" 18 #include "base/time/clock.h"
17 #include "base/time/default_clock.h" 19 #include "base/time/default_clock.h"
18 #include "components/content_settings/core/browser/content_settings_pref.h" 20 #include "components/content_settings/core/browser/content_settings_pref.h"
19 #include "components/content_settings/core/browser/content_settings_rule.h" 21 #include "components/content_settings/core/browser/content_settings_rule.h"
20 #include "components/content_settings/core/browser/content_settings_utils.h" 22 #include "components/content_settings/core/browser/content_settings_utils.h"
21 #include "components/content_settings/core/browser/host_content_settings_map.h" 23 #include "components/content_settings/core/browser/host_content_settings_map.h"
22 #include "components/content_settings/core/common/content_settings.h" 24 #include "components/content_settings/core/common/content_settings.h"
23 #include "components/content_settings/core/common/content_settings_pattern.h" 25 #include "components/content_settings/core/common/content_settings_pattern.h"
24 #include "components/content_settings/core/common/pref_names.h" 26 #include "components/content_settings/core/common/pref_names.h"
25 #include "components/pref_registry/pref_registry_syncable.h" 27 #include "components/pref_registry/pref_registry_syncable.h"
26 28
27 namespace { 29 namespace {
28 30
31 //typedef std::pair<std::string, std::string> StringPair;
32
33 const char kPerPluginPrefName[] = "per_plugin";
34
35 // If the given content type supports resource identifiers in user preferences,
36 // returns true and sets |pref_key| to the key in the content settings
37 // dictionary under which per-resource content settings are stored.
38 // Otherwise, returns false.
39 bool GetResourceTypeName(ContentSettingsType content_type,
40 std::string* pref_key) {
41 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) {
42 *pref_key = kPerPluginPrefName;
43 return true;
44 }
45 return false;
46 }
47
48 ContentSetting FixObsoleteCookiePromptMode(ContentSettingsType content_type,
49 ContentSetting setting) {
50 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES &&
51 setting == CONTENT_SETTING_ASK) {
52 return CONTENT_SETTING_BLOCK;
53 }
54 return setting;
55 }
56
29 const char kAudioKey[] = "audio"; 57 const char kAudioKey[] = "audio";
30 const char kVideoKey[] = "video"; 58 const char kVideoKey[] = "video";
31 59
60 const char* kContentSettingsExceptionsPrefs[] = {
61 prefs::kContentSettingsCookiesPatternPairs,
62 prefs::kContentSettingsImagesPatternPairs,
63 prefs::kContentSettingsJavaScriptPatternPairs,
64 prefs::kContentSettingsPluginsPatternPairs,
65 prefs::kContentSettingsPopupsPatternPairs,
66 prefs::kContentSettingsGeolocationPatternPairs,
67 prefs::kContentSettingsNotificationsPatternPairs,
68 prefs::kContentSettingsAutoSelectCertificatePatternPairs,
69 prefs::kContentSettingsFullScreenPatternPairs,
70 prefs::kContentSettingsMouseLockPatternPairs,
71 prefs::kContentSettingsMixedScriptPatternPairs,
72 prefs::kContentSettingsMediaStreamPatternPairs,
73 prefs::kContentSettingsMediaStreamMicPatternPairs,
74 prefs::kContentSettingsMediaStreamCameraPatternPairs,
75 prefs::kContentSettingsProtocolHandlersPatternPairs,
76 prefs::kContentSettingsPpapiBrokerPatternPairs,
77 prefs::kContentSettingsAutomaticDownloadsPatternPairs,
78 prefs::kContentSettingsMidiSysexPatternPairs,
79 prefs::kContentSettingsPushMessagingPatternPairs,
80 prefs::kContentSettingsSSLCertDecisionsPatternPairs,
81 #if defined(OS_WIN)
82 prefs::kContentSettingsMetroSwitchToDesktopPatternPairs,
83 #elif defined(OS_ANDROID) || defined(OS_CHROMEOS)
84 prefs::kContentSettingsProtectedMediaIdentifierPatternPairs,
85 #endif
86 prefs::kContentSettingsAppBannerPatternPairs
87 };
88 static_assert(arraysize(kContentSettingsExceptionsPrefs)
89 == CONTENT_SETTINGS_NUM_TYPES,
90 "kContentSettingsExceptionsPrefs should have "
91 "CONTENT_SETTINGS_NUM_TYPES elements");
92
32 } // namespace 93 } // namespace
33 94
34 namespace content_settings { 95 namespace content_settings {
35 96
36 // //////////////////////////////////////////////////////////////////////////// 97 // ////////////////////////////////////////////////////////////////////////////
37 // PrefProvider: 98 // PrefProvider:
38 // 99 //
39 100
40 // static 101 // static
41 void PrefProvider::RegisterProfilePrefs( 102 void PrefProvider::RegisterProfilePrefs(
42 user_prefs::PrefRegistrySyncable* registry) { 103 user_prefs::PrefRegistrySyncable* registry) {
43 registry->RegisterIntegerPref( 104 registry->RegisterIntegerPref(
44 prefs::kContentSettingsVersion, 105 prefs::kContentSettingsVersion,
45 ContentSettingsPattern::kContentSettingsPatternVersion, 106 ContentSettingsPattern::kContentSettingsPatternVersion,
46 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 107 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
47 registry->RegisterDictionaryPref( 108 registry->RegisterDictionaryPref(
48 prefs::kContentSettingsPatternPairs, 109 prefs::kContentSettingsPatternPairs,
49 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 110 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
111 registry->RegisterBooleanPref(
112 prefs::kContentSettingsPatternPairsMigrated,
113 false,
114 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
115
116 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
117 registry->RegisterDictionaryPref(
118 kContentSettingsExceptionsPrefs[i],
119 IsContentSettingsTypeSyncable(ContentSettingsType(i))
120 ? user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
121 : user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
122 );
50 } 123 }
51 124
52 PrefProvider::PrefProvider(PrefService* prefs, bool incognito) 125 PrefProvider::PrefProvider(PrefService* prefs, bool incognito)
53 : prefs_(prefs), 126 : prefs_(prefs),
54 clock_(new base::DefaultClock()) { 127 clock_(new base::DefaultClock()),
128 updating_old_preferences_(false) {
55 DCHECK(prefs_); 129 DCHECK(prefs_);
56 // Verify preferences version. 130 // Verify preferences version.
57 if (!prefs_->HasPrefPath(prefs::kContentSettingsVersion)) { 131 if (!prefs_->HasPrefPath(prefs::kContentSettingsVersion)) {
58 prefs_->SetInteger(prefs::kContentSettingsVersion, 132 prefs_->SetInteger(prefs::kContentSettingsVersion,
59 ContentSettingsPattern::kContentSettingsPatternVersion); 133 ContentSettingsPattern::kContentSettingsPatternVersion);
60 } 134 }
61 if (prefs_->GetInteger(prefs::kContentSettingsVersion) > 135 if (prefs_->GetInteger(prefs::kContentSettingsVersion) >
62 ContentSettingsPattern::kContentSettingsPatternVersion) { 136 ContentSettingsPattern::kContentSettingsPatternVersion) {
63 return; 137 return;
64 } 138 }
65 139
66 pref_change_registrar_.Init(prefs_); 140 pref_change_registrar_.Init(prefs_);
67 content_settings_pref_.reset(new ContentSettingsPref( 141
68 prefs_, &pref_change_registrar_, clock_.get(), incognito, 142 pref_change_registrar_.Add(prefs::kContentSettingsPatternPairs, base::Bind(
69 base::Bind(&PrefProvider::Notify, 143 &PrefProvider::OnOldContentSettingsPatternPairsChanged,
70 base::Unretained(this)))); 144 base::Unretained(this)));
145
146 content_settings_prefs_.resize(CONTENT_SETTINGS_NUM_TYPES);
147 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
148 content_settings_prefs_[i].reset(new ContentSettingsPref(
149 ContentSettingsType(i), prefs_, &pref_change_registrar_,
150 kContentSettingsExceptionsPrefs[i], incognito,
151 &updating_old_preferences_, base::Bind(&PrefProvider::Notify,
152 base::Unretained(this))));
153 }
154
155 ReadContentSettingsFromOldPref();
71 156
72 if (!incognito) { 157 if (!incognito) {
158 size_t num_exceptions = 0;
159 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
160 num_exceptions += content_settings_prefs_[i]->GetNumExceptions();
161
73 UMA_HISTOGRAM_COUNTS("ContentSettings.NumberOfExceptions", 162 UMA_HISTOGRAM_COUNTS("ContentSettings.NumberOfExceptions",
74 content_settings_pref_->GetNumExceptions()); 163 num_exceptions);
164
165 // Migrate all the exceptions from the aggregate dictionary preference
166 // to the separate dictionaries.
167 MigrateAllExceptions();
168
75 // Migrate the obsolete media content setting exceptions to the new 169 // Migrate the obsolete media content setting exceptions to the new
76 // settings. This needs to be done after ReadContentSettingsFromPref(). 170 // settings.
77 MigrateObsoleteMediaContentSetting(); 171 MigrateObsoleteMediaContentSetting();
78 } 172 }
173
79 } 174 }
80 175
81 PrefProvider::~PrefProvider() { 176 PrefProvider::~PrefProvider() {
82 DCHECK(!prefs_); 177 DCHECK(!prefs_);
83 } 178 }
84 179
85 RuleIterator* PrefProvider::GetRuleIterator( 180 RuleIterator* PrefProvider::GetRuleIterator(
86 ContentSettingsType content_type, 181 ContentSettingsType content_type,
87 const ResourceIdentifier& resource_identifier, 182 const ResourceIdentifier& resource_identifier,
88 bool incognito) const { 183 bool incognito) const {
89 return content_settings_pref_->GetRuleIterator(content_type, 184 return content_settings_prefs_[content_type]->GetRuleIterator(
90 resource_identifier, 185 resource_identifier,
91 incognito); 186 incognito);
92 } 187 }
93 188
94 bool PrefProvider::SetWebsiteSetting( 189 bool PrefProvider::SetWebsiteSetting(
95 const ContentSettingsPattern& primary_pattern, 190 const ContentSettingsPattern& primary_pattern,
96 const ContentSettingsPattern& secondary_pattern, 191 const ContentSettingsPattern& secondary_pattern,
97 ContentSettingsType content_type, 192 ContentSettingsType content_type,
98 const ResourceIdentifier& resource_identifier, 193 const ResourceIdentifier& resource_identifier,
99 base::Value* in_value) { 194 base::Value* in_value) {
100 DCHECK(CalledOnValidThread()); 195 DCHECK(CalledOnValidThread());
101 DCHECK(prefs_); 196 DCHECK(prefs_);
102 197
103 return content_settings_pref_->SetWebsiteSetting(primary_pattern, 198 // Default settings are set using a wildcard pattern for both
104 secondary_pattern, 199 // |primary_pattern| and |secondary_pattern|. Don't store default settings in
105 content_type, 200 // the |PrefProvider|. The |PrefProvider| handles settings for specific
106 resource_identifier, 201 // sites/origins defined by the |primary_pattern| and the |secondary_pattern|.
107 in_value); 202 // Default settings are handled by the |DefaultProvider|.
203 if (primary_pattern == ContentSettingsPattern::Wildcard() &&
204 secondary_pattern == ContentSettingsPattern::Wildcard() &&
205 resource_identifier.empty()) {
206 return false;
207 }
208
209 return content_settings_prefs_[content_type]->SetWebsiteSetting(
210 primary_pattern,
211 secondary_pattern,
212 resource_identifier,
213 in_value);
108 } 214 }
109 215
110 void PrefProvider::ClearAllContentSettingsRules( 216 void PrefProvider::ClearAllContentSettingsRules(
111 ContentSettingsType content_type) { 217 ContentSettingsType content_type) {
112 DCHECK(CalledOnValidThread()); 218 DCHECK(CalledOnValidThread());
113 DCHECK(prefs_); 219 DCHECK(prefs_);
114 220
115 content_settings_pref_->ClearAllContentSettingsRules(content_type); 221 content_settings_prefs_[content_type]->ClearAllContentSettingsRules();
116 } 222 }
117 223
118 void PrefProvider::ShutdownOnUIThread() { 224 void PrefProvider::ShutdownOnUIThread() {
119 DCHECK(CalledOnValidThread()); 225 DCHECK(CalledOnValidThread());
120 DCHECK(prefs_); 226 DCHECK(prefs_);
121 RemoveAllObservers(); 227 RemoveAllObservers();
122 pref_change_registrar_.RemoveAll(); 228 pref_change_registrar_.RemoveAll();
123 prefs_ = NULL; 229 prefs_ = NULL;
124 } 230 }
125 231
126 void PrefProvider::UpdateLastUsage( 232 void PrefProvider::UpdateLastUsage(
127 const ContentSettingsPattern& primary_pattern, 233 const ContentSettingsPattern& primary_pattern,
128 const ContentSettingsPattern& secondary_pattern, 234 const ContentSettingsPattern& secondary_pattern,
129 ContentSettingsType content_type) { 235 ContentSettingsType content_type) {
130 content_settings_pref_->UpdateLastUsage(primary_pattern, 236 content_settings_prefs_[content_type]->UpdateLastUsage(primary_pattern,
131 secondary_pattern, 237 secondary_pattern,
132 content_type); 238 clock_.get());
133 } 239 }
134 240
135 base::Time PrefProvider::GetLastUsage( 241 base::Time PrefProvider::GetLastUsage(
136 const ContentSettingsPattern& primary_pattern, 242 const ContentSettingsPattern& primary_pattern,
137 const ContentSettingsPattern& secondary_pattern, 243 const ContentSettingsPattern& secondary_pattern,
138 ContentSettingsType content_type) { 244 ContentSettingsType content_type) {
139 return content_settings_pref_->GetLastUsage(primary_pattern, 245 return content_settings_prefs_[content_type]->GetLastUsage(primary_pattern,
140 secondary_pattern, 246 secondary_pattern);
141 content_type);
142 } 247 }
143 248
144 // //////////////////////////////////////////////////////////////////////////// 249 // ////////////////////////////////////////////////////////////////////////////
145 // Private 250 // Private
146 251
147 void PrefProvider::MigrateObsoleteMediaContentSetting() { 252 void PrefProvider::MigrateObsoleteMediaContentSetting() {
148 std::vector<Rule> rules_to_delete; 253 std::vector<Rule> rules_to_delete;
149 { 254 {
150 scoped_ptr<RuleIterator> rule_iterator(GetRuleIterator( 255 scoped_ptr<RuleIterator> rule_iterator(GetRuleIterator(
151 CONTENT_SETTINGS_TYPE_MEDIASTREAM, std::string(), false)); 256 CONTENT_SETTINGS_TYPE_MEDIASTREAM, std::string(), false));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const ContentSettingsPattern& primary_pattern, 303 const ContentSettingsPattern& primary_pattern,
199 const ContentSettingsPattern& secondary_pattern, 304 const ContentSettingsPattern& secondary_pattern,
200 ContentSettingsType content_type, 305 ContentSettingsType content_type,
201 const std::string& resource_identifier) { 306 const std::string& resource_identifier) {
202 NotifyObservers(primary_pattern, 307 NotifyObservers(primary_pattern,
203 secondary_pattern, 308 secondary_pattern,
204 content_type, 309 content_type,
205 resource_identifier); 310 resource_identifier);
206 } 311 }
207 312
313 void PrefProvider::ReadContentSettingsFromOldPref() {
314 // |DictionaryPrefUpdate| sends out notifications when destructed. This
315 // construction order ensures |AutoLock| gets destroyed first and |old_lock_|
316 // is not held when the notifications are sent. Also, |auto_reset| must be
317 // still valid when the notifications are sent, so that |Observe| skips the
318 // notification.
319 base::AutoReset<bool> auto_reset(&updating_old_preferences_, true);
320 DictionaryPrefUpdate update(prefs_, prefs::kContentSettingsPatternPairs);
321
322 const base::DictionaryValue* all_settings_dictionary =
323 prefs_->GetDictionary(prefs::kContentSettingsPatternPairs);
324
325 old_value_map_.clear();
326
327 // Careful: The returned value could be NULL if the pref has never been set.
328 if (!all_settings_dictionary)
329 return;
330
331 base::DictionaryValue* mutable_settings;
332 scoped_ptr<base::DictionaryValue> mutable_settings_scope;
333
334 if (!is_incognito_) {
335 mutable_settings = update.Get();
336 } else {
337 // Create copy as we do not want to persist anything in OTR prefs.
338 mutable_settings = all_settings_dictionary->DeepCopy();
339 mutable_settings_scope.reset(mutable_settings);
340 }
341 // Convert all Unicode patterns into punycode form, then read.
342 ContentSettingsPref::CanonicalizeContentSettingsExceptions(mutable_settings);
343
344 for (base::DictionaryValue::Iterator i(*mutable_settings); !i.IsAtEnd();
345 i.Advance()) {
346 const std::string& pattern_str(i.key());
347 std::pair<ContentSettingsPattern, ContentSettingsPattern> pattern_pair =
348 ParsePatternString(pattern_str);
349 if (!pattern_pair.first.IsValid() ||
350 !pattern_pair.second.IsValid()) {
351 // TODO: Change this to DFATAL when crbug.com/132659 is fixed.
352 LOG(ERROR) << "Invalid pattern strings: " << pattern_str;
353 continue;
354 }
355
356 // Get settings dictionary for the current pattern string, and read
357 // settings from the dictionary.
358 const base::DictionaryValue* settings_dictionary = NULL;
359 bool is_dictionary = i.value().GetAsDictionary(&settings_dictionary);
360 DCHECK(is_dictionary);
361
362 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
363 ContentSettingsType content_type = static_cast<ContentSettingsType>(i);
364
365 std::string res_dictionary_path;
366 if (GetResourceTypeName(content_type, &res_dictionary_path)) {
367 const base::DictionaryValue* resource_dictionary = NULL;
368 if (settings_dictionary->GetDictionary(
369 res_dictionary_path, &resource_dictionary)) {
370 for (base::DictionaryValue::Iterator j(*resource_dictionary);
371 !j.IsAtEnd();
372 j.Advance()) {
373 const std::string& resource_identifier(j.key());
374 int setting = CONTENT_SETTING_DEFAULT;
375 bool is_integer = j.value().GetAsInteger(&setting);
376 DCHECK(is_integer);
377 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
378 old_value_map_[content_type].push_back(
379 (ContentSettingsPrefEntry){
380 pattern_pair.first,
381 pattern_pair.second,
382 resource_identifier,
383 make_scoped_ptr(new base::FundamentalValue(setting))});
384 }
385 }
386 }
387 base::Value* value = NULL;
388 if (HostContentSettingsMap::ContentTypeHasCompoundValue(content_type)) {
389 const base::DictionaryValue* setting = NULL;
390 // TODO(xians): Handle the non-dictionary types.
391 if (settings_dictionary->GetDictionaryWithoutPathExpansion(
392 GetTypeName(ContentSettingsType(i)), &setting)) {
393 DCHECK(!setting->empty());
394 value = setting->DeepCopy();
395 }
396 } else {
397 int setting = CONTENT_SETTING_DEFAULT;
398 if (settings_dictionary->GetIntegerWithoutPathExpansion(
399 GetTypeName(ContentSettingsType(i)), &setting)) {
400 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
401 setting = FixObsoleteCookiePromptMode(content_type,
402 ContentSetting(setting));
403 value = new base::FundamentalValue(setting);
404 }
405 }
406
407 // |old_value_map_| will take the ownership of |value|.
408 if (value != NULL) {
409 old_value_map_[content_type].push_back(
410 (ContentSettingsPrefEntry){
411 pattern_pair.first,
412 pattern_pair.second,
413 ResourceIdentifier(),
414 make_scoped_ptr(value)});
415 }
416 }
417 }
418 }
419
420 void PrefProvider::WriteSettingsToNewPreferences(bool syncable_only) {
421 if (updating_old_preferences_)
422 return;
423
424 base::AutoReset<bool> auto_reset(&updating_old_preferences_, true);
425
426 ReadContentSettingsFromOldPref();
427
428 for (ContentSettingsPrefEntryMap::iterator it = old_value_map_.begin();
429 it != old_value_map_.end(); ++it) {
430 ContentSettingsType content_type = it->first;
431 if (syncable_only && !IsContentSettingsTypeSyncable(content_type))
432 return;
433
434 std::vector<ContentSettingsPrefEntry>& entries = it->second;
435
436 content_settings_prefs_[content_type]->ClearAllContentSettingsRules();
437
438 for (size_t i = 0; i < entries.size(); ++i) {
msramek 2015/03/24 15:11:45 This for-cycle migrates exceptions one by one. Unl
msramek 2015/03/25 11:58:50 I tried this out with 1000 exceptions and the migr
439 content_settings_prefs_[content_type]->SetWebsiteSetting(
440 entries[i].primary_pattern,
441 entries[i].secondary_pattern,
442 entries[i].resource_identifier,
443 entries[i].value->DeepCopy());
444 }
445 }
446
447 old_value_map_.clear();
448 }
449
450 void PrefProvider::OnOldContentSettingsPatternPairsChanged() {
451 DCHECK(thread_checker_.CalledOnValidThread());
452
453 WriteSettingsToNewPreferences(true);
454 }
455
456 void PrefProvider::MigrateAllExceptions() {
457 if (prefs_->GetBoolean(prefs::kContentSettingsPatternPairsMigrated))
458 return;
459 WriteSettingsToNewPreferences(false);
460
461 // Protected media identifier settings should be reset during the migration.
462 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
463 content_settings_prefs_[CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER]->
464 ClearAllContentSettingsRules();
465 #endif
466
467 prefs_->SetBoolean(prefs::kContentSettingsPatternPairsMigrated, true);
468 }
469
208 void PrefProvider::SetClockForTesting(scoped_ptr<base::Clock> clock) { 470 void PrefProvider::SetClockForTesting(scoped_ptr<base::Clock> clock) {
209 clock_ = clock.Pass(); 471 clock_ = clock.Pass();
210 content_settings_pref_->SetClockForTesting(clock_.get()); 472 }
473
474 bool PrefProvider::TestAllLocks() const {
475 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
476 if (!content_settings_prefs_[i]->lock_.Try())
477 return false;
478 content_settings_prefs_[i]->lock_.Release();
479 }
480 return true;
211 } 481 }
212 482
213 } // namespace content_settings 483 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698