OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 | 1166 |
1167 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] | 1167 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] |
1168 [i->secondary_pattern] = i->setting; | 1168 [i->secondary_pattern] = i->setting; |
1169 } | 1169 } |
1170 | 1170 |
1171 // Keep the exceptions sorted by provider so they will be displayed in | 1171 // Keep the exceptions sorted by provider so they will be displayed in |
1172 // precedence order. | 1172 // precedence order. |
1173 std::vector<std::vector<base::Value*> > all_provider_exceptions; | 1173 std::vector<std::vector<base::Value*> > all_provider_exceptions; |
1174 all_provider_exceptions.resize(HostContentSettingsMap::NUM_PROVIDER_TYPES); | 1174 all_provider_exceptions.resize(HostContentSettingsMap::NUM_PROVIDER_TYPES); |
1175 | 1175 |
1176 for (AllPatternsSettings::iterator i = all_patterns_settings.begin(); | 1176 // The all_patterns_settings is sorted from the lowest precedence pattern to |
1177 i != all_patterns_settings.end(); | 1177 // the highest (see operator< in ContentSettingsPattern), so traverse it in |
| 1178 // reverse to show the patterns with the highest precedence (the more specific |
| 1179 // ones) on the top. |
| 1180 for (AllPatternsSettings::reverse_iterator i = all_patterns_settings.rbegin(); |
| 1181 i != all_patterns_settings.rend(); |
1178 ++i) { | 1182 ++i) { |
1179 const ContentSettingsPattern& primary_pattern = i->first.first; | 1183 const ContentSettingsPattern& primary_pattern = i->first.first; |
1180 const OnePatternSettings& one_settings = i->second; | 1184 const OnePatternSettings& one_settings = i->second; |
1181 | 1185 |
1182 // The "parent" entry either has an identical primary and secondary pattern, | 1186 // The "parent" entry either has an identical primary and secondary pattern, |
1183 // or has a wildcard secondary. The two cases are indistinguishable in the | 1187 // or has a wildcard secondary. The two cases are indistinguishable in the |
1184 // UI. | 1188 // UI. |
1185 OnePatternSettings::const_iterator parent = | 1189 OnePatternSettings::const_iterator parent = |
1186 one_settings.find(primary_pattern); | 1190 one_settings.find(primary_pattern); |
1187 if (parent == one_settings.end()) | 1191 if (parent == one_settings.end()) |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 | 1624 |
1621 // Exceptions apply only when the feature is enabled. | 1625 // Exceptions apply only when the feature is enabled. |
1622 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1626 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1623 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1627 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1624 web_ui()->CallJavascriptFunction( | 1628 web_ui()->CallJavascriptFunction( |
1625 "ContentSettings.enableProtectedContentExceptions", | 1629 "ContentSettings.enableProtectedContentExceptions", |
1626 base::FundamentalValue(enable_exceptions)); | 1630 base::FundamentalValue(enable_exceptions)); |
1627 } | 1631 } |
1628 | 1632 |
1629 } // namespace options | 1633 } // namespace options |
OLD | NEW |