OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/site_settings_helper.h" | 5 #include "chrome/browser/ui/webui/site_settings_helper.h" |
6 | 6 |
7 #include <functional> | |
8 #include <string> | |
9 #include <utility> | |
Finnur
2016/09/15 12:51:11
Is this the result of a clang IWYU tool?
Also, st
dschuyler
2016/09/15 20:35:28
Yes.
| |
10 | |
7 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
8 #include "base/values.h" | 12 #include "base/values.h" |
9 #include "chrome/browser/permissions/chooser_context_base.h" | 13 #include "chrome/browser/permissions/chooser_context_base.h" |
10 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 15 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
12 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 17 #include "components/content_settings/core/browser/host_content_settings_map.h" |
14 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
15 | 19 |
16 namespace site_settings { | 20 namespace site_settings { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 exception->SetString(kSetting, setting_string); | 101 exception->SetString(kSetting, setting_string); |
98 exception->SetString(kSource, provider_name); | 102 exception->SetString(kSource, provider_name); |
99 exception->SetBoolean(kIncognito, incognito); | 103 exception->SetBoolean(kIncognito, incognito); |
100 return base::WrapUnique(exception); | 104 return base::WrapUnique(exception); |
101 } | 105 } |
102 | 106 |
103 void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map, | 107 void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map, |
104 ContentSettingsType type, | 108 ContentSettingsType type, |
105 content::WebUI* web_ui, | 109 content::WebUI* web_ui, |
106 bool incognito, | 110 bool incognito, |
111 const std::string* filter, | |
107 base::ListValue* exceptions) { | 112 base::ListValue* exceptions) { |
108 ContentSettingsForOneType entries; | 113 ContentSettingsForOneType entries; |
109 map->GetSettingsForOneType(type, std::string(), &entries); | 114 map->GetSettingsForOneType(type, std::string(), &entries); |
110 // Group settings by primary_pattern. | 115 // Group settings by primary_pattern. |
111 AllPatternsSettings all_patterns_settings; | 116 AllPatternsSettings all_patterns_settings; |
112 for (ContentSettingsForOneType::iterator i = entries.begin(); | 117 for (ContentSettingsForOneType::iterator i = entries.begin(); |
113 i != entries.end(); ++i) { | 118 i != entries.end(); ++i) { |
114 // Don't add default settings. | 119 // Don't add default settings. |
115 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 120 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
116 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 121 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
117 i->source != kPreferencesSource) { | 122 i->source != kPreferencesSource) { |
118 continue; | 123 continue; |
119 } | 124 } |
120 | 125 |
121 // Off-the-record HostContentSettingsMap contains incognito content settings | 126 // Off-the-record HostContentSettingsMap contains incognito content settings |
122 // as well as normal content settings. Here, we use the incongnito settings | 127 // as well as normal content settings. Here, we use the incongnito settings |
123 // only. | 128 // only. |
124 if (map->is_off_the_record() && !i->incognito) | 129 if (map->is_off_the_record() && !i->incognito) |
125 continue; | 130 continue; |
126 | 131 |
132 if (filter && i->primary_pattern.ToString() != *filter) | |
133 continue; | |
134 | |
127 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] | 135 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] |
128 [i->secondary_pattern] = i->setting; | 136 [i->secondary_pattern] = i->setting; |
129 } | 137 } |
130 | 138 |
131 // Keep the exceptions sorted by provider so they will be displayed in | 139 // Keep the exceptions sorted by provider so they will be displayed in |
132 // precedence order. | 140 // precedence order. |
133 std::vector<std::unique_ptr<base::DictionaryValue>> | 141 std::vector<std::unique_ptr<base::DictionaryValue>> |
134 all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES]; | 142 all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES]; |
135 | 143 |
136 // |all_patterns_settings| is sorted from the lowest precedence pattern to | 144 // |all_patterns_settings| is sorted from the lowest precedence pattern to |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 } | 363 } |
356 } | 364 } |
357 | 365 |
358 for (auto& one_provider_exceptions : all_provider_exceptions) { | 366 for (auto& one_provider_exceptions : all_provider_exceptions) { |
359 for (auto& exception : one_provider_exceptions) | 367 for (auto& exception : one_provider_exceptions) |
360 exceptions->Append(std::move(exception)); | 368 exceptions->Append(std::move(exception)); |
361 } | 369 } |
362 } | 370 } |
363 | 371 |
364 } // namespace site_settings | 372 } // namespace site_settings |
OLD | NEW |