| 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 <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 resource_identifier.empty()); | 304 resource_identifier.empty()); |
| 305 DCHECK(settings); | 305 DCHECK(settings); |
| 306 | 306 |
| 307 settings->clear(); | 307 settings->clear(); |
| 308 for (size_t i = 0; i < content_settings_providers_.size(); ++i) { | 308 for (size_t i = 0; i < content_settings_providers_.size(); ++i) { |
| 309 // Get rules from the content settings provider. | 309 // Get rules from the content settings provider. |
| 310 Rules rules; | 310 Rules rules; |
| 311 content_settings_providers_[i]->GetAllContentSettingsRules( | 311 content_settings_providers_[i]->GetAllContentSettingsRules( |
| 312 content_type, resource_identifier, &rules); | 312 content_type, resource_identifier, &rules); |
| 313 | 313 |
| 314 // Sort rules according to their primary pattern string using a map. | 314 // Sort rules according to their primary pattern string using a multimap. |
| 315 std::map<std::string, PatternSettingSourceTuple> settings_map; | 315 std::multimap<std::string, PatternSettingSourceTuple> settings_map; |
| 316 for (Rules::iterator rule = rules.begin(); | 316 for (Rules::iterator rule = rules.begin(); |
| 317 rule != rules.end(); | 317 rule != rules.end(); |
| 318 ++rule) { | 318 ++rule) { |
| 319 // We do not support pattern pairs in the UI, so we only display the | |
| 320 // primary pattern. | |
| 321 std::string sort_key = rule->primary_pattern.ToString(); | 319 std::string sort_key = rule->primary_pattern.ToString(); |
| 322 settings_map[sort_key] = PatternSettingSourceTuple( | 320 std::pair<std::string, PatternSettingSourceTuple> map_entry( |
| 323 rule->primary_pattern, | 321 sort_key, |
| 324 rule->secondary_pattern, | 322 PatternSettingSourceTuple(rule->primary_pattern, |
| 325 rule->content_setting, | 323 rule->secondary_pattern, |
| 326 kProviderNames[i]); | 324 rule->content_setting, |
| 325 kProviderNames[i])); |
| 326 |
| 327 settings_map.insert(map_entry); |
| 327 } | 328 } |
| 328 | 329 |
| 329 // TODO(markusheintz): Only the rules that are applied should be added. | 330 // TODO(markusheintz): Only the rules that are applied should be added. |
| 330 for (std::map<std::string, PatternSettingSourceTuple>::iterator i( | 331 for (std::multimap<std::string, PatternSettingSourceTuple>::iterator i( |
| 331 settings_map.begin()); | 332 settings_map.begin()); |
| 332 i != settings_map.end(); | 333 i != settings_map.end(); |
| 333 ++i) { | 334 ++i) { |
| 334 settings->push_back(i->second); | 335 settings->push_back(i->second); |
| 335 } | 336 } |
| 336 } | 337 } |
| 337 } | 338 } |
| 338 | 339 |
| 339 void HostContentSettingsMap::SetDefaultContentSetting( | 340 void HostContentSettingsMap::SetDefaultContentSetting( |
| 340 ContentSettingsType content_type, | 341 ContentSettingsType content_type, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 535 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
| 535 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? | 536 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? |
| 536 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); | 537 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); |
| 537 } | 538 } |
| 538 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { | 539 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { |
| 539 SetBlockThirdPartyCookies(cookie_behavior == | 540 SetBlockThirdPartyCookies(cookie_behavior == |
| 540 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); | 541 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); |
| 541 } | 542 } |
| 542 } | 543 } |
| 543 } | 544 } |
| OLD | NEW |