Chromium Code Reviews| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 false); | 203 false); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void HostContentSettingsMap::SetDefaultContentSetting( | 207 void HostContentSettingsMap::SetDefaultContentSetting( |
| 208 ContentSettingsType content_type, | 208 ContentSettingsType content_type, |
| 209 ContentSetting setting) { | 209 ContentSetting setting) { |
| 210 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); | 210 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| 211 DCHECK(IsSettingAllowedForType(setting, content_type)); | 211 DCHECK(IsSettingAllowedForType(setting, content_type)); |
| 212 | 212 |
| 213 base::Value* value = Value::CreateIntegerValue(setting); | 213 base::Value* value = NULL; |
| 214 if (!content_settings_providers_[DEFAULT_PROVIDER]->SetWebsiteSetting( | 214 if (setting != CONTENT_SETTING_DEFAULT) |
| 215 ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), | 215 value = Value::CreateIntegerValue(setting); |
| 216 content_type, std::string(), value)) { | 216 SetWebsiteSetting( |
| 217 delete value; | 217 ContentSettingsPattern::Wildcard(), |
| 218 } | 218 ContentSettingsPattern::Wildcard(), |
| 219 content_type, | |
| 220 std::string(), | |
| 221 value); | |
|
Bernhard Bauer
2011/11/18 16:32:42
You should still check the return value for the ca
Bernhard Bauer
2011/11/18 16:44:44
Uh, disregard this, I thought that SetWebsiteSetti
| |
| 219 } | 222 } |
| 220 | 223 |
| 221 void HostContentSettingsMap::SetWebsiteSetting( | 224 void HostContentSettingsMap::SetWebsiteSetting( |
| 222 const ContentSettingsPattern& primary_pattern, | 225 const ContentSettingsPattern& primary_pattern, |
| 223 const ContentSettingsPattern& secondary_pattern, | 226 const ContentSettingsPattern& secondary_pattern, |
| 224 ContentSettingsType content_type, | 227 ContentSettingsType content_type, |
| 225 const std::string& resource_identifier, | 228 const std::string& resource_identifier, |
| 226 base::Value* value) { | 229 base::Value* value) { |
| 227 DCHECK(IsValueAllowedForType(value, content_type)); | 230 DCHECK(IsValueAllowedForType(value, content_type)); |
| 228 DCHECK(content_settings::SupportsResourceIdentifier(content_type) || | 231 DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| 229 resource_identifier.empty()); | 232 resource_identifier.empty()); |
| 230 for (ProviderIterator provider = content_settings_providers_.begin(); | 233 for (ProviderIterator provider = content_settings_providers_.begin(); |
| 231 provider != content_settings_providers_.end(); | 234 provider != content_settings_providers_.end(); |
| 232 ++provider) { | 235 ++provider) { |
| 233 if (provider->second->SetWebsiteSetting(primary_pattern, | 236 if (provider->second->SetWebsiteSetting(primary_pattern, |
| 234 secondary_pattern, | 237 secondary_pattern, |
| 235 content_type, | 238 content_type, |
| 236 resource_identifier, | 239 resource_identifier, |
| 237 value)) { | 240 value)) { |
| 238 return; | 241 return; |
| 239 } | 242 } |
| 240 } | 243 } |
| 244 // There should be at least one provider that accepts the ownership of the | |
|
James Hawkins
2011/11/18 16:39:44
Eh I'm not so sure about this. This falls under th
Bernhard Bauer
2011/11/18 16:44:44
Hm, but shouldn't the right way to catch this be a
James Hawkins
2011/11/18 16:53:40
Yes, you're right; however, my original complaint
markusheintz_
2011/11/18 17:01:18
The NOTREACHED is really not reached. I don't know
markusheintz_
2011/11/18 21:04:31
If you like we can change the NOTREACHED() to a CH
James Hawkins
2011/11/18 21:07:23
There's no need to change the NOTREACHED(). If it'
| |
| 245 // passed |value|. However if we would set a default setting on the incognito | |
| 246 // map the |DefaultProvider| would refuse to accept the setting. This should | |
| 247 // not happen that's why there is the NOTREACHED. However if it would happen, | |
| 248 // then we do not want to leak memory. Hence delete the |value|. | |
| 249 delete value; | |
| 241 NOTREACHED(); | 250 NOTREACHED(); |
| 242 } | 251 } |
| 243 | 252 |
| 244 void HostContentSettingsMap::SetContentSetting( | 253 void HostContentSettingsMap::SetContentSetting( |
| 245 const ContentSettingsPattern& primary_pattern, | 254 const ContentSettingsPattern& primary_pattern, |
| 246 const ContentSettingsPattern& secondary_pattern, | 255 const ContentSettingsPattern& secondary_pattern, |
| 247 ContentSettingsType content_type, | 256 ContentSettingsType content_type, |
| 248 const std::string& resource_identifier, | 257 const std::string& resource_identifier, |
| 249 ContentSetting setting) { | 258 ContentSetting setting) { |
| 250 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); | 259 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 } | 456 } |
| 448 } | 457 } |
| 449 | 458 |
| 450 if (info) { | 459 if (info) { |
| 451 info->source = content_settings::SETTING_SOURCE_NONE; | 460 info->source = content_settings::SETTING_SOURCE_NONE; |
| 452 info->primary_pattern = ContentSettingsPattern(); | 461 info->primary_pattern = ContentSettingsPattern(); |
| 453 info->secondary_pattern = ContentSettingsPattern(); | 462 info->secondary_pattern = ContentSettingsPattern(); |
| 454 } | 463 } |
| 455 return NULL; | 464 return NULL; |
| 456 } | 465 } |
| OLD | NEW |