Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/browser/ui/webui/site_settings_helper.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 142 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
143 143
144 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); 144 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs();
145 const base::ListValue* policy_urls = prefs->GetList( 145 const base::ListValue* policy_urls = prefs->GetList(
146 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC 146 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
147 ? prefs::kAudioCaptureAllowedUrls 147 ? prefs::kAudioCaptureAllowedUrls
148 : prefs::kVideoCaptureAllowedUrls); 148 : prefs::kVideoCaptureAllowedUrls);
149 149
150 // Convert the URLs to |ContentSettingsPattern|s. Ignore any invalid ones. 150 // Convert the URLs to |ContentSettingsPattern|s. Ignore any invalid ones.
151 std::vector<ContentSettingsPattern> patterns; 151 std::vector<ContentSettingsPattern> patterns;
152 for (const base::Value* entry : *policy_urls) { 152 for (const auto& entry : *policy_urls) {
153 std::string url; 153 std::string url;
154 bool valid_string = entry->GetAsString(&url); 154 bool valid_string = entry->GetAsString(&url);
155 if (!valid_string) 155 if (!valid_string)
156 continue; 156 continue;
157 157
158 ContentSettingsPattern pattern = ContentSettingsPattern::FromString(url); 158 ContentSettingsPattern pattern = ContentSettingsPattern::FromString(url);
159 if (!pattern.IsValid()) 159 if (!pattern.IsValid())
160 continue; 160 continue;
161 161
162 patterns.push_back(pattern); 162 patterns.push_back(pattern);
163 } 163 }
164 164
165 // The patterns are shown in the UI in a reverse order defined by 165 // The patterns are shown in the UI in a reverse order defined by
166 // |ContentSettingsPattern::operator<|. 166 // |ContentSettingsPattern::operator<|.
167 std::sort( 167 std::sort(
168 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>()); 168 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>());
169 169
170 for (const ContentSettingsPattern& pattern : patterns) { 170 for (const ContentSettingsPattern& pattern : patterns) {
171 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(), 171 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(),
172 CONTENT_SETTING_ALLOW, 172 CONTENT_SETTING_ALLOW,
173 kPolicyProviderId)); 173 kPolicyProviderId));
174 } 174 }
175 } 175 }
176 176
177 } // namespace site_settings 177 } // namespace site_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698