Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6160)

Unified Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7049007: Origin Identifier Value Map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/host_content_settings_map.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index f253ae7642e18b579ec344d49844fcf3b9053573..78a02149fdd290c72afb54c5f554f3a81c99d81d 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -261,34 +261,31 @@ void HostContentSettingsMap::GetSettingsForOneType(
const std::string& resource_identifier,
SettingsForOneType* settings) const {
DCHECK(settings);
- settings->clear();
-
// Collect content_settings::Rules for the given content_type and
// resource_identifier from the content settings providers.
- Rules content_settings_rules;
+ std::map<std::string, PatternSettingPair> tmp_map;
markusheintz_ 2011/06/03 13:08:54 I moved the sorting from the PrefProvider to his p
for (ConstProviderIterator provider = content_settings_providers_.begin();
- provider != content_settings_providers_.end();
- ++provider) {
- // TODO(markusheintz): Only the rules that are applied should be collected.
- // Merge rules.
- // TODO(markusheintz): GetAllContentSettingsRules should maybe not clear the
- // passed vector in case rule sets are just unified.
+ provider != content_settings_providers_.end();
+ ++provider) {
Rules rules;
(*provider)->GetAllContentSettingsRules(
content_type, resource_identifier, &rules);
- content_settings_rules.insert(content_settings_rules.end(),
- rules.begin(),
- rules.end());
+ // TODO(markusheintz): Only the rules that are applied should be collected.
+ for (Rules::iterator rule = rules.begin();
+ rule != rules.end();
+ ++rule) {
+ const ContentSettingsPattern& pattern(rule->requesting_url_pattern);
+ tmp_map[pattern.ToString()] =
+ PatternSettingPair(pattern, rule->content_setting);
+ }
}
- // convert Rules to SettingsForOneType
- for (const_rules_iterator rule_iterator =
- content_settings_rules.begin();
- rule_iterator != content_settings_rules.end();
- ++rule_iterator) {
- settings->push_back(std::make_pair(ContentSettingsPattern(
- rule_iterator->requesting_url_pattern),
- rule_iterator->content_setting));
+ settings->clear();
+ // Rely on the maps iterator to sort the rules.
+ for (std::map<std::string, PatternSettingPair>::iterator i(tmp_map.begin());
+ i != tmp_map.end();
+ ++i) {
+ settings->push_back(i->second);
}
}

Powered by Google App Engine
This is Rietveld 408576698