Chromium Code Reviews| 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; |
| 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()); |
|
Bernhard Bauer
2011/06/03 14:50:23
Longer-term it might make sense to group the rules
markusheintz_
2011/06/03 15:29:31
FYI: Hey I'm sorry I actually wanted to rename tha
Bernhard Bauer
2011/06/03 16:36:54
Ok, doesn't change the sorting behavior though ;-)
|
| + i != tmp_map.end(); |
| + ++i) { |
| + settings->push_back(i->second); |
| } |
| } |