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> | 7 #include <functional> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // Create a DictionaryValue* that will act as a data source for a single row | 130 // Create a DictionaryValue* that will act as a data source for a single row |
131 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). | 131 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). |
132 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( | 132 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( |
133 const ContentSettingsPattern& pattern, | 133 const ContentSettingsPattern& pattern, |
134 const ContentSettingsPattern& secondary_pattern, | 134 const ContentSettingsPattern& secondary_pattern, |
135 const std::string& display_name, | 135 const std::string& display_name, |
136 const ContentSetting& setting, | 136 const ContentSetting& setting, |
137 const std::string& provider_name, | 137 const std::string& provider_name, |
138 bool incognito) { | 138 bool incognito) { |
139 base::DictionaryValue* exception = new base::DictionaryValue(); | 139 auto exception = base::MakeUnique<base::DictionaryValue>(); |
140 exception->SetString(kOrigin, pattern.ToString()); | 140 exception->SetString(kOrigin, pattern.ToString()); |
141 exception->SetString(kDisplayName, display_name); | 141 exception->SetString(kDisplayName, display_name); |
142 exception->SetString(kEmbeddingOrigin, | 142 exception->SetString(kEmbeddingOrigin, |
143 secondary_pattern == ContentSettingsPattern::Wildcard() ? | 143 secondary_pattern == ContentSettingsPattern::Wildcard() ? |
144 std::string() : | 144 std::string() : |
145 secondary_pattern.ToString()); | 145 secondary_pattern.ToString()); |
146 | 146 |
147 std::string setting_string = | 147 std::string setting_string = |
148 content_settings::ContentSettingToString(setting); | 148 content_settings::ContentSettingToString(setting); |
149 DCHECK(!setting_string.empty()); | 149 DCHECK(!setting_string.empty()); |
150 | 150 |
151 exception->SetString(kSetting, setting_string); | 151 exception->SetString(kSetting, setting_string); |
152 exception->SetString(kSource, provider_name); | 152 exception->SetString(kSource, provider_name); |
153 exception->SetBoolean(kIncognito, incognito); | 153 exception->SetBoolean(kIncognito, incognito); |
154 return base::WrapUnique(exception); | 154 return exception; |
155 } | 155 } |
156 | 156 |
157 std::string GetDisplayName( | 157 std::string GetDisplayName( |
158 const ContentSettingsPattern& pattern, | 158 const ContentSettingsPattern& pattern, |
159 const extensions::ExtensionRegistry* extension_registry) { | 159 const extensions::ExtensionRegistry* extension_registry) { |
160 if (extension_registry && | 160 if (extension_registry && |
161 pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROMEEXTENSION) { | 161 pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROMEEXTENSION) { |
162 GURL url(pattern.ToString()); | 162 GURL url(pattern.ToString()); |
163 // For the extension scheme, the pattern must be a valid URL. | 163 // For the extension scheme, the pattern must be a valid URL. |
164 DCHECK(url.is_valid()); | 164 DCHECK(url.is_valid()); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 for (auto& one_provider_exceptions : all_provider_exceptions) { | 457 for (auto& one_provider_exceptions : all_provider_exceptions) { |
458 for (auto& exception : one_provider_exceptions) | 458 for (auto& exception : one_provider_exceptions) |
459 exceptions->Append(std::move(exception)); | 459 exceptions->Append(std::move(exception)); |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 } // namespace site_settings | 463 } // namespace site_settings |
OLD | NEW |