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 | 5 |
| 6 #include "chrome/browser/content_settings/content_settings_base_provider.h" | 6 #include "chrome/browser/content_settings/content_settings_base_provider.h" |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 next_dot - ContentSettingsPattern::kDomainWildcardLength + 1); | 143 next_dot - ContentSettingsPattern::kDomainWildcardLength + 1); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return CONTENT_SETTING_DEFAULT; | 146 return CONTENT_SETTING_DEFAULT; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void BaseProvider::GetAllContentSettingsRules( | 149 void BaseProvider::GetAllContentSettingsRules( |
| 150 ContentSettingsType content_type, | 150 ContentSettingsType content_type, |
| 151 const ResourceIdentifier& resource_identifier, | 151 const ResourceIdentifier& resource_identifier, |
| 152 Rules* content_setting_rules) const { | 152 Rules* content_setting_rules) const { |
| 153 //TODO | |
|
Bernhard Bauer
2011/02/23 13:18:53
Please expand.
markusheintz_
2011/02/23 18:42:09
Fixed the TODO
| |
| 153 DCHECK(RequiresResourceIdentifier(content_type) != | 154 DCHECK(RequiresResourceIdentifier(content_type) != |
| 154 resource_identifier.empty()); | 155 resource_identifier.empty()); |
| 155 DCHECK(content_setting_rules); | 156 DCHECK(content_setting_rules); |
| 156 content_setting_rules->clear(); | 157 content_setting_rules->clear(); |
| 157 | 158 |
| 158 const HostContentSettings* map_to_return = | 159 const HostContentSettings* map_to_return = |
| 159 is_off_the_record_ ? &off_the_record_settings_ : &host_content_settings_; | 160 is_off_the_record_ ? &off_the_record_settings_ : &host_content_settings_; |
| 160 ContentSettingsTypeResourceIdentifierPair requested_setting( | 161 ContentSettingsTypeResourceIdentifierPair requested_setting( |
| 161 content_type, resource_identifier); | 162 content_type, resource_identifier); |
| 162 | 163 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 key.find('.', ContentSettingsPattern::kDomainWildcardLength); | 231 key.find('.', ContentSettingsPattern::kDomainWildcardLength); |
| 231 if (next_dot == std::string::npos) | 232 if (next_dot == std::string::npos) |
| 232 break; | 233 break; |
| 233 key.erase(ContentSettingsPattern::kDomainWildcardLength, | 234 key.erase(ContentSettingsPattern::kDomainWildcardLength, |
| 234 next_dot - ContentSettingsPattern::kDomainWildcardLength + 1); | 235 next_dot - ContentSettingsPattern::kDomainWildcardLength + 1); |
| 235 } | 236 } |
| 236 | 237 |
| 237 return output; | 238 return output; |
| 238 } | 239 } |
| 239 | 240 |
| 241 void BaseProvider::UpdateContentSettingsMap( | |
| 242 const ContentSettingsPattern& requesting_pattern, | |
| 243 const ContentSettingsPattern& embedding_pattern, | |
| 244 ContentSettingsType content_type, | |
| 245 const ResourceIdentifier& resource_identifier, | |
| 246 ContentSetting content_setting) { | |
| 247 std::string pattern_str(requesting_pattern.CanonicalizePattern()); | |
|
Bernhard Bauer
2011/02/23 13:18:53
I think you could move this down and get rid of th
markusheintz_
2011/02/23 18:42:09
Yep. Done
| |
| 248 { | |
| 249 base::AutoLock auto_lock(lock()); | |
| 250 | |
| 251 HostContentSettings* content_settings_map = host_content_settings(); | |
| 252 | |
| 253 if (!content_settings_map->count(pattern_str)) { | |
| 254 (*content_settings_map)[pattern_str].content_settings = ContentSettings(); | |
|
Bernhard Bauer
2011/02/23 13:18:53
Is this necessary? Shouldn't an empty ContentSetti
markusheintz_
2011/02/23 18:42:09
True.
| |
| 255 } | |
| 256 HostContentSettings::iterator i( | |
| 257 content_settings_map->find(pattern_str)); | |
| 258 if (RequiresResourceIdentifier(content_type)) { | |
| 259 i->second.content_settings.settings[content_type] = | |
| 260 CONTENT_SETTING_DEFAULT; | |
| 261 | |
| 262 ResourceContentSettings& content_settings_for_resources = | |
| 263 i->second.content_settings_for_resources; | |
| 264 if (content_setting != CONTENT_SETTING_DEFAULT) { | |
| 265 content_settings_for_resources[ | |
| 266 ContentSettingsTypeResourceIdentifierPair(content_type, | |
| 267 resource_identifier)] = content_setting; | |
| 268 } else { | |
| 269 content_settings_for_resources.erase( | |
| 270 ContentSettingsTypeResourceIdentifierPair(content_type, | |
| 271 resource_identifier)); | |
| 272 } | |
| 273 } else { | |
| 274 ContentSettings& content_settings = i->second.content_settings; | |
|
Bernhard Bauer
2011/02/23 13:18:53
Inline this local variable?
markusheintz_
2011/02/23 18:42:09
Done.
| |
| 275 content_settings.settings[content_type] = content_setting; | |
| 276 } | |
| 277 } | |
| 278 } | |
| 279 | |
| 240 // static | 280 // static |
| 241 ContentSetting BaseProvider::ClickToPlayFixup(ContentSettingsType content_type, | 281 ContentSetting BaseProvider::ClickToPlayFixup(ContentSettingsType content_type, |
| 242 ContentSetting setting) { | 282 ContentSetting setting) { |
| 243 if (setting == CONTENT_SETTING_ASK && | 283 if (setting == CONTENT_SETTING_ASK && |
| 244 content_type == CONTENT_SETTINGS_TYPE_PLUGINS && | 284 content_type == CONTENT_SETTINGS_TYPE_PLUGINS && |
| 245 !CommandLine::ForCurrentProcess()->HasSwitch( | 285 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 246 switches::kEnableClickToPlay)) { | 286 switches::kEnableClickToPlay)) { |
| 247 return CONTENT_SETTING_BLOCK; | 287 return CONTENT_SETTING_BLOCK; |
| 248 } | 288 } |
| 249 return setting; | 289 return setting; |
| 250 } | 290 } |
| 251 | 291 |
| 252 } // namespace content_settings | 292 } // namespace content_settings |
| OLD | NEW |