Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.h" | 5 #include "components/content_settings/core/browser/content_settings_pref.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
| 14 #include "components/content_settings/core/browser/content_settings_registry.h" | |
| 14 #include "components/content_settings/core/browser/content_settings_rule.h" | 15 #include "components/content_settings/core/browser/content_settings_rule.h" |
| 15 #include "components/content_settings/core/browser/content_settings_utils.h" | 16 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 17 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 17 #include "components/content_settings/core/common/content_settings.h" | 18 #include "components/content_settings/core/common/content_settings.h" |
| 18 #include "components/content_settings/core/common/content_settings_pattern.h" | 19 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 19 #include "components/content_settings/core/common/pref_names.h" | 20 #include "components/content_settings/core/common/pref_names.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 new base::FundamentalValue(setting)); | 302 new base::FundamentalValue(setting)); |
| 302 value_map_.SetValue(pattern_pair.first, | 303 value_map_.SetValue(pattern_pair.first, |
| 303 pattern_pair.second, | 304 pattern_pair.second, |
| 304 content_type_, | 305 content_type_, |
| 305 resource_identifier, | 306 resource_identifier, |
| 306 setting_ptr->DeepCopy()); | 307 setting_ptr->DeepCopy()); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 } | 310 } |
| 310 base::Value* value = NULL; | 311 base::Value* value = NULL; |
| 311 if (HostContentSettingsMap::ContentTypeHasCompoundValue(content_type_)) { | 312 if (ContentSettingsRegistry::GetInstance()->Get(content_type_)) { |
| 312 const base::DictionaryValue* setting = NULL; | |
| 313 // TODO(xians): Handle the non-dictionary types. | |
| 314 if (settings_dictionary->GetDictionaryWithoutPathExpansion( | |
| 315 kSettingPath, &setting)) { | |
| 316 DCHECK(!setting->empty()); | |
| 317 value = setting->DeepCopy(); | |
| 318 } | |
| 319 } else { | |
| 320 int setting = CONTENT_SETTING_DEFAULT; | 313 int setting = CONTENT_SETTING_DEFAULT; |
| 321 if (settings_dictionary->GetIntegerWithoutPathExpansion( | 314 if (settings_dictionary->GetIntegerWithoutPathExpansion( |
| 322 kSettingPath, &setting)) { | 315 kSettingPath, &setting)) { |
| 323 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); | 316 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); |
| 324 setting = FixObsoleteCookiePromptMode(content_type_, | 317 setting = FixObsoleteCookiePromptMode(content_type_, |
|
Bernhard Bauer
2015/09/23 11:30:37
Actually, we can probably get rid of this migratio
raymes
2015/09/24 03:07:51
Let me know if I did what you were thinking :)
O
Bernhard Bauer
2015/09/24 08:48:26
CONTENT_SETTING_DEFAULT is useful for interfaces t
raymes
2015/09/28 06:45:23
Sounds good. I've left the behavior as it is for n
| |
| 325 ContentSetting(setting)); | 318 ContentSetting(setting)); |
| 326 value = new base::FundamentalValue(setting); | 319 value = new base::FundamentalValue(setting); |
| 327 } | 320 } |
| 321 } else { | |
| 322 const base::DictionaryValue* setting = NULL; | |
| 323 // TODO(xians): Handle the non-dictionary types. | |
| 324 if (settings_dictionary->GetDictionaryWithoutPathExpansion(kSettingPath, | |
| 325 &setting)) { | |
| 326 DCHECK(!setting->empty()); | |
| 327 value = setting->DeepCopy(); | |
| 328 } | |
| 328 } | 329 } |
| 329 | 330 |
| 330 if (value != NULL) { | 331 if (value != NULL) { |
| 331 scoped_ptr<base::Value> value_ptr(value); | 332 scoped_ptr<base::Value> value_ptr(value); |
| 332 value_map_.SetValue(pattern_pair.first, | 333 value_map_.SetValue(pattern_pair.first, |
| 333 pattern_pair.second, | 334 pattern_pair.second, |
| 334 content_type_, | 335 content_type_, |
| 335 ResourceIdentifier(), | 336 ResourceIdentifier(), |
| 336 value->DeepCopy()); | 337 value->DeepCopy()); |
| 337 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) { | 338 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 | 509 |
| 509 void ContentSettingsPref::AssertLockNotHeld() const { | 510 void ContentSettingsPref::AssertLockNotHeld() const { |
| 510 #if !defined(NDEBUG) | 511 #if !defined(NDEBUG) |
| 511 // |Lock::Acquire()| will assert if the lock is held by this thread. | 512 // |Lock::Acquire()| will assert if the lock is held by this thread. |
| 512 lock_.Acquire(); | 513 lock_.Acquire(); |
| 513 lock_.Release(); | 514 lock_.Release(); |
| 514 #endif | 515 #endif |
| 515 } | 516 } |
| 516 | 517 |
| 517 } // namespace content_settings | 518 } // namespace content_settings |
| OLD | NEW |