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

Side by Side Diff: chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years 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/policy/device_policy_decoder_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 29 matching lines...) Expand all
40 // Decodes a protobuf integer to an IntegerValue. Returns NULL in case the input 40 // Decodes a protobuf integer to an IntegerValue. Returns NULL in case the input
41 // value is out of bounds. 41 // value is out of bounds.
42 std::unique_ptr<base::Value> DecodeIntegerValue(google::protobuf::int64 value) { 42 std::unique_ptr<base::Value> DecodeIntegerValue(google::protobuf::int64 value) {
43 if (value < std::numeric_limits<int>::min() || 43 if (value < std::numeric_limits<int>::min() ||
44 value > std::numeric_limits<int>::max()) { 44 value > std::numeric_limits<int>::max()) {
45 LOG(WARNING) << "Integer value " << value 45 LOG(WARNING) << "Integer value " << value
46 << " out of numeric limits, ignoring."; 46 << " out of numeric limits, ignoring.";
47 return std::unique_ptr<base::Value>(); 47 return std::unique_ptr<base::Value>();
48 } 48 }
49 49
50 return std::unique_ptr<base::Value>( 50 return std::unique_ptr<base::Value>(new base::Value(static_cast<int>(value)));
51 new base::FundamentalValue(static_cast<int>(value)));
52 } 51 }
53 52
54 // Decodes a JSON string to a base::Value, and drops unknown properties 53 // Decodes a JSON string to a base::Value, and drops unknown properties
55 // according to a policy schema. |policy_name| is the name of a policy schema 54 // according to a policy schema. |policy_name| is the name of a policy schema
56 // defined in policy_templates.json. Returns NULL in case the input is not a 55 // defined in policy_templates.json. Returns NULL in case the input is not a
57 // valid JSON string. 56 // valid JSON string.
58 std::unique_ptr<base::Value> DecodeJsonStringAndDropUnknownBySchema( 57 std::unique_ptr<base::Value> DecodeJsonStringAndDropUnknownBySchema(
59 const std::string& json_string, 58 const std::string& json_string,
60 const std::string& policy_name) { 59 const std::string& policy_name) {
61 std::string error; 60 std::string error;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return nullptr; 108 return nullptr;
110 109
111 return base::MakeUnique<base::StringValue>(kConnectionTypes[value]); 110 return base::MakeUnique<base::StringValue>(kConnectionTypes[value]);
112 } 111 }
113 112
114 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, 113 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy,
115 PolicyMap* policies) { 114 PolicyMap* policies) {
116 if (policy.has_guest_mode_enabled()) { 115 if (policy.has_guest_mode_enabled()) {
117 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); 116 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled());
118 if (container.has_guest_mode_enabled()) { 117 if (container.has_guest_mode_enabled()) {
119 policies->Set(key::kDeviceGuestModeEnabled, POLICY_LEVEL_MANDATORY, 118 policies->Set(
120 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 119 key::kDeviceGuestModeEnabled, POLICY_LEVEL_MANDATORY,
121 base::MakeUnique<base::FundamentalValue>( 120 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
122 container.guest_mode_enabled()), 121 base::MakeUnique<base::Value>(container.guest_mode_enabled()),
123 nullptr); 122 nullptr);
124 } 123 }
125 } 124 }
126 125
127 if (policy.has_reboot_on_shutdown()) { 126 if (policy.has_reboot_on_shutdown()) {
128 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown()); 127 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown());
129 if (container.has_reboot_on_shutdown()) { 128 if (container.has_reboot_on_shutdown()) {
130 policies->Set(key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY, 129 policies->Set(
131 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 130 key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY,
132 base::MakeUnique<base::FundamentalValue>( 131 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
133 container.reboot_on_shutdown()), 132 base::MakeUnique<base::Value>(container.reboot_on_shutdown()),
134 nullptr); 133 nullptr);
135 } 134 }
136 } 135 }
137 136
138 if (policy.has_show_user_names()) { 137 if (policy.has_show_user_names()) {
139 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names()); 138 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names());
140 if (container.has_show_user_names()) { 139 if (container.has_show_user_names()) {
141 policies->Set( 140 policies->Set(key::kDeviceShowUserNamesOnSignin, POLICY_LEVEL_MANDATORY,
142 key::kDeviceShowUserNamesOnSignin, POLICY_LEVEL_MANDATORY, 141 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
143 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 142 base::MakeUnique<base::Value>(container.show_user_names()),
144 base::MakeUnique<base::FundamentalValue>(container.show_user_names()), 143 nullptr);
145 nullptr);
146 } 144 }
147 } 145 }
148 146
149 if (policy.has_allow_new_users()) { 147 if (policy.has_allow_new_users()) {
150 const em::AllowNewUsersProto& container(policy.allow_new_users()); 148 const em::AllowNewUsersProto& container(policy.allow_new_users());
151 if (container.has_allow_new_users()) { 149 if (container.has_allow_new_users()) {
152 policies->Set( 150 policies->Set(key::kDeviceAllowNewUsers, POLICY_LEVEL_MANDATORY,
153 key::kDeviceAllowNewUsers, POLICY_LEVEL_MANDATORY, 151 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
154 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 152 base::MakeUnique<base::Value>(container.allow_new_users()),
155 base::MakeUnique<base::FundamentalValue>(container.allow_new_users()), 153 nullptr);
156 nullptr);
157 } 154 }
158 } 155 }
159 156
160 if (policy.has_user_whitelist()) { 157 if (policy.has_user_whitelist()) {
161 const em::UserWhitelistProto& container(policy.user_whitelist()); 158 const em::UserWhitelistProto& container(policy.user_whitelist());
162 std::unique_ptr<base::ListValue> whitelist(new base::ListValue); 159 std::unique_ptr<base::ListValue> whitelist(new base::ListValue);
163 for (const auto& entry : container.user_whitelist()) 160 for (const auto& entry : container.user_whitelist())
164 whitelist->AppendString(entry); 161 whitelist->AppendString(entry);
165 policies->Set(key::kDeviceUserWhitelist, POLICY_LEVEL_MANDATORY, 162 policies->Set(key::kDeviceUserWhitelist, POLICY_LEVEL_MANDATORY,
166 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 163 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
167 std::move(whitelist), nullptr); 164 std::move(whitelist), nullptr);
168 } 165 }
169 166
170 if (policy.has_ephemeral_users_enabled()) { 167 if (policy.has_ephemeral_users_enabled()) {
171 const em::EphemeralUsersEnabledProto& container( 168 const em::EphemeralUsersEnabledProto& container(
172 policy.ephemeral_users_enabled()); 169 policy.ephemeral_users_enabled());
173 if (container.has_ephemeral_users_enabled()) { 170 if (container.has_ephemeral_users_enabled()) {
174 policies->Set(key::kDeviceEphemeralUsersEnabled, POLICY_LEVEL_MANDATORY, 171 policies->Set(
175 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 172 key::kDeviceEphemeralUsersEnabled, POLICY_LEVEL_MANDATORY,
176 base::MakeUnique<base::FundamentalValue>( 173 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
177 container.ephemeral_users_enabled()), 174 base::MakeUnique<base::Value>(container.ephemeral_users_enabled()),
178 nullptr); 175 nullptr);
179 } 176 }
180 } 177 }
181 178
182 if (policy.has_device_local_accounts()) { 179 if (policy.has_device_local_accounts()) {
183 const em::DeviceLocalAccountsProto& container( 180 const em::DeviceLocalAccountsProto& container(
184 policy.device_local_accounts()); 181 policy.device_local_accounts());
185 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = 182 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts =
186 container.account(); 183 container.account();
187 std::unique_ptr<base::ListValue> account_list(new base::ListValue()); 184 std::unique_ptr<base::ListValue> account_list(new base::ListValue());
188 for (const auto& entry : accounts) { 185 for (const auto& entry : accounts) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 base::MakeUnique<base::StringValue>(container.auto_login_id()), 239 base::MakeUnique<base::StringValue>(container.auto_login_id()),
243 nullptr); 240 nullptr);
244 } 241 }
245 if (container.has_auto_login_delay()) { 242 if (container.has_auto_login_delay()) {
246 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, 243 policies->Set(key::kDeviceLocalAccountAutoLoginDelay,
247 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 244 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
248 POLICY_SOURCE_CLOUD, 245 POLICY_SOURCE_CLOUD,
249 DecodeIntegerValue(container.auto_login_delay()), nullptr); 246 DecodeIntegerValue(container.auto_login_delay()), nullptr);
250 } 247 }
251 if (container.has_enable_auto_login_bailout()) { 248 if (container.has_enable_auto_login_bailout()) {
252 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, 249 policies->Set(
253 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 250 key::kDeviceLocalAccountAutoLoginBailoutEnabled,
254 POLICY_SOURCE_CLOUD, 251 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
255 base::MakeUnique<base::FundamentalValue>( 252 base::MakeUnique<base::Value>(container.enable_auto_login_bailout()),
256 container.enable_auto_login_bailout()), 253 nullptr);
257 nullptr);
258 } 254 }
259 if (container.has_prompt_for_network_when_offline()) { 255 if (container.has_prompt_for_network_when_offline()) {
260 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, 256 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline,
261 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 257 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
262 POLICY_SOURCE_CLOUD, 258 POLICY_SOURCE_CLOUD,
263 base::MakeUnique<base::FundamentalValue>( 259 base::MakeUnique<base::Value>(
264 container.prompt_for_network_when_offline()), 260 container.prompt_for_network_when_offline()),
265 nullptr); 261 nullptr);
266 } 262 }
267 } 263 }
268 264
269 if (policy.has_supervised_users_settings()) { 265 if (policy.has_supervised_users_settings()) {
270 const em::SupervisedUsersSettingsProto& container = 266 const em::SupervisedUsersSettingsProto& container =
271 policy.supervised_users_settings(); 267 policy.supervised_users_settings();
272 if (container.has_supervised_users_enabled()) { 268 if (container.has_supervised_users_enabled()) {
273 policies->Set(key::kSupervisedUsersEnabled, POLICY_LEVEL_MANDATORY, 269 policies->Set(
274 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 270 key::kSupervisedUsersEnabled, POLICY_LEVEL_MANDATORY,
275 base::MakeUnique<base::FundamentalValue>( 271 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
276 container.supervised_users_enabled()), 272 base::MakeUnique<base::Value>(container.supervised_users_enabled()),
277 nullptr); 273 nullptr);
278 } 274 }
279 } 275 }
280 276
281 if (policy.has_saml_settings()) { 277 if (policy.has_saml_settings()) {
282 const em::SAMLSettingsProto& container(policy.saml_settings()); 278 const em::SAMLSettingsProto& container(policy.saml_settings());
283 if (container.has_transfer_saml_cookies()) { 279 if (container.has_transfer_saml_cookies()) {
284 policies->Set(key::kDeviceTransferSAMLCookies, POLICY_LEVEL_MANDATORY, 280 policies->Set(
285 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 281 key::kDeviceTransferSAMLCookies, POLICY_LEVEL_MANDATORY,
286 base::MakeUnique<base::FundamentalValue>( 282 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
287 container.transfer_saml_cookies()), 283 base::MakeUnique<base::Value>(container.transfer_saml_cookies()),
288 nullptr); 284 nullptr);
289 } 285 }
290 } 286 }
291 287
292 if (policy.has_login_authentication_behavior()) { 288 if (policy.has_login_authentication_behavior()) {
293 const em::LoginAuthenticationBehaviorProto& container( 289 const em::LoginAuthenticationBehaviorProto& container(
294 policy.login_authentication_behavior()); 290 policy.login_authentication_behavior());
295 if (container.has_login_authentication_behavior()) { 291 if (container.has_login_authentication_behavior()) {
296 policies->Set( 292 policies->Set(
297 key::kLoginAuthenticationBehavior, POLICY_LEVEL_MANDATORY, 293 key::kLoginAuthenticationBehavior, POLICY_LEVEL_MANDATORY,
298 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 294 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
299 DecodeIntegerValue(container.login_authentication_behavior()), 295 DecodeIntegerValue(container.login_authentication_behavior()),
300 nullptr); 296 nullptr);
301 } 297 }
302 } 298 }
303 299
304 if (policy.has_allow_bluetooth()) { 300 if (policy.has_allow_bluetooth()) {
305 const em::AllowBluetoothProto& container(policy.allow_bluetooth()); 301 const em::AllowBluetoothProto& container(policy.allow_bluetooth());
306 if (container.has_allow_bluetooth()) { 302 if (container.has_allow_bluetooth()) {
307 policies->Set( 303 policies->Set(key::kDeviceAllowBluetooth, POLICY_LEVEL_MANDATORY,
308 key::kDeviceAllowBluetooth, POLICY_LEVEL_MANDATORY, 304 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
309 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 305 base::MakeUnique<base::Value>(container.allow_bluetooth()),
310 base::MakeUnique<base::FundamentalValue>(container.allow_bluetooth()), 306 nullptr);
311 nullptr);
312 } 307 }
313 } 308 }
314 309
315 if (policy.has_login_video_capture_allowed_urls()) { 310 if (policy.has_login_video_capture_allowed_urls()) {
316 const em::LoginVideoCaptureAllowedUrlsProto& container( 311 const em::LoginVideoCaptureAllowedUrlsProto& container(
317 policy.login_video_capture_allowed_urls()); 312 policy.login_video_capture_allowed_urls());
318 std::unique_ptr<base::ListValue> urls(new base::ListValue()); 313 std::unique_ptr<base::ListValue> urls(new base::ListValue());
319 for (const auto& entry : container.urls()) { 314 for (const auto& entry : container.urls()) {
320 urls->AppendString(entry); 315 urls->AppendString(entry);
321 } 316 }
(...skipping 10 matching lines...) Expand all
332 policies->Set(key::kLoginApps, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 327 policies->Set(key::kLoginApps, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
333 POLICY_SOURCE_CLOUD, std::move(login_apps), nullptr); 328 POLICY_SOURCE_CLOUD, std::move(login_apps), nullptr);
334 } 329 }
335 } 330 }
336 331
337 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, 332 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy,
338 PolicyMap* policies) { 333 PolicyMap* policies) {
339 if (policy.has_data_roaming_enabled()) { 334 if (policy.has_data_roaming_enabled()) {
340 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); 335 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled());
341 if (container.has_data_roaming_enabled()) { 336 if (container.has_data_roaming_enabled()) {
342 policies->Set(key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY, 337 policies->Set(
343 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 338 key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY,
344 base::MakeUnique<base::FundamentalValue>( 339 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
345 container.data_roaming_enabled()), 340 base::MakeUnique<base::Value>(container.data_roaming_enabled()),
346 nullptr); 341 nullptr);
347 } 342 }
348 } 343 }
349 344
350 if (policy.has_network_throttling()) { 345 if (policy.has_network_throttling()) {
351 const em::NetworkThrottlingEnabledProto& container( 346 const em::NetworkThrottlingEnabledProto& container(
352 policy.network_throttling()); 347 policy.network_throttling());
353 std::unique_ptr<base::DictionaryValue> throttling_status( 348 std::unique_ptr<base::DictionaryValue> throttling_status(
354 new base::DictionaryValue()); 349 new base::DictionaryValue());
355 bool enabled = (container.has_enabled()) ? container.enabled() : false; 350 bool enabled = (container.has_enabled()) ? container.enabled() : false;
356 uint32_t upload_rate_kbits = 351 uint32_t upload_rate_kbits =
(...skipping 18 matching lines...) Expand all
375 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 370 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
376 base::MakeUnique<base::StringValue>(config), nullptr); 371 base::MakeUnique<base::StringValue>(config), nullptr);
377 } 372 }
378 } 373 }
379 374
380 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, 375 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy,
381 PolicyMap* policies) { 376 PolicyMap* policies) {
382 if (policy.has_device_reporting()) { 377 if (policy.has_device_reporting()) {
383 const em::DeviceReportingProto& container(policy.device_reporting()); 378 const em::DeviceReportingProto& container(policy.device_reporting());
384 if (container.has_report_version_info()) { 379 if (container.has_report_version_info()) {
385 policies->Set(key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY, 380 policies->Set(
386 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 381 key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY,
387 base::MakeUnique<base::FundamentalValue>( 382 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
388 container.report_version_info()), 383 base::MakeUnique<base::Value>(container.report_version_info()),
389 nullptr); 384 nullptr);
390 } 385 }
391 if (container.has_report_activity_times()) { 386 if (container.has_report_activity_times()) {
392 policies->Set(key::kReportDeviceActivityTimes, POLICY_LEVEL_MANDATORY, 387 policies->Set(
393 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 388 key::kReportDeviceActivityTimes, POLICY_LEVEL_MANDATORY,
394 base::MakeUnique<base::FundamentalValue>( 389 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
395 container.report_activity_times()), 390 base::MakeUnique<base::Value>(container.report_activity_times()),
396 nullptr); 391 nullptr);
397 } 392 }
398 if (container.has_report_boot_mode()) { 393 if (container.has_report_boot_mode()) {
399 policies->Set(key::kReportDeviceBootMode, POLICY_LEVEL_MANDATORY, 394 policies->Set(key::kReportDeviceBootMode, POLICY_LEVEL_MANDATORY,
400 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 395 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
401 base::MakeUnique<base::FundamentalValue>( 396 base::MakeUnique<base::Value>(container.report_boot_mode()),
402 container.report_boot_mode()),
403 nullptr); 397 nullptr);
404 } 398 }
405 if (container.has_report_location()) { 399 if (container.has_report_location()) {
400 policies->Set(key::kReportDeviceLocation, POLICY_LEVEL_MANDATORY,
401 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
402 base::MakeUnique<base::Value>(container.report_location()),
403 nullptr);
404 }
405 if (container.has_report_network_interfaces()) {
406 policies->Set( 406 policies->Set(
407 key::kReportDeviceLocation, POLICY_LEVEL_MANDATORY, 407 key::kReportDeviceNetworkInterfaces, POLICY_LEVEL_MANDATORY,
408 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 408 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
409 base::MakeUnique<base::FundamentalValue>(container.report_location()), 409 base::MakeUnique<base::Value>(container.report_network_interfaces()),
410 nullptr); 410 nullptr);
411 } 411 }
412 if (container.has_report_network_interfaces()) { 412 if (container.has_report_users()) {
413 policies->Set(key::kReportDeviceNetworkInterfaces, POLICY_LEVEL_MANDATORY, 413 policies->Set(key::kReportDeviceUsers, POLICY_LEVEL_MANDATORY,
414 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 414 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
415 base::MakeUnique<base::FundamentalValue>( 415 base::MakeUnique<base::Value>(container.report_users()),
416 container.report_network_interfaces()),
417 nullptr); 416 nullptr);
418 } 417 }
419 if (container.has_report_users()) { 418 if (container.has_report_hardware_status()) {
420 policies->Set( 419 policies->Set(
421 key::kReportDeviceUsers, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 420 key::kReportDeviceHardwareStatus, POLICY_LEVEL_MANDATORY,
422 POLICY_SOURCE_CLOUD, 421 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
423 base::MakeUnique<base::FundamentalValue>(container.report_users()), 422 base::MakeUnique<base::Value>(container.report_hardware_status()),
424 nullptr); 423 nullptr);
425 } 424 }
426 if (container.has_report_hardware_status()) {
427 policies->Set(key::kReportDeviceHardwareStatus, POLICY_LEVEL_MANDATORY,
428 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
429 base::MakeUnique<base::FundamentalValue>(
430 container.report_hardware_status()),
431 nullptr);
432 }
433 if (container.has_report_session_status()) { 425 if (container.has_report_session_status()) {
434 policies->Set(key::kReportDeviceSessionStatus, POLICY_LEVEL_MANDATORY, 426 policies->Set(
435 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 427 key::kReportDeviceSessionStatus, POLICY_LEVEL_MANDATORY,
436 base::MakeUnique<base::FundamentalValue>( 428 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
437 container.report_session_status()), 429 base::MakeUnique<base::Value>(container.report_session_status()),
438 nullptr); 430 nullptr);
439 } 431 }
440 if (container.has_device_status_frequency()) { 432 if (container.has_device_status_frequency()) {
441 policies->Set(key::kReportUploadFrequency, POLICY_LEVEL_MANDATORY, 433 policies->Set(key::kReportUploadFrequency, POLICY_LEVEL_MANDATORY,
442 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 434 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
443 DecodeIntegerValue(container.device_status_frequency()), 435 DecodeIntegerValue(container.device_status_frequency()),
444 nullptr); 436 nullptr);
445 } 437 }
446 } 438 }
447 439
448 if (policy.has_device_heartbeat_settings()) { 440 if (policy.has_device_heartbeat_settings()) {
449 const em::DeviceHeartbeatSettingsProto& container( 441 const em::DeviceHeartbeatSettingsProto& container(
450 policy.device_heartbeat_settings()); 442 policy.device_heartbeat_settings());
451 if (container.has_heartbeat_enabled()) { 443 if (container.has_heartbeat_enabled()) {
452 policies->Set(key::kHeartbeatEnabled, POLICY_LEVEL_MANDATORY, 444 policies->Set(
453 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 445 key::kHeartbeatEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
454 base::MakeUnique<base::FundamentalValue>( 446 POLICY_SOURCE_CLOUD,
455 container.heartbeat_enabled()), 447 base::MakeUnique<base::Value>(container.heartbeat_enabled()),
456 nullptr); 448 nullptr);
457 } 449 }
458 if (container.has_heartbeat_frequency()) { 450 if (container.has_heartbeat_frequency()) {
459 policies->Set(key::kHeartbeatFrequency, POLICY_LEVEL_MANDATORY, 451 policies->Set(key::kHeartbeatFrequency, POLICY_LEVEL_MANDATORY,
460 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 452 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
461 DecodeIntegerValue(container.heartbeat_frequency()), 453 DecodeIntegerValue(container.heartbeat_frequency()),
462 nullptr); 454 nullptr);
463 } 455 }
464 } 456 }
465 457
466 if (policy.has_device_log_upload_settings()) { 458 if (policy.has_device_log_upload_settings()) {
467 const em::DeviceLogUploadSettingsProto& container( 459 const em::DeviceLogUploadSettingsProto& container(
468 policy.device_log_upload_settings()); 460 policy.device_log_upload_settings());
469 if (container.has_system_log_upload_enabled()) { 461 if (container.has_system_log_upload_enabled()) {
470 policies->Set(key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, 462 policies->Set(
471 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 463 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
472 base::MakeUnique<base::FundamentalValue>( 464 POLICY_SOURCE_CLOUD,
473 container.system_log_upload_enabled()), 465 base::MakeUnique<base::Value>(container.system_log_upload_enabled()),
474 nullptr); 466 nullptr);
475 } 467 }
476 } 468 }
477 } 469 }
478 470
479 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, 471 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy,
480 PolicyMap* policies) { 472 PolicyMap* policies) {
481 if (policy.has_release_channel()) { 473 if (policy.has_release_channel()) {
482 const em::ReleaseChannelProto& container(policy.release_channel()); 474 const em::ReleaseChannelProto& container(policy.release_channel());
483 if (container.has_release_channel()) { 475 if (container.has_release_channel()) {
484 std::string channel(container.release_channel()); 476 std::string channel(container.release_channel());
485 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY, 477 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY,
486 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 478 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
487 base::MakeUnique<base::StringValue>(channel), nullptr); 479 base::MakeUnique<base::StringValue>(channel), nullptr);
488 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't 480 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't
489 // have to pass the channel in here, only ping the update engine to tell 481 // have to pass the channel in here, only ping the update engine to tell
490 // it to fetch the channel from the policy. 482 // it to fetch the channel from the policy.
491 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> 483 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
492 SetChannel(channel, false); 484 SetChannel(channel, false);
493 } 485 }
494 if (container.has_release_channel_delegated()) { 486 if (container.has_release_channel_delegated()) {
495 policies->Set(key::kChromeOsReleaseChannelDelegated, 487 policies->Set(
496 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 488 key::kChromeOsReleaseChannelDelegated, POLICY_LEVEL_MANDATORY,
497 POLICY_SOURCE_CLOUD, 489 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
498 base::MakeUnique<base::FundamentalValue>( 490 base::MakeUnique<base::Value>(container.release_channel_delegated()),
499 container.release_channel_delegated()), 491 nullptr);
500 nullptr);
501 } 492 }
502 } 493 }
503 494
504 if (policy.has_auto_update_settings()) { 495 if (policy.has_auto_update_settings()) {
505 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); 496 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings());
506 if (container.has_update_disabled()) { 497 if (container.has_update_disabled()) {
507 policies->Set( 498 policies->Set(key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY,
508 key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY, 499 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
509 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 500 base::MakeUnique<base::Value>(container.update_disabled()),
510 base::MakeUnique<base::FundamentalValue>(container.update_disabled()), 501 nullptr);
511 nullptr);
512 } 502 }
513 503
514 if (container.has_target_version_prefix()) { 504 if (container.has_target_version_prefix()) {
515 policies->Set(key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY, 505 policies->Set(key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY,
516 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 506 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
517 base::MakeUnique<base::StringValue>( 507 base::MakeUnique<base::StringValue>(
518 container.target_version_prefix()), 508 container.target_version_prefix()),
519 nullptr); 509 nullptr);
520 } 510 }
521 511
522 // target_version_display_name is not actually a policy, but a display 512 // target_version_display_name is not actually a policy, but a display
523 // string for target_version_prefix, so we ignore it. 513 // string for target_version_prefix, so we ignore it.
524 514
525 if (container.has_scatter_factor_in_seconds()) { 515 if (container.has_scatter_factor_in_seconds()) {
526 // TODO(dcheng): Shouldn't this use DecodeIntegerValue? 516 // TODO(dcheng): Shouldn't this use DecodeIntegerValue?
527 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY, 517 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY,
528 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 518 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
529 base::MakeUnique<base::FundamentalValue>(static_cast<int>( 519 base::MakeUnique<base::Value>(static_cast<int>(
530 container.scatter_factor_in_seconds())), 520 container.scatter_factor_in_seconds())),
531 nullptr); 521 nullptr);
532 } 522 }
533 523
534 if (container.allowed_connection_types_size()) { 524 if (container.allowed_connection_types_size()) {
535 std::unique_ptr<base::ListValue> allowed_connection_types( 525 std::unique_ptr<base::ListValue> allowed_connection_types(
536 new base::ListValue); 526 new base::ListValue);
537 for (const auto& entry : container.allowed_connection_types()) { 527 for (const auto& entry : container.allowed_connection_types()) {
538 std::unique_ptr<base::Value> value = DecodeConnectionType(entry); 528 std::unique_ptr<base::Value> value = DecodeConnectionType(entry);
539 if (value) 529 if (value)
540 allowed_connection_types->Append(std::move(value)); 530 allowed_connection_types->Append(std::move(value));
541 } 531 }
542 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, 532 policies->Set(key::kDeviceUpdateAllowedConnectionTypes,
543 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 533 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
544 POLICY_SOURCE_CLOUD, std::move(allowed_connection_types), 534 POLICY_SOURCE_CLOUD, std::move(allowed_connection_types),
545 nullptr); 535 nullptr);
546 } 536 }
547 537
548 if (container.has_http_downloads_enabled()) { 538 if (container.has_http_downloads_enabled()) {
549 policies->Set(key::kDeviceUpdateHttpDownloadsEnabled, 539 policies->Set(
550 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 540 key::kDeviceUpdateHttpDownloadsEnabled, POLICY_LEVEL_MANDATORY,
551 POLICY_SOURCE_CLOUD, 541 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
552 base::MakeUnique<base::FundamentalValue>( 542 base::MakeUnique<base::Value>(container.http_downloads_enabled()),
553 container.http_downloads_enabled()), 543 nullptr);
554 nullptr);
555 } 544 }
556 545
557 if (container.has_reboot_after_update()) { 546 if (container.has_reboot_after_update()) {
558 policies->Set(key::kRebootAfterUpdate, POLICY_LEVEL_MANDATORY, 547 policies->Set(
559 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 548 key::kRebootAfterUpdate, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
560 base::MakeUnique<base::FundamentalValue>( 549 POLICY_SOURCE_CLOUD,
561 container.reboot_after_update()), 550 base::MakeUnique<base::Value>(container.reboot_after_update()),
562 nullptr); 551 nullptr);
563 } 552 }
564 553
565 if (container.has_p2p_enabled()) { 554 if (container.has_p2p_enabled()) {
566 policies->Set( 555 policies->Set(key::kDeviceAutoUpdateP2PEnabled, POLICY_LEVEL_MANDATORY,
567 key::kDeviceAutoUpdateP2PEnabled, POLICY_LEVEL_MANDATORY, 556 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
568 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 557 base::MakeUnique<base::Value>(container.p2p_enabled()),
569 base::MakeUnique<base::FundamentalValue>(container.p2p_enabled()), 558 nullptr);
570 nullptr);
571 } 559 }
572 } 560 }
573 561
574 if (policy.has_allow_kiosk_app_control_chrome_version()) { 562 if (policy.has_allow_kiosk_app_control_chrome_version()) {
575 const em::AllowKioskAppControlChromeVersionProto& container( 563 const em::AllowKioskAppControlChromeVersionProto& container(
576 policy.allow_kiosk_app_control_chrome_version()); 564 policy.allow_kiosk_app_control_chrome_version());
577 if (container.has_allow_kiosk_app_control_chrome_version()) { 565 if (container.has_allow_kiosk_app_control_chrome_version()) {
578 policies->Set(key::kAllowKioskAppControlChromeVersion, 566 policies->Set(key::kAllowKioskAppControlChromeVersion,
579 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 567 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
580 POLICY_SOURCE_CLOUD, 568 POLICY_SOURCE_CLOUD,
581 base::MakeUnique<base::FundamentalValue>( 569 base::MakeUnique<base::Value>(
582 container.allow_kiosk_app_control_chrome_version()), 570 container.allow_kiosk_app_control_chrome_version()),
583 nullptr); 571 nullptr);
584 } 572 }
585 } 573 }
586 } 574 }
587 575
588 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, 576 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy,
589 PolicyMap* policies) { 577 PolicyMap* policies) {
590 if (policy.has_accessibility_settings()) { 578 if (policy.has_accessibility_settings()) {
591 const em::AccessibilitySettingsProto& 579 const em::AccessibilitySettingsProto&
592 container(policy.accessibility_settings()); 580 container(policy.accessibility_settings());
593 581
594 if (container.has_login_screen_default_large_cursor_enabled()) { 582 if (container.has_login_screen_default_large_cursor_enabled()) {
595 policies->Set(key::kDeviceLoginScreenDefaultLargeCursorEnabled, 583 policies->Set(key::kDeviceLoginScreenDefaultLargeCursorEnabled,
596 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 584 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
597 POLICY_SOURCE_CLOUD, 585 POLICY_SOURCE_CLOUD,
598 base::MakeUnique<base::FundamentalValue>( 586 base::MakeUnique<base::Value>(
599 container.login_screen_default_large_cursor_enabled()), 587 container.login_screen_default_large_cursor_enabled()),
600 nullptr); 588 nullptr);
601 } 589 }
602 590
603 if (container.has_login_screen_default_spoken_feedback_enabled()) { 591 if (container.has_login_screen_default_spoken_feedback_enabled()) {
604 policies->Set( 592 policies->Set(
605 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, 593 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled,
606 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 594 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
607 base::MakeUnique<base::FundamentalValue>( 595 base::MakeUnique<base::Value>(
608 container.login_screen_default_spoken_feedback_enabled()), 596 container.login_screen_default_spoken_feedback_enabled()),
609 nullptr); 597 nullptr);
610 } 598 }
611 599
612 if (container.has_login_screen_default_high_contrast_enabled()) { 600 if (container.has_login_screen_default_high_contrast_enabled()) {
613 policies->Set(key::kDeviceLoginScreenDefaultHighContrastEnabled, 601 policies->Set(key::kDeviceLoginScreenDefaultHighContrastEnabled,
614 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 602 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
615 POLICY_SOURCE_CLOUD, 603 POLICY_SOURCE_CLOUD,
616 base::MakeUnique<base::FundamentalValue>( 604 base::MakeUnique<base::Value>(
617 container.login_screen_default_high_contrast_enabled()), 605 container.login_screen_default_high_contrast_enabled()),
618 nullptr); 606 nullptr);
619 } 607 }
620 608
621 if (container.has_login_screen_default_screen_magnifier_type()) { 609 if (container.has_login_screen_default_screen_magnifier_type()) {
622 policies->Set(key::kDeviceLoginScreenDefaultScreenMagnifierType, 610 policies->Set(key::kDeviceLoginScreenDefaultScreenMagnifierType,
623 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 611 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
624 POLICY_SOURCE_CLOUD, 612 POLICY_SOURCE_CLOUD,
625 DecodeIntegerValue( 613 DecodeIntegerValue(
626 container.login_screen_default_screen_magnifier_type()), 614 container.login_screen_default_screen_magnifier_type()),
627 nullptr); 615 nullptr);
628 } 616 }
629 617
630 if (container.has_login_screen_default_virtual_keyboard_enabled()) { 618 if (container.has_login_screen_default_virtual_keyboard_enabled()) {
631 policies->Set( 619 policies->Set(
632 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, 620 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled,
633 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 621 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
634 base::MakeUnique<base::FundamentalValue>( 622 base::MakeUnique<base::Value>(
635 container.login_screen_default_virtual_keyboard_enabled()), 623 container.login_screen_default_virtual_keyboard_enabled()),
636 nullptr); 624 nullptr);
637 } 625 }
638 } 626 }
639 } 627 }
640 628
641 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, 629 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy,
642 PolicyMap* policies) { 630 PolicyMap* policies) {
643 if (policy.has_device_policy_refresh_rate()) { 631 if (policy.has_device_policy_refresh_rate()) {
644 const em::DevicePolicyRefreshRateProto& container( 632 const em::DevicePolicyRefreshRateProto& container(
645 policy.device_policy_refresh_rate()); 633 policy.device_policy_refresh_rate());
646 if (container.has_device_policy_refresh_rate()) { 634 if (container.has_device_policy_refresh_rate()) {
647 policies->Set(key::kDevicePolicyRefreshRate, POLICY_LEVEL_MANDATORY, 635 policies->Set(key::kDevicePolicyRefreshRate, POLICY_LEVEL_MANDATORY,
648 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 636 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
649 DecodeIntegerValue(container.device_policy_refresh_rate()), 637 DecodeIntegerValue(container.device_policy_refresh_rate()),
650 nullptr); 638 nullptr);
651 } 639 }
652 } 640 }
653 641
654 if (policy.has_metrics_enabled()) { 642 if (policy.has_metrics_enabled()) {
655 const em::MetricsEnabledProto& container(policy.metrics_enabled()); 643 const em::MetricsEnabledProto& container(policy.metrics_enabled());
656 if (container.has_metrics_enabled()) { 644 if (container.has_metrics_enabled()) {
657 policies->Set( 645 policies->Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY,
658 key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, 646 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
659 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 647 base::MakeUnique<base::Value>(container.metrics_enabled()),
660 base::MakeUnique<base::FundamentalValue>(container.metrics_enabled()), 648 nullptr);
661 nullptr);
662 } 649 }
663 } 650 }
664 651
665 if (policy.has_system_timezone()) { 652 if (policy.has_system_timezone()) {
666 if (policy.system_timezone().has_timezone()) { 653 if (policy.system_timezone().has_timezone()) {
667 policies->Set(key::kSystemTimezone, POLICY_LEVEL_MANDATORY, 654 policies->Set(key::kSystemTimezone, POLICY_LEVEL_MANDATORY,
668 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 655 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
669 base::MakeUnique<base::StringValue>( 656 base::MakeUnique<base::StringValue>(
670 policy.system_timezone().timezone()), 657 policy.system_timezone().timezone()),
671 nullptr); 658 nullptr);
672 } 659 }
673 660
674 if (policy.system_timezone().has_timezone_detection_type()) { 661 if (policy.system_timezone().has_timezone_detection_type()) {
675 std::unique_ptr<base::Value> value(DecodeIntegerValue( 662 std::unique_ptr<base::Value> value(DecodeIntegerValue(
676 policy.system_timezone().timezone_detection_type())); 663 policy.system_timezone().timezone_detection_type()));
677 if (value) { 664 if (value) {
678 policies->Set(key::kSystemTimezoneAutomaticDetection, 665 policies->Set(key::kSystemTimezoneAutomaticDetection,
679 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 666 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
680 POLICY_SOURCE_CLOUD, std::move(value), nullptr); 667 POLICY_SOURCE_CLOUD, std::move(value), nullptr);
681 } 668 }
682 } 669 }
683 } 670 }
684 671
685 if (policy.has_use_24hour_clock()) { 672 if (policy.has_use_24hour_clock()) {
686 if (policy.use_24hour_clock().has_use_24hour_clock()) { 673 if (policy.use_24hour_clock().has_use_24hour_clock()) {
687 policies->Set(key::kSystemUse24HourClock, POLICY_LEVEL_MANDATORY, 674 policies->Set(key::kSystemUse24HourClock, POLICY_LEVEL_MANDATORY,
688 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 675 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
689 base::MakeUnique<base::FundamentalValue>( 676 base::MakeUnique<base::Value>(
690 policy.use_24hour_clock().use_24hour_clock()), 677 policy.use_24hour_clock().use_24hour_clock()),
691 nullptr); 678 nullptr);
692 } 679 }
693 } 680 }
694 681
695 if (policy.has_allow_redeem_offers()) { 682 if (policy.has_allow_redeem_offers()) {
696 const em::AllowRedeemChromeOsRegistrationOffersProto& container( 683 const em::AllowRedeemChromeOsRegistrationOffersProto& container(
697 policy.allow_redeem_offers()); 684 policy.allow_redeem_offers());
698 if (container.has_allow_redeem_offers()) { 685 if (container.has_allow_redeem_offers()) {
699 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, 686 policies->Set(
700 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 687 key::kDeviceAllowRedeemChromeOsRegistrationOffers,
701 POLICY_SOURCE_CLOUD, 688 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
702 base::MakeUnique<base::FundamentalValue>( 689 base::MakeUnique<base::Value>(container.allow_redeem_offers()),
703 container.allow_redeem_offers()), 690 nullptr);
704 nullptr);
705 } 691 }
706 } 692 }
707 693
708 if (policy.has_uptime_limit()) { 694 if (policy.has_uptime_limit()) {
709 const em::UptimeLimitProto& container(policy.uptime_limit()); 695 const em::UptimeLimitProto& container(policy.uptime_limit());
710 if (container.has_uptime_limit()) { 696 if (container.has_uptime_limit()) {
711 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY, 697 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY,
712 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 698 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
713 DecodeIntegerValue(container.uptime_limit()), nullptr); 699 DecodeIntegerValue(container.uptime_limit()), nullptr);
714 } 700 }
(...skipping 17 matching lines...) Expand all
732 base::MakeUnique<base::StringValue>( 718 base::MakeUnique<base::StringValue>(
733 policy.variations_parameter().parameter()), 719 policy.variations_parameter().parameter()),
734 nullptr); 720 nullptr);
735 } 721 }
736 } 722 }
737 723
738 if (policy.has_attestation_settings()) { 724 if (policy.has_attestation_settings()) {
739 if (policy.attestation_settings().has_attestation_enabled()) { 725 if (policy.attestation_settings().has_attestation_enabled()) {
740 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY, 726 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY,
741 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 727 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
742 base::MakeUnique<base::FundamentalValue>( 728 base::MakeUnique<base::Value>(
743 policy.attestation_settings().attestation_enabled()), 729 policy.attestation_settings().attestation_enabled()),
744 nullptr); 730 nullptr);
745 } 731 }
746 if (policy.attestation_settings().has_content_protection_enabled()) { 732 if (policy.attestation_settings().has_content_protection_enabled()) {
747 policies->Set( 733 policies->Set(
748 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY, 734 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY,
749 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 735 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
750 base::MakeUnique<base::FundamentalValue>( 736 base::MakeUnique<base::Value>(
751 policy.attestation_settings().content_protection_enabled()), 737 policy.attestation_settings().content_protection_enabled()),
752 nullptr); 738 nullptr);
753 } 739 }
754 } 740 }
755 741
756 if (policy.has_login_screen_power_management()) { 742 if (policy.has_login_screen_power_management()) {
757 const em::LoginScreenPowerManagementProto& container( 743 const em::LoginScreenPowerManagementProto& container(
758 policy.login_screen_power_management()); 744 policy.login_screen_power_management());
759 if (container.has_login_screen_power_management()) { 745 if (container.has_login_screen_power_management()) {
760 std::unique_ptr<base::Value> decoded_json; 746 std::unique_ptr<base::Value> decoded_json;
761 decoded_json = DecodeJsonStringAndDropUnknownBySchema( 747 decoded_json = DecodeJsonStringAndDropUnknownBySchema(
762 container.login_screen_power_management(), 748 container.login_screen_power_management(),
763 key::kDeviceLoginScreenPowerManagement); 749 key::kDeviceLoginScreenPowerManagement);
764 if (decoded_json) { 750 if (decoded_json) {
765 policies->Set(key::kDeviceLoginScreenPowerManagement, 751 policies->Set(key::kDeviceLoginScreenPowerManagement,
766 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 752 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
767 POLICY_SOURCE_CLOUD, std::move(decoded_json), nullptr); 753 POLICY_SOURCE_CLOUD, std::move(decoded_json), nullptr);
768 } 754 }
769 } 755 }
770 } 756 }
771 757
772 if (policy.has_system_settings()) { 758 if (policy.has_system_settings()) {
773 const em::SystemSettingsProto& container(policy.system_settings()); 759 const em::SystemSettingsProto& container(policy.system_settings());
774 if (container.has_block_devmode()) { 760 if (container.has_block_devmode()) {
775 policies->Set( 761 policies->Set(key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY,
776 key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY, 762 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
777 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 763 base::MakeUnique<base::Value>(container.block_devmode()),
778 base::MakeUnique<base::FundamentalValue>(container.block_devmode()), 764 nullptr);
779 nullptr);
780 } 765 }
781 } 766 }
782 767
783 if (policy.has_extension_cache_size()) { 768 if (policy.has_extension_cache_size()) {
784 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); 769 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size());
785 if (container.has_extension_cache_size()) { 770 if (container.has_extension_cache_size()) {
786 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, 771 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY,
787 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 772 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
788 DecodeIntegerValue(container.extension_cache_size()), 773 DecodeIntegerValue(container.extension_cache_size()),
789 nullptr); 774 nullptr);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 811 }
827 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY, 812 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY,
828 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 813 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
829 std::move(whitelist), nullptr); 814 std::move(whitelist), nullptr);
830 } 815 }
831 816
832 if (policy.has_quirks_download_enabled()) { 817 if (policy.has_quirks_download_enabled()) {
833 const em::DeviceQuirksDownloadEnabledProto& container( 818 const em::DeviceQuirksDownloadEnabledProto& container(
834 policy.quirks_download_enabled()); 819 policy.quirks_download_enabled());
835 if (container.has_quirks_download_enabled()) { 820 if (container.has_quirks_download_enabled()) {
836 policies->Set(key::kDeviceQuirksDownloadEnabled, POLICY_LEVEL_MANDATORY, 821 policies->Set(
837 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 822 key::kDeviceQuirksDownloadEnabled, POLICY_LEVEL_MANDATORY,
838 base::MakeUnique<base::FundamentalValue>( 823 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
839 container.quirks_download_enabled()), 824 base::MakeUnique<base::Value>(container.quirks_download_enabled()),
840 nullptr); 825 nullptr);
841 } 826 }
842 } 827 }
843 } 828 }
844 829
845 } // namespace 830 } // namespace
846 831
847 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, 832 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
848 PolicyMap* policies) { 833 PolicyMap* policies) {
849 // Decode the various groups of policies. 834 // Decode the various groups of policies.
850 DecodeLoginPolicies(policy, policies); 835 DecodeLoginPolicies(policy, policies);
851 DecodeNetworkPolicies(policy, policies); 836 DecodeNetworkPolicies(policy, policies);
852 DecodeReportingPolicies(policy, policies); 837 DecodeReportingPolicies(policy, policies);
853 DecodeAutoUpdatePolicies(policy, policies); 838 DecodeAutoUpdatePolicies(policy, policies);
854 DecodeAccessibilityPolicies(policy, policies); 839 DecodeAccessibilityPolicies(policy, policies);
855 DecodeGenericPolicies(policy, policies); 840 DecodeGenericPolicies(policy, policies);
856 } 841 }
857 842
858 } // namespace policy 843 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698