Chromium Code Reviews| 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 "components/content_settings/core/browser/host_content_settings_map.h" | 5 #include "components/content_settings/core/browser/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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/clock.h" | 15 #include "base/time/clock.h" |
| 16 #include "components/content_settings/core/browser/content_settings_default_prov ider.h" | 16 #include "components/content_settings/core/browser/content_settings_default_prov ider.h" |
| 17 #include "components/content_settings/core/browser/content_settings_details.h" | 17 #include "components/content_settings/core/browser/content_settings_details.h" |
| 18 #include "components/content_settings/core/browser/content_settings_info.h" | 18 #include "components/content_settings/core/browser/content_settings_info.h" |
| 19 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h" | 19 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h" |
| 20 #include "components/content_settings/core/browser/content_settings_policy_provi der.h" | 20 #include "components/content_settings/core/browser/content_settings_policy_provi der.h" |
| 21 #include "components/content_settings/core/browser/content_settings_pref_provide r.h" | 21 #include "components/content_settings/core/browser/content_settings_pref_provide r.h" |
| 22 #include "components/content_settings/core/browser/content_settings_provider.h" | 22 #include "components/content_settings/core/browser/content_settings_provider.h" |
| 23 #include "components/content_settings/core/browser/content_settings_registry.h" | 23 #include "components/content_settings/core/browser/content_settings_registry.h" |
| 24 #include "components/content_settings/core/browser/content_settings_rule.h" | 24 #include "components/content_settings/core/browser/content_settings_rule.h" |
| 25 #include "components/content_settings/core/browser/content_settings_utils.h" | 25 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 26 #include "components/content_settings/core/browser/website_settings_info.h" | |
| 26 #include "components/content_settings/core/browser/website_settings_registry.h" | 27 #include "components/content_settings/core/browser/website_settings_registry.h" |
| 27 #include "components/content_settings/core/common/content_settings_pattern.h" | 28 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 28 #include "components/content_settings/core/common/pref_names.h" | 29 #include "components/content_settings/core/common/pref_names.h" |
| 29 #include "components/pref_registry/pref_registry_syncable.h" | 30 #include "components/pref_registry/pref_registry_syncable.h" |
| 30 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 31 #include "net/base/static_cookie_policy.h" | 32 #include "net/base/static_cookie_policy.h" |
| 32 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 rule.secondary_pattern == wildcard) { | 140 rule.secondary_pattern == wildcard) { |
| 140 return content_settings::ValueToContentSetting(rule.value.get()); | 141 return content_settings::ValueToContentSetting(rule.value.get()); |
| 141 } | 142 } |
| 142 } | 143 } |
| 143 return CONTENT_SETTING_DEFAULT; | 144 return CONTENT_SETTING_DEFAULT; |
| 144 } | 145 } |
| 145 | 146 |
| 146 ContentSetting HostContentSettingsMap::GetDefaultContentSetting( | 147 ContentSetting HostContentSettingsMap::GetDefaultContentSetting( |
| 147 ContentSettingsType content_type, | 148 ContentSettingsType content_type, |
| 148 std::string* provider_id) const { | 149 std::string* provider_id) const { |
| 150 using content_settings::WebsiteSettingsInfo; | |
|
msramek
2015/11/27 16:30:04
Nit: Is this allowed? I have seen it in tests and
raymes
2015/11/30 00:28:46
This was a suggestion from Michael. Either way is
johnme
2015/11/30 14:56:58
Done.
johnme
2015/11/30 14:56:58
Done.
| |
| 151 using content_settings::WebsiteSettingsRegistry; | |
| 149 UsedContentSettingsProviders(); | 152 UsedContentSettingsProviders(); |
| 150 | 153 |
| 154 const WebsiteSettingsRegistry* reg = WebsiteSettingsRegistry::GetInstance(); | |
| 155 bool do_not_inherit_allow = | |
| 156 is_off_the_record_ && | |
| 157 reg->Get(content_type)->incognito_behavior() | |
| 158 == WebsiteSettingsInfo::INHERIT_IN_INCOGNITO_EXCEPT_ALLOW; | |
| 159 | |
| 151 // Iterate through the list of providers and return the first non-NULL value | 160 // Iterate through the list of providers and return the first non-NULL value |
| 152 // that matches |primary_url| and |secondary_url|. | 161 // that matches |primary_url| and |secondary_url|. |
| 153 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 162 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| 154 provider != content_settings_providers_.end(); | 163 provider != content_settings_providers_.end(); |
| 155 ++provider) { | 164 ++provider) { |
| 156 if (provider->first == PREF_PROVIDER) | 165 if (provider->first == PREF_PROVIDER) |
| 157 continue; | 166 continue; |
| 158 ContentSetting default_setting = | 167 ContentSetting default_setting = |
| 159 GetDefaultContentSettingFromProvider(content_type, provider->second); | 168 GetDefaultContentSettingFromProvider(content_type, provider->second); |
| 169 if (do_not_inherit_allow && default_setting == CONTENT_SETTING_ALLOW) | |
| 170 default_setting = CONTENT_SETTING_ASK; | |
|
msramek
2015/11/27 16:30:04
DCHECK ContentSettingsInfo::IsSettingValid(ASK)
S
raymes
2015/11/30 00:28:46
+1
johnme
2015/11/30 14:56:58
Done.
johnme
2015/11/30 14:56:58
Done.
| |
| 160 if (default_setting != CONTENT_SETTING_DEFAULT) { | 171 if (default_setting != CONTENT_SETTING_DEFAULT) { |
| 161 if (provider_id) | 172 if (provider_id) |
| 162 *provider_id = kProviderNamesSourceMap[provider->first].provider_name; | 173 *provider_id = kProviderNamesSourceMap[provider->first].provider_name; |
| 163 return default_setting; | 174 return default_setting; |
| 164 } | 175 } |
| 165 } | 176 } |
| 166 | 177 |
| 167 return CONTENT_SETTING_DEFAULT; | 178 return CONTENT_SETTING_DEFAULT; |
| 168 } | 179 } |
| 169 | 180 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 primary_pattern = &info->primary_pattern; | 658 primary_pattern = &info->primary_pattern; |
| 648 secondary_pattern = &info->secondary_pattern; | 659 secondary_pattern = &info->secondary_pattern; |
| 649 } | 660 } |
| 650 | 661 |
| 651 // The list of |content_settings_providers_| is ordered according to their | 662 // The list of |content_settings_providers_| is ordered according to their |
| 652 // precedence. | 663 // precedence. |
| 653 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 664 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| 654 provider != content_settings_providers_.end(); | 665 provider != content_settings_providers_.end(); |
| 655 ++provider) { | 666 ++provider) { |
| 656 | 667 |
| 657 scoped_ptr<base::Value> value( | 668 scoped_ptr<base::Value> value = |
| 658 content_settings::GetContentSettingValueAndPatterns(provider->second, | 669 content_settings::GetContentSettingValueAndPatterns(provider->second, |
| 659 primary_url, | 670 primary_url, |
| 660 secondary_url, | 671 secondary_url, |
| 661 content_type, | 672 content_type, |
| 662 resource_identifier, | 673 resource_identifier, |
| 663 is_off_the_record_, | 674 is_off_the_record_, |
| 664 primary_pattern, | 675 primary_pattern, |
| 665 secondary_pattern)); | 676 secondary_pattern); |
| 666 if (value) { | 677 if (value) { |
| 667 if (info) | 678 if (info) |
| 668 info->source = kProviderNamesSourceMap[provider->first].provider_source; | 679 info->source = kProviderNamesSourceMap[provider->first].provider_source; |
| 669 return value.Pass(); | 680 return value.Pass(); |
| 670 } | 681 } |
| 671 } | 682 } |
| 672 | 683 |
| 673 if (info) { | 684 if (info) { |
| 674 info->source = content_settings::SETTING_SOURCE_NONE; | 685 info->source = content_settings::SETTING_SOURCE_NONE; |
| 675 info->primary_pattern = ContentSettingsPattern(); | 686 info->primary_pattern = ContentSettingsPattern(); |
| 676 info->secondary_pattern = ContentSettingsPattern(); | 687 info->secondary_pattern = ContentSettingsPattern(); |
| 677 } | 688 } |
| 678 return scoped_ptr<base::Value>(); | 689 return scoped_ptr<base::Value>(); |
| 679 } | 690 } |
| OLD | NEW |