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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/content_settings/content_settings_extension_provider.h" | 10 #include "chrome/browser/content_settings/content_settings_extension_provider.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 url, ContentSettingsType(j) , ""); | 254 url, ContentSettingsType(j) , ""); |
255 } | 255 } |
256 return output; | 256 return output; |
257 } | 257 } |
258 | 258 |
259 void HostContentSettingsMap::GetSettingsForOneType( | 259 void HostContentSettingsMap::GetSettingsForOneType( |
260 ContentSettingsType content_type, | 260 ContentSettingsType content_type, |
261 const std::string& resource_identifier, | 261 const std::string& resource_identifier, |
262 SettingsForOneType* settings) const { | 262 SettingsForOneType* settings) const { |
263 DCHECK(settings); | 263 DCHECK(settings); |
264 settings->clear(); | |
265 | |
266 // Collect content_settings::Rules for the given content_type and | 264 // Collect content_settings::Rules for the given content_type and |
267 // resource_identifier from the content settings providers. | 265 // resource_identifier from the content settings providers. |
268 Rules content_settings_rules; | 266 std::map<std::string, PatternSettingPair> tmp_map; |
markusheintz_
2011/06/03 13:08:54
I moved the sorting from the PrefProvider to his p
| |
269 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 267 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
270 provider != content_settings_providers_.end(); | 268 provider != content_settings_providers_.end(); |
271 ++provider) { | 269 ++provider) { |
272 // TODO(markusheintz): Only the rules that are applied should be collected. | |
273 // Merge rules. | |
274 // TODO(markusheintz): GetAllContentSettingsRules should maybe not clear the | |
275 // passed vector in case rule sets are just unified. | |
276 Rules rules; | 270 Rules rules; |
277 (*provider)->GetAllContentSettingsRules( | 271 (*provider)->GetAllContentSettingsRules( |
278 content_type, resource_identifier, &rules); | 272 content_type, resource_identifier, &rules); |
279 content_settings_rules.insert(content_settings_rules.end(), | 273 // TODO(markusheintz): Only the rules that are applied should be collected. |
280 rules.begin(), | 274 for (Rules::iterator rule = rules.begin(); |
281 rules.end()); | 275 rule != rules.end(); |
276 ++rule) { | |
277 const ContentSettingsPattern& pattern(rule->requesting_url_pattern); | |
278 tmp_map[pattern.ToString()] = | |
279 PatternSettingPair(pattern, rule->content_setting); | |
280 } | |
282 } | 281 } |
283 | 282 |
284 // convert Rules to SettingsForOneType | 283 settings->clear(); |
285 for (const_rules_iterator rule_iterator = | 284 // Rely on the maps iterator to sort the rules. |
286 content_settings_rules.begin(); | 285 for (std::map<std::string, PatternSettingPair>::iterator i(tmp_map.begin()); |
287 rule_iterator != content_settings_rules.end(); | 286 i != tmp_map.end(); |
288 ++rule_iterator) { | 287 ++i) { |
289 settings->push_back(std::make_pair(ContentSettingsPattern( | 288 settings->push_back(i->second); |
290 rule_iterator->requesting_url_pattern), | |
291 rule_iterator->content_setting)); | |
292 } | 289 } |
293 } | 290 } |
294 | 291 |
295 void HostContentSettingsMap::SetDefaultContentSetting( | 292 void HostContentSettingsMap::SetDefaultContentSetting( |
296 ContentSettingsType content_type, | 293 ContentSettingsType content_type, |
297 ContentSetting setting) { | 294 ContentSetting setting) { |
298 for (DefaultProviderIterator provider = | 295 for (DefaultProviderIterator provider = |
299 default_content_settings_providers_.begin(); | 296 default_content_settings_providers_.begin(); |
300 provider != default_content_settings_providers_.end(); ++provider) { | 297 provider != default_content_settings_providers_.end(); ++provider) { |
301 (*provider)->UpdateDefaultSetting(content_type, setting); | 298 (*provider)->UpdateDefaultSetting(content_type, setting); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 460 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
464 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? | 461 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? |
465 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); | 462 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); |
466 } | 463 } |
467 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) { | 464 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) { |
468 SetBlockThirdPartyCookies(cookie_behavior == | 465 SetBlockThirdPartyCookies(cookie_behavior == |
469 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); | 466 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); |
470 } | 467 } |
471 } | 468 } |
472 } | 469 } |
OLD | NEW |