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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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 (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/chromeos/settings/device_settings_provider.h" 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
6 6
7 #include <memory.h> 7 #include <memory.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 policy.has_ephemeral_users_enabled() && 165 policy.has_ephemeral_users_enabled() &&
166 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() && 166 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() &&
167 policy.ephemeral_users_enabled().ephemeral_users_enabled()); 167 policy.ephemeral_users_enabled().ephemeral_users_enabled());
168 168
169 std::unique_ptr<base::ListValue> list(new base::ListValue()); 169 std::unique_ptr<base::ListValue> list(new base::ListValue());
170 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); 170 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist();
171 const RepeatedPtrField<std::string>& whitelist = 171 const RepeatedPtrField<std::string>& whitelist =
172 whitelist_proto.user_whitelist(); 172 whitelist_proto.user_whitelist();
173 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); 173 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin();
174 it != whitelist.end(); ++it) { 174 it != whitelist.end(); ++it) {
175 list->Append(new base::StringValue(*it)); 175 list->AppendString(*it);
176 } 176 }
177 new_values_cache->SetValue(kAccountsPrefUsers, std::move(list)); 177 new_values_cache->SetValue(kAccountsPrefUsers, std::move(list));
178 178
179 std::unique_ptr<base::ListValue> account_list(new base::ListValue()); 179 std::unique_ptr<base::ListValue> account_list(new base::ListValue());
180 const em::DeviceLocalAccountsProto device_local_accounts_proto = 180 const em::DeviceLocalAccountsProto device_local_accounts_proto =
181 policy.device_local_accounts(); 181 policy.device_local_accounts();
182 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = 182 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts =
183 device_local_accounts_proto.account(); 183 device_local_accounts_proto.account();
184 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; 184 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry;
185 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { 185 for (entry = accounts.begin(); entry != accounts.end(); ++entry) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 new_values_cache->SetBoolean( 235 new_values_cache->SetBoolean(
236 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, 236 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
237 policy.device_local_accounts().prompt_for_network_when_offline()); 237 policy.device_local_accounts().prompt_for_network_when_offline());
238 238
239 if (policy.has_start_up_flags()) { 239 if (policy.has_start_up_flags()) {
240 std::unique_ptr<base::ListValue> list(new base::ListValue()); 240 std::unique_ptr<base::ListValue> list(new base::ListValue());
241 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); 241 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags();
242 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); 242 const RepeatedPtrField<std::string>& flags = flags_proto.flags();
243 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); 243 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin();
244 it != flags.end(); ++it) { 244 it != flags.end(); ++it) {
245 list->Append(new base::StringValue(*it)); 245 list->AppendString(*it);
246 } 246 }
247 new_values_cache->SetValue(kStartUpFlags, std::move(list)); 247 new_values_cache->SetValue(kStartUpFlags, std::move(list));
248 } 248 }
249 249
250 if (policy.has_saml_settings()) { 250 if (policy.has_saml_settings()) {
251 new_values_cache->SetBoolean( 251 new_values_cache->SetBoolean(
252 kAccountsPrefTransferSAMLCookies, 252 kAccountsPrefTransferSAMLCookies,
253 policy.saml_settings().transfer_saml_cookies()); 253 policy.saml_settings().transfer_saml_cookies());
254 } 254 }
255 255
(...skipping 18 matching lines...) Expand all
274 kLoginAuthenticationBehavior, 274 kLoginAuthenticationBehavior,
275 policy.login_authentication_behavior().login_authentication_behavior()); 275 policy.login_authentication_behavior().login_authentication_behavior());
276 } 276 }
277 277
278 if (policy.has_login_video_capture_allowed_urls()) { 278 if (policy.has_login_video_capture_allowed_urls()) {
279 std::unique_ptr<base::ListValue> list(new base::ListValue()); 279 std::unique_ptr<base::ListValue> list(new base::ListValue());
280 const em::LoginVideoCaptureAllowedUrlsProto& 280 const em::LoginVideoCaptureAllowedUrlsProto&
281 login_video_capture_allowed_urls_proto = 281 login_video_capture_allowed_urls_proto =
282 policy.login_video_capture_allowed_urls(); 282 policy.login_video_capture_allowed_urls();
283 for (const auto& value : login_video_capture_allowed_urls_proto.urls()) { 283 for (const auto& value : login_video_capture_allowed_urls_proto.urls()) {
284 list->Append(new base::StringValue(value)); 284 list->AppendString(value);
285 } 285 }
286 new_values_cache->SetValue(kLoginVideoCaptureAllowedUrls, std::move(list)); 286 new_values_cache->SetValue(kLoginVideoCaptureAllowedUrls, std::move(list));
287 } 287 }
288 288
289 if (policy.has_login_apps()) { 289 if (policy.has_login_apps()) {
290 std::unique_ptr<base::ListValue> login_apps(new base::ListValue); 290 std::unique_ptr<base::ListValue> login_apps(new base::ListValue);
291 const em::LoginAppsProto& login_apps_proto(policy.login_apps()); 291 const em::LoginAppsProto& login_apps_proto(policy.login_apps());
292 for (const auto& login_app : login_apps_proto.login_apps()) 292 for (const auto& login_app : login_apps_proto.login_apps())
293 login_apps->Append(new base::StringValue(login_app)); 293 login_apps->AppendString(login_app);
294 new_values_cache->SetValue(kLoginApps, std::move(login_apps)); 294 new_values_cache->SetValue(kLoginApps, std::move(login_apps));
295 } 295 }
296 } 296 }
297 297
298 void DecodeNetworkPolicies( 298 void DecodeNetworkPolicies(
299 const em::ChromeDeviceSettingsProto& policy, 299 const em::ChromeDeviceSettingsProto& policy,
300 PrefValueMap* new_values_cache) { 300 PrefValueMap* new_values_cache) {
301 // kSignedDataRoamingEnabled has a default value of false. 301 // kSignedDataRoamingEnabled has a default value of false.
302 new_values_cache->SetBoolean( 302 new_values_cache->SetBoolean(
303 kSignedDataRoamingEnabled, 303 kSignedDataRoamingEnabled,
(...skipping 10 matching lines...) Expand all
314 policy.auto_update_settings(); 314 policy.auto_update_settings();
315 if (au_settings_proto.has_update_disabled()) { 315 if (au_settings_proto.has_update_disabled()) {
316 new_values_cache->SetBoolean(kUpdateDisabled, 316 new_values_cache->SetBoolean(kUpdateDisabled,
317 au_settings_proto.update_disabled()); 317 au_settings_proto.update_disabled());
318 } 318 }
319 const RepeatedField<int>& allowed_connection_types = 319 const RepeatedField<int>& allowed_connection_types =
320 au_settings_proto.allowed_connection_types(); 320 au_settings_proto.allowed_connection_types();
321 std::unique_ptr<base::ListValue> list(new base::ListValue()); 321 std::unique_ptr<base::ListValue> list(new base::ListValue());
322 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin()); 322 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin());
323 i != allowed_connection_types.end(); ++i) { 323 i != allowed_connection_types.end(); ++i) {
324 list->Append(new base::FundamentalValue(*i)); 324 list->AppendInteger(*i);
325 } 325 }
326 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate, 326 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate,
327 std::move(list)); 327 std::move(list));
328 } 328 }
329 } 329 }
330 330
331 void DecodeReportingPolicies( 331 void DecodeReportingPolicies(
332 const em::ChromeDeviceSettingsProto& policy, 332 const em::ChromeDeviceSettingsProto& policy,
333 PrefValueMap* new_values_cache) { 333 PrefValueMap* new_values_cache) {
334 if (policy.has_device_reporting()) { 334 if (policy.has_device_reporting()) {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 // Notify the observers we are done. 840 // Notify the observers we are done.
841 std::vector<base::Closure> callbacks; 841 std::vector<base::Closure> callbacks;
842 callbacks.swap(callbacks_); 842 callbacks.swap(callbacks_);
843 for (size_t i = 0; i < callbacks.size(); ++i) 843 for (size_t i = 0; i < callbacks.size(); ++i)
844 callbacks[i].Run(); 844 callbacks[i].Run();
845 845
846 return settings_loaded; 846 return settings_loaded;
847 } 847 }
848 848
849 } // namespace chromeos 849 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698