| 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/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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 // The method GetDefaultContentSetting always has to return an explicit | 159 // The method GetDefaultContentSetting always has to return an explicit |
| 160 // value that is to be used as default. We here rely on the | 160 // value that is to be used as default. We here rely on the |
| 161 // DefaultProvider to always provide a value. | 161 // DefaultProvider to always provide a value. |
| 162 NOTREACHED(); | 162 NOTREACHED(); |
| 163 return CONTENT_SETTING_DEFAULT; | 163 return CONTENT_SETTING_DEFAULT; |
| 164 } | 164 } |
| 165 | 165 |
| 166 ContentSettings HostContentSettingsMap::GetDefaultContentSettings() const { | |
| 167 ContentSettings output(CONTENT_SETTING_DEFAULT); | |
| 168 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | |
| 169 if (!ContentTypeHasCompoundValue(ContentSettingsType(i))) | |
| 170 output.settings[i] = GetDefaultContentSetting(ContentSettingsType(i), | |
| 171 NULL); | |
| 172 } | |
| 173 return output; | |
| 174 } | |
| 175 | |
| 176 ContentSetting HostContentSettingsMap::GetContentSetting( | 166 ContentSetting HostContentSettingsMap::GetContentSetting( |
| 177 const GURL& primary_url, | 167 const GURL& primary_url, |
| 178 const GURL& secondary_url, | 168 const GURL& secondary_url, |
| 179 ContentSettingsType content_type, | 169 ContentSettingsType content_type, |
| 180 const std::string& resource_identifier) const { | 170 const std::string& resource_identifier) const { |
| 181 scoped_ptr<base::Value> value(GetWebsiteSetting( | 171 scoped_ptr<base::Value> value(GetWebsiteSetting( |
| 182 primary_url, secondary_url, content_type, resource_identifier, NULL)); | 172 primary_url, secondary_url, content_type, resource_identifier, NULL)); |
| 183 return content_settings::ValueToContentSetting(value.get()); | 173 return content_settings::ValueToContentSetting(value.get()); |
| 184 } | 174 } |
| 185 | 175 |
| 186 ContentSettings HostContentSettingsMap::GetContentSettings( | |
| 187 const GURL& primary_url) const { | |
| 188 ContentSettings output; | |
| 189 // If we require a resource identifier, set the content settings to default, | |
| 190 // otherwise make the defaults explicit. Values for content type | |
| 191 // CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE can't be mapped to the type | |
| 192 // |ContentSetting|. So we ignore them here. | |
| 193 for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) { | |
| 194 ContentSettingsType type = ContentSettingsType(j); | |
| 195 if (!ContentTypeHasCompoundValue(type)) { | |
| 196 output.settings[j] = GetContentSetting( | |
| 197 primary_url, primary_url, ContentSettingsType(j), std::string()); | |
| 198 } | |
| 199 } | |
| 200 return output; | |
| 201 } | |
| 202 | |
| 203 void HostContentSettingsMap::GetSettingsForOneType( | 176 void HostContentSettingsMap::GetSettingsForOneType( |
| 204 ContentSettingsType content_type, | 177 ContentSettingsType content_type, |
| 205 const std::string& resource_identifier, | 178 const std::string& resource_identifier, |
| 206 ContentSettingsForOneType* settings) const { | 179 ContentSettingsForOneType* settings) const { |
| 207 DCHECK(content_settings::SupportsResourceIdentifier(content_type) || | 180 DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| 208 resource_identifier.empty()); | 181 resource_identifier.empty()); |
| 209 DCHECK(settings); | 182 DCHECK(settings); |
| 210 | 183 |
| 211 settings->clear(); | 184 settings->clear(); |
| 212 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 185 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 417 } |
| 445 } | 418 } |
| 446 | 419 |
| 447 if (info) { | 420 if (info) { |
| 448 info->source = content_settings::SETTING_SOURCE_NONE; | 421 info->source = content_settings::SETTING_SOURCE_NONE; |
| 449 info->primary_pattern = ContentSettingsPattern(); | 422 info->primary_pattern = ContentSettingsPattern(); |
| 450 info->secondary_pattern = ContentSettingsPattern(); | 423 info->secondary_pattern = ContentSettingsPattern(); |
| 451 } | 424 } |
| 452 return NULL; | 425 return NULL; |
| 453 } | 426 } |
| OLD | NEW |