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 f05ef0acdc5b38d317b108dac41eff3454b53e6f..f9c4bd68d83b9ab5f1475b10339f817f96fa6f68 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/content_settings/host_content_settings_map.h" |
| +#include <algorithm> |
| #include <list> |
| #include "base/command_line.h" |
| @@ -347,7 +348,9 @@ ContentSettings HostContentSettingsMap::GetNonDefaultContentSettings( |
| void HostContentSettingsMap::GetSettingsForOneType( |
| ContentSettingsType content_type, |
| const std::string& resource_identifier, |
| - SettingsForOneType* settings) const { |
| + content_settings::ProviderInterface::Rule::SortFunction sort_function, |
| + ContentSettingsForOneType* settings) |
|
Bernhard Bauer
2011/09/16 09:16:48
Nit: I think the |const| belongs on this line?
marja
2011/09/19 11:53:40
Done.
|
| + const { |
| DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type), |
| resource_identifier.empty()); |
| DCHECK(settings); |
| @@ -355,31 +358,23 @@ void HostContentSettingsMap::GetSettingsForOneType( |
| settings->clear(); |
| for (size_t i = 0; i < content_settings_providers_.size(); ++i) { |
| // Get rules from the content settings provider. |
| - Rules rules; |
| + Rules rules_for_provider; |
| content_settings_providers_[i]->GetAllContentSettingsRules( |
| - content_type, resource_identifier, &rules); |
| - |
| - // Sort rules according to their primary-secondary pattern string pairs |
| - // using a map. |
| - std::map<StringPair, PatternSettingSourceTuple> settings_map; |
| - for (Rules::iterator rule = rules.begin(); |
| - rule != rules.end(); |
| - ++rule) { |
| - StringPair sort_key(rule->primary_pattern.ToString(), |
| - rule->secondary_pattern.ToString()); |
| - settings_map[sort_key] = PatternSettingSourceTuple( |
| - rule->primary_pattern, |
| - rule->secondary_pattern, |
| - rule->content_setting, |
| - kProviderNames[i]); |
| + content_type, resource_identifier, &rules_for_provider); |
| + |
| + // The rules are returned in arbitrary order. Sort them according to the |
| + // ContentSettingsPattern precedence relation. |
| + if (sort_function) { |
| + std::sort(rules_for_provider.begin(), rules_for_provider.end(), |
| + sort_function); |
| } |
| // TODO(markusheintz): Only the rules that are applied should be added. |
| - for (std::map<StringPair, PatternSettingSourceTuple>::iterator i( |
| - settings_map.begin()); |
| - i != settings_map.end(); |
| - ++i) { |
| - settings->push_back(i->second); |
| + for (Rules::const_iterator it = rules_for_provider.begin(); |
| + it != rules_for_provider.end(); ++it) { |
| + settings->push_back(ContentSettingPatternSourceTuple( |
| + it->primary_pattern, it->secondary_pattern, |
| + it->content_setting, kProviderNames[i])); |
| } |
| } |
| } |