| OLD | NEW |
| 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/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 custom_extension_provider; | 126 custom_extension_provider; |
| 127 | 127 |
| 128 #ifndef NDEBUG | 128 #ifndef NDEBUG |
| 129 DCHECK(used_from_thread_id_ != base::kInvalidThreadId) | 129 DCHECK(used_from_thread_id_ != base::kInvalidThreadId) |
| 130 << "Used from multiple threads before initialization complete."; | 130 << "Used from multiple threads before initialization complete."; |
| 131 #endif | 131 #endif |
| 132 | 132 |
| 133 OnContentSettingChanged(ContentSettingsPattern(), | 133 OnContentSettingChanged(ContentSettingsPattern(), |
| 134 ContentSettingsPattern(), | 134 ContentSettingsPattern(), |
| 135 CONTENT_SETTINGS_TYPE_DEFAULT, | 135 CONTENT_SETTINGS_TYPE_DEFAULT, |
| 136 ""); | 136 std::string()); |
| 137 } | 137 } |
| 138 #endif | 138 #endif |
| 139 | 139 |
| 140 // static | 140 // static |
| 141 void HostContentSettingsMap::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 141 void HostContentSettingsMap::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 142 registry->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, | 142 registry->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, |
| 143 0, | 143 0, |
| 144 PrefRegistrySyncable::UNSYNCABLE_PREF); | 144 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 145 registry->RegisterIntegerPref(prefs::kContentSettingsDefaultWhitelistVersion, | 145 registry->RegisterIntegerPref(prefs::kContentSettingsDefaultWhitelistVersion, |
| 146 0, | 146 0, |
| 147 PrefRegistrySyncable::SYNCABLE_PREF); | 147 PrefRegistrySyncable::SYNCABLE_PREF); |
| 148 registry->RegisterBooleanPref(prefs::kContentSettingsClearOnExitMigrated, | 148 registry->RegisterBooleanPref(prefs::kContentSettingsClearOnExitMigrated, |
| 149 false, | 149 false, |
| 150 PrefRegistrySyncable::SYNCABLE_PREF); | 150 PrefRegistrySyncable::SYNCABLE_PREF); |
| 151 | 151 |
| 152 // Register the prefs for the content settings providers. | 152 // Register the prefs for the content settings providers. |
| 153 content_settings::DefaultProvider::RegisterUserPrefs(registry); | 153 content_settings::DefaultProvider::RegisterUserPrefs(registry); |
| 154 content_settings::PrefProvider::RegisterUserPrefs(registry); | 154 content_settings::PrefProvider::RegisterUserPrefs(registry); |
| 155 content_settings::PolicyProvider::RegisterUserPrefs(registry); | 155 content_settings::PolicyProvider::RegisterUserPrefs(registry); |
| 156 } | 156 } |
| 157 | 157 |
| 158 ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider( | 158 ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider( |
| 159 ContentSettingsType content_type, | 159 ContentSettingsType content_type, |
| 160 content_settings::ProviderInterface* provider) const { | 160 content_settings::ProviderInterface* provider) const { |
| 161 scoped_ptr<content_settings::RuleIterator> rule_iterator( | 161 scoped_ptr<content_settings::RuleIterator> rule_iterator( |
| 162 provider->GetRuleIterator(content_type, "", false)); | 162 provider->GetRuleIterator(content_type, std::string(), false)); |
| 163 | 163 |
| 164 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); | 164 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
| 165 while (rule_iterator->HasNext()) { | 165 while (rule_iterator->HasNext()) { |
| 166 content_settings::Rule rule = rule_iterator->Next(); | 166 content_settings::Rule rule = rule_iterator->Next(); |
| 167 if (rule.primary_pattern == wildcard && | 167 if (rule.primary_pattern == wildcard && |
| 168 rule.secondary_pattern == wildcard) { | 168 rule.secondary_pattern == wildcard) { |
| 169 return content_settings::ValueToContentSetting(rule.value.get()); | 169 return content_settings::ValueToContentSetting(rule.value.get()); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 return CONTENT_SETTING_DEFAULT; | 172 return CONTENT_SETTING_DEFAULT; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 if (default_setting == CONTENT_SETTING_ALLOW) { | 453 if (default_setting == CONTENT_SETTING_ALLOW) { |
| 454 SetDefaultContentSetting( | 454 SetDefaultContentSetting( |
| 455 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_SESSION_ONLY); | 455 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_SESSION_ONLY); |
| 456 } | 456 } |
| 457 | 457 |
| 458 // Change the exceptions using the same rules. | 458 // Change the exceptions using the same rules. |
| 459 ContentSettingsForOneType exceptions; | 459 ContentSettingsForOneType exceptions; |
| 460 AddSettingsForOneType(content_settings_providers_[PREF_PROVIDER], | 460 AddSettingsForOneType(content_settings_providers_[PREF_PROVIDER], |
| 461 PREF_PROVIDER, | 461 PREF_PROVIDER, |
| 462 CONTENT_SETTINGS_TYPE_COOKIES, | 462 CONTENT_SETTINGS_TYPE_COOKIES, |
| 463 "", | 463 std::string(), |
| 464 &exceptions, | 464 &exceptions, |
| 465 false); | 465 false); |
| 466 for (ContentSettingsForOneType::iterator it = exceptions.begin(); | 466 for (ContentSettingsForOneType::iterator it = exceptions.begin(); |
| 467 it != exceptions.end(); ++it) { | 467 it != exceptions.end(); ++it) { |
| 468 if (it->setting != CONTENT_SETTING_ALLOW) | 468 if (it->setting != CONTENT_SETTING_ALLOW) |
| 469 continue; | 469 continue; |
| 470 SetWebsiteSetting( | 470 SetWebsiteSetting(it->primary_pattern, |
| 471 it->primary_pattern, | 471 it->secondary_pattern, |
| 472 it->secondary_pattern, | 472 CONTENT_SETTINGS_TYPE_COOKIES, |
| 473 CONTENT_SETTINGS_TYPE_COOKIES, | 473 std::string(), |
| 474 "", | 474 Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY)); |
| 475 Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY)); | |
| 476 } | 475 } |
| 477 | 476 |
| 478 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); | 477 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); |
| 479 } | 478 } |
| 480 | 479 |
| 481 void HostContentSettingsMap::AddSettingsForOneType( | 480 void HostContentSettingsMap::AddSettingsForOneType( |
| 482 const content_settings::ProviderInterface* provider, | 481 const content_settings::ProviderInterface* provider, |
| 483 ProviderType provider_type, | 482 ProviderType provider_type, |
| 484 ContentSettingsType content_type, | 483 ContentSettingsType content_type, |
| 485 const std::string& resource_identifier, | 484 const std::string& resource_identifier, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 HostContentSettingsMap::GetProviderTypeFromSource( | 598 HostContentSettingsMap::GetProviderTypeFromSource( |
| 600 const std::string& source) { | 599 const std::string& source) { |
| 601 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { | 600 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { |
| 602 if (source == kProviderNames[i]) | 601 if (source == kProviderNames[i]) |
| 603 return static_cast<ProviderType>(i); | 602 return static_cast<ProviderType>(i); |
| 604 } | 603 } |
| 605 | 604 |
| 606 NOTREACHED(); | 605 NOTREACHED(); |
| 607 return DEFAULT_PROVIDER; | 606 return DEFAULT_PROVIDER; |
| 608 } | 607 } |
| OLD | NEW |