| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_default_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 namespace content_settings { | 51 namespace content_settings { |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 class DefaultRuleIterator : public RuleIterator { | 55 class DefaultRuleIterator : public RuleIterator { |
| 56 public: | 56 public: |
| 57 explicit DefaultRuleIterator(const base::Value* value) { | 57 explicit DefaultRuleIterator(const base::Value* value) { |
| 58 value_.reset(value->DeepCopy()); | 58 if (value) |
| 59 value_.reset(value->DeepCopy()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 bool HasNext() const { | 62 bool HasNext() const { |
| 62 return value_.get() != NULL; | 63 return value_.get() != NULL; |
| 63 } | 64 } |
| 64 | 65 |
| 65 Rule Next() { | 66 Rule Next() { |
| 66 DCHECK(value_.get()); | 67 DCHECK(value_.get()); |
| 67 return Rule(ContentSettingsPattern::Wildcard(), | 68 return Rule(ContentSettingsPattern::Wildcard(), |
| 68 ContentSettingsPattern::Wildcard(), | 69 ContentSettingsPattern::Wildcard(), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // Careful: The returned value could be NULL if the pref has never been set. | 310 // Careful: The returned value could be NULL if the pref has never been set. |
| 310 if (default_settings_dictionary) | 311 if (default_settings_dictionary) |
| 311 GetSettingsFromDictionary(default_settings_dictionary); | 312 GetSettingsFromDictionary(default_settings_dictionary); |
| 312 | 313 |
| 313 ForceDefaultsToBeExplicit(); | 314 ForceDefaultsToBeExplicit(); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void DefaultProvider::ForceDefaultsToBeExplicit() { | 317 void DefaultProvider::ForceDefaultsToBeExplicit() { |
| 317 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 318 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 318 ContentSettingsType type = ContentSettingsType(i); | 319 ContentSettingsType type = ContentSettingsType(i); |
| 319 if (!default_settings_[type].get()) | 320 if (!default_settings_[type].get() && |
| 321 kDefaultSettings[i] != CONTENT_SETTING_DEFAULT) { |
| 320 default_settings_[type].reset( | 322 default_settings_[type].reset( |
| 321 Value::CreateIntegerValue(kDefaultSettings[i])); | 323 Value::CreateIntegerValue(kDefaultSettings[i])); |
| 324 } |
| 322 } | 325 } |
| 323 } | 326 } |
| 324 | 327 |
| 325 void DefaultProvider::GetSettingsFromDictionary( | 328 void DefaultProvider::GetSettingsFromDictionary( |
| 326 const DictionaryValue* dictionary) { | 329 const DictionaryValue* dictionary) { |
| 327 for (DictionaryValue::key_iterator i(dictionary->begin_keys()); | 330 for (DictionaryValue::key_iterator i(dictionary->begin_keys()); |
| 328 i != dictionary->end_keys(); ++i) { | 331 i != dictionary->end_keys(); ++i) { |
| 329 const std::string& content_type(*i); | 332 const std::string& content_type(*i); |
| 330 for (size_t type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 333 for (size_t type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) { |
| 331 if (content_type == GetTypeName(ContentSettingsType(type))) { | 334 if (content_type == GetTypeName(ContentSettingsType(type))) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 SetWebsiteSetting( | 385 SetWebsiteSetting( |
| 383 ContentSettingsPattern::Wildcard(), | 386 ContentSettingsPattern::Wildcard(), |
| 384 ContentSettingsPattern::Wildcard(), | 387 ContentSettingsPattern::Wildcard(), |
| 385 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 388 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 386 std::string(), | 389 std::string(), |
| 387 value->DeepCopy()); | 390 value->DeepCopy()); |
| 388 } | 391 } |
| 389 } | 392 } |
| 390 | 393 |
| 391 } // namespace content_settings | 394 } // namespace content_settings |
| OLD | NEW |