| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 base::MakeUnique<base::StringValue>(container.auto_login_id()), | 244 base::MakeUnique<base::StringValue>(container.auto_login_id()), |
| 248 nullptr); | 245 nullptr); |
| 249 } | 246 } |
| 250 if (container.has_auto_login_delay()) { | 247 if (container.has_auto_login_delay()) { |
| 251 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, | 248 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, |
| 252 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 249 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 253 POLICY_SOURCE_CLOUD, | 250 POLICY_SOURCE_CLOUD, |
| 254 DecodeIntegerValue(container.auto_login_delay()), nullptr); | 251 DecodeIntegerValue(container.auto_login_delay()), nullptr); |
| 255 } | 252 } |
| 256 if (container.has_enable_auto_login_bailout()) { | 253 if (container.has_enable_auto_login_bailout()) { |
| 257 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, | 254 policies->Set( |
| 258 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 255 key::kDeviceLocalAccountAutoLoginBailoutEnabled, |
| 259 POLICY_SOURCE_CLOUD, | 256 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 260 base::MakeUnique<base::FundamentalValue>( | 257 base::MakeUnique<base::Value>(container.enable_auto_login_bailout()), |
| 261 container.enable_auto_login_bailout()), | 258 nullptr); |
| 262 nullptr); | |
| 263 } | 259 } |
| 264 if (container.has_prompt_for_network_when_offline()) { | 260 if (container.has_prompt_for_network_when_offline()) { |
| 265 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, | 261 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, |
| 266 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 262 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 267 POLICY_SOURCE_CLOUD, | 263 POLICY_SOURCE_CLOUD, |
| 268 base::MakeUnique<base::FundamentalValue>( | 264 base::MakeUnique<base::Value>( |
| 269 container.prompt_for_network_when_offline()), | 265 container.prompt_for_network_when_offline()), |
| 270 nullptr); | 266 nullptr); |
| 271 } | 267 } |
| 272 } | 268 } |
| 273 | 269 |
| 274 if (policy.has_supervised_users_settings()) { | 270 if (policy.has_supervised_users_settings()) { |
| 275 const em::SupervisedUsersSettingsProto& container = | 271 const em::SupervisedUsersSettingsProto& container = |
| 276 policy.supervised_users_settings(); | 272 policy.supervised_users_settings(); |
| 277 if (container.has_supervised_users_enabled()) { | 273 if (container.has_supervised_users_enabled()) { |
| 278 policies->Set(key::kSupervisedUsersEnabled, POLICY_LEVEL_MANDATORY, | 274 policies->Set( |
| 279 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 275 key::kSupervisedUsersEnabled, POLICY_LEVEL_MANDATORY, |
| 280 base::MakeUnique<base::FundamentalValue>( | 276 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 281 container.supervised_users_enabled()), | 277 base::MakeUnique<base::Value>(container.supervised_users_enabled()), |
| 282 nullptr); | 278 nullptr); |
| 283 } | 279 } |
| 284 } | 280 } |
| 285 | 281 |
| 286 if (policy.has_saml_settings()) { | 282 if (policy.has_saml_settings()) { |
| 287 const em::SAMLSettingsProto& container(policy.saml_settings()); | 283 const em::SAMLSettingsProto& container(policy.saml_settings()); |
| 288 if (container.has_transfer_saml_cookies()) { | 284 if (container.has_transfer_saml_cookies()) { |
| 289 policies->Set(key::kDeviceTransferSAMLCookies, POLICY_LEVEL_MANDATORY, | 285 policies->Set( |
| 290 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 286 key::kDeviceTransferSAMLCookies, POLICY_LEVEL_MANDATORY, |
| 291 base::MakeUnique<base::FundamentalValue>( | 287 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 292 container.transfer_saml_cookies()), | 288 base::MakeUnique<base::Value>(container.transfer_saml_cookies()), |
| 293 nullptr); | 289 nullptr); |
| 294 } | 290 } |
| 295 } | 291 } |
| 296 | 292 |
| 297 if (policy.has_login_authentication_behavior()) { | 293 if (policy.has_login_authentication_behavior()) { |
| 298 const em::LoginAuthenticationBehaviorProto& container( | 294 const em::LoginAuthenticationBehaviorProto& container( |
| 299 policy.login_authentication_behavior()); | 295 policy.login_authentication_behavior()); |
| 300 if (container.has_login_authentication_behavior()) { | 296 if (container.has_login_authentication_behavior()) { |
| 301 policies->Set( | 297 policies->Set( |
| 302 key::kLoginAuthenticationBehavior, POLICY_LEVEL_MANDATORY, | 298 key::kLoginAuthenticationBehavior, POLICY_LEVEL_MANDATORY, |
| 303 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 299 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 304 DecodeIntegerValue(container.login_authentication_behavior()), | 300 DecodeIntegerValue(container.login_authentication_behavior()), |
| 305 nullptr); | 301 nullptr); |
| 306 } | 302 } |
| 307 } | 303 } |
| 308 | 304 |
| 309 if (policy.has_allow_bluetooth()) { | 305 if (policy.has_allow_bluetooth()) { |
| 310 const em::AllowBluetoothProto& container(policy.allow_bluetooth()); | 306 const em::AllowBluetoothProto& container(policy.allow_bluetooth()); |
| 311 if (container.has_allow_bluetooth()) { | 307 if (container.has_allow_bluetooth()) { |
| 312 policies->Set( | 308 policies->Set(key::kDeviceAllowBluetooth, POLICY_LEVEL_MANDATORY, |
| 313 key::kDeviceAllowBluetooth, POLICY_LEVEL_MANDATORY, | 309 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 314 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 310 base::MakeUnique<base::Value>(container.allow_bluetooth()), |
| 315 base::MakeUnique<base::FundamentalValue>(container.allow_bluetooth()), | 311 nullptr); |
| 316 nullptr); | |
| 317 } | 312 } |
| 318 } | 313 } |
| 319 | 314 |
| 320 if (policy.has_login_video_capture_allowed_urls()) { | 315 if (policy.has_login_video_capture_allowed_urls()) { |
| 321 const em::LoginVideoCaptureAllowedUrlsProto& container( | 316 const em::LoginVideoCaptureAllowedUrlsProto& container( |
| 322 policy.login_video_capture_allowed_urls()); | 317 policy.login_video_capture_allowed_urls()); |
| 323 std::unique_ptr<base::ListValue> urls(new base::ListValue()); | 318 std::unique_ptr<base::ListValue> urls(new base::ListValue()); |
| 324 for (const auto& entry : container.urls()) { | 319 for (const auto& entry : container.urls()) { |
| 325 urls->AppendString(entry); | 320 urls->AppendString(entry); |
| 326 } | 321 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 384 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 390 std::move(input_methods), nullptr); | 385 std::move(input_methods), nullptr); |
| 391 } | 386 } |
| 392 } | 387 } |
| 393 | 388 |
| 394 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, | 389 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 395 PolicyMap* policies) { | 390 PolicyMap* policies) { |
| 396 if (policy.has_data_roaming_enabled()) { | 391 if (policy.has_data_roaming_enabled()) { |
| 397 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); | 392 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); |
| 398 if (container.has_data_roaming_enabled()) { | 393 if (container.has_data_roaming_enabled()) { |
| 399 policies->Set(key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY, | 394 policies->Set( |
| 400 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 395 key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY, |
| 401 base::MakeUnique<base::FundamentalValue>( | 396 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 402 container.data_roaming_enabled()), | 397 base::MakeUnique<base::Value>(container.data_roaming_enabled()), |
| 403 nullptr); | 398 nullptr); |
| 404 } | 399 } |
| 405 } | 400 } |
| 406 | 401 |
| 407 if (policy.has_network_throttling()) { | 402 if (policy.has_network_throttling()) { |
| 408 const em::NetworkThrottlingEnabledProto& container( | 403 const em::NetworkThrottlingEnabledProto& container( |
| 409 policy.network_throttling()); | 404 policy.network_throttling()); |
| 410 std::unique_ptr<base::DictionaryValue> throttling_status( | 405 std::unique_ptr<base::DictionaryValue> throttling_status( |
| 411 new base::DictionaryValue()); | 406 new base::DictionaryValue()); |
| 412 bool enabled = (container.has_enabled()) ? container.enabled() : false; | 407 bool enabled = (container.has_enabled()) ? container.enabled() : false; |
| 413 uint32_t upload_rate_kbits = | 408 uint32_t upload_rate_kbits = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 432 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 427 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 433 base::MakeUnique<base::StringValue>(config), nullptr); | 428 base::MakeUnique<base::StringValue>(config), nullptr); |
| 434 } | 429 } |
| 435 } | 430 } |
| 436 | 431 |
| 437 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, | 432 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 438 PolicyMap* policies) { | 433 PolicyMap* policies) { |
| 439 if (policy.has_device_reporting()) { | 434 if (policy.has_device_reporting()) { |
| 440 const em::DeviceReportingProto& container(policy.device_reporting()); | 435 const em::DeviceReportingProto& container(policy.device_reporting()); |
| 441 if (container.has_report_version_info()) { | 436 if (container.has_report_version_info()) { |
| 442 policies->Set(key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY, | 437 policies->Set( |
| 443 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 438 key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY, |
| 444 base::MakeUnique<base::FundamentalValue>( | 439 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 445 container.report_version_info()), | 440 base::MakeUnique<base::Value>(container.report_version_info()), |
| 446 nullptr); | 441 nullptr); |
| 447 } | 442 } |
| 448 if (container.has_report_activity_times()) { | 443 if (container.has_report_activity_times()) { |
| 449 policies->Set(key::kReportDeviceActivityTimes, POLICY_LEVEL_MANDATORY, | 444 policies->Set( |
| 450 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 445 key::kReportDeviceActivityTimes, POLICY_LEVEL_MANDATORY, |
| 451 base::MakeUnique<base::FundamentalValue>( | 446 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 452 container.report_activity_times()), | 447 base::MakeUnique<base::Value>(container.report_activity_times()), |
| 453 nullptr); | 448 nullptr); |
| 454 } | 449 } |
| 455 if (container.has_report_boot_mode()) { | 450 if (container.has_report_boot_mode()) { |
| 456 policies->Set(key::kReportDeviceBootMode, POLICY_LEVEL_MANDATORY, | 451 policies->Set(key::kReportDeviceBootMode, POLICY_LEVEL_MANDATORY, |
| 457 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 452 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 458 base::MakeUnique<base::FundamentalValue>( | 453 base::MakeUnique<base::Value>(container.report_boot_mode()), |
| 459 container.report_boot_mode()), | |
| 460 nullptr); | 454 nullptr); |
| 461 } | 455 } |
| 462 if (container.has_report_location()) { | 456 if (container.has_report_location()) { |
| 457 policies->Set(key::kReportDeviceLocation, POLICY_LEVEL_MANDATORY, |
| 458 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 459 base::MakeUnique<base::Value>(container.report_location()), |
| 460 nullptr); |
| 461 } |
| 462 if (container.has_report_network_interfaces()) { |
| 463 policies->Set( | 463 policies->Set( |
| 464 key::kReportDeviceLocation, POLICY_LEVEL_MANDATORY, | 464 key::kReportDeviceNetworkInterfaces, POLICY_LEVEL_MANDATORY, |
| 465 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 465 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 466 base::MakeUnique<base::FundamentalValue>(container.report_location()), | 466 base::MakeUnique<base::Value>(container.report_network_interfaces()), |
| 467 nullptr); | 467 nullptr); |
| 468 } | 468 } |
| 469 if (container.has_report_network_interfaces()) { | 469 if (container.has_report_users()) { |
| 470 policies->Set(key::kReportDeviceNetworkInterfaces, POLICY_LEVEL_MANDATORY, | 470 policies->Set(key::kReportDeviceUsers, POLICY_LEVEL_MANDATORY, |
| 471 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 471 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 472 base::MakeUnique<base::FundamentalValue>( | 472 base::MakeUnique<base::Value>(container.report_users()), |
| 473 container.report_network_interfaces()), | |
| 474 nullptr); | 473 nullptr); |
| 475 } | 474 } |
| 476 if (container.has_report_users()) { | 475 if (container.has_report_hardware_status()) { |
| 477 policies->Set( | 476 policies->Set( |
| 478 key::kReportDeviceUsers, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 477 key::kReportDeviceHardwareStatus, POLICY_LEVEL_MANDATORY, |
| 479 POLICY_SOURCE_CLOUD, | 478 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 480 base::MakeUnique<base::FundamentalValue>(container.report_users()), | 479 base::MakeUnique<base::Value>(container.report_hardware_status()), |
| 481 nullptr); | 480 nullptr); |
| 482 } | 481 } |
| 483 if (container.has_report_hardware_status()) { | |
| 484 policies->Set(key::kReportDeviceHardwareStatus, POLICY_LEVEL_MANDATORY, | |
| 485 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | |
| 486 base::MakeUnique<base::FundamentalValue>( | |
| 487 container.report_hardware_status()), | |
| 488 nullptr); | |
| 489 } | |
| 490 if (container.has_report_session_status()) { | 482 if (container.has_report_session_status()) { |
| 491 policies->Set(key::kReportDeviceSessionStatus, POLICY_LEVEL_MANDATORY, | 483 policies->Set( |
| 492 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 484 key::kReportDeviceSessionStatus, POLICY_LEVEL_MANDATORY, |
| 493 base::MakeUnique<base::FundamentalValue>( | 485 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 494 container.report_session_status()), | 486 base::MakeUnique<base::Value>(container.report_session_status()), |
| 495 nullptr); | 487 nullptr); |
| 496 } | 488 } |
| 497 if (container.has_device_status_frequency()) { | 489 if (container.has_device_status_frequency()) { |
| 498 policies->Set(key::kReportUploadFrequency, POLICY_LEVEL_MANDATORY, | 490 policies->Set(key::kReportUploadFrequency, POLICY_LEVEL_MANDATORY, |
| 499 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 491 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 500 DecodeIntegerValue(container.device_status_frequency()), | 492 DecodeIntegerValue(container.device_status_frequency()), |
| 501 nullptr); | 493 nullptr); |
| 502 } | 494 } |
| 503 } | 495 } |
| 504 | 496 |
| 505 if (policy.has_device_heartbeat_settings()) { | 497 if (policy.has_device_heartbeat_settings()) { |
| 506 const em::DeviceHeartbeatSettingsProto& container( | 498 const em::DeviceHeartbeatSettingsProto& container( |
| 507 policy.device_heartbeat_settings()); | 499 policy.device_heartbeat_settings()); |
| 508 if (container.has_heartbeat_enabled()) { | 500 if (container.has_heartbeat_enabled()) { |
| 509 policies->Set(key::kHeartbeatEnabled, POLICY_LEVEL_MANDATORY, | 501 policies->Set( |
| 510 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 502 key::kHeartbeatEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 511 base::MakeUnique<base::FundamentalValue>( | 503 POLICY_SOURCE_CLOUD, |
| 512 container.heartbeat_enabled()), | 504 base::MakeUnique<base::Value>(container.heartbeat_enabled()), |
| 513 nullptr); | 505 nullptr); |
| 514 } | 506 } |
| 515 if (container.has_heartbeat_frequency()) { | 507 if (container.has_heartbeat_frequency()) { |
| 516 policies->Set(key::kHeartbeatFrequency, POLICY_LEVEL_MANDATORY, | 508 policies->Set(key::kHeartbeatFrequency, POLICY_LEVEL_MANDATORY, |
| 517 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 509 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 518 DecodeIntegerValue(container.heartbeat_frequency()), | 510 DecodeIntegerValue(container.heartbeat_frequency()), |
| 519 nullptr); | 511 nullptr); |
| 520 } | 512 } |
| 521 } | 513 } |
| 522 | 514 |
| 523 if (policy.has_device_log_upload_settings()) { | 515 if (policy.has_device_log_upload_settings()) { |
| 524 const em::DeviceLogUploadSettingsProto& container( | 516 const em::DeviceLogUploadSettingsProto& container( |
| 525 policy.device_log_upload_settings()); | 517 policy.device_log_upload_settings()); |
| 526 if (container.has_system_log_upload_enabled()) { | 518 if (container.has_system_log_upload_enabled()) { |
| 527 policies->Set(key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, | 519 policies->Set( |
| 528 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 520 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 529 base::MakeUnique<base::FundamentalValue>( | 521 POLICY_SOURCE_CLOUD, |
| 530 container.system_log_upload_enabled()), | 522 base::MakeUnique<base::Value>(container.system_log_upload_enabled()), |
| 531 nullptr); | 523 nullptr); |
| 532 } | 524 } |
| 533 } | 525 } |
| 534 } | 526 } |
| 535 | 527 |
| 536 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, | 528 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, |
| 537 PolicyMap* policies) { | 529 PolicyMap* policies) { |
| 538 if (policy.has_release_channel()) { | 530 if (policy.has_release_channel()) { |
| 539 const em::ReleaseChannelProto& container(policy.release_channel()); | 531 const em::ReleaseChannelProto& container(policy.release_channel()); |
| 540 if (container.has_release_channel()) { | 532 if (container.has_release_channel()) { |
| 541 std::string channel(container.release_channel()); | 533 std::string channel(container.release_channel()); |
| 542 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY, | 534 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY, |
| 543 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 535 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 544 base::MakeUnique<base::StringValue>(channel), nullptr); | 536 base::MakeUnique<base::StringValue>(channel), nullptr); |
| 545 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't | 537 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't |
| 546 // have to pass the channel in here, only ping the update engine to tell | 538 // have to pass the channel in here, only ping the update engine to tell |
| 547 // it to fetch the channel from the policy. | 539 // it to fetch the channel from the policy. |
| 548 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> | 540 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> |
| 549 SetChannel(channel, false); | 541 SetChannel(channel, false); |
| 550 } | 542 } |
| 551 if (container.has_release_channel_delegated()) { | 543 if (container.has_release_channel_delegated()) { |
| 552 policies->Set(key::kChromeOsReleaseChannelDelegated, | 544 policies->Set( |
| 553 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 545 key::kChromeOsReleaseChannelDelegated, POLICY_LEVEL_MANDATORY, |
| 554 POLICY_SOURCE_CLOUD, | 546 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 555 base::MakeUnique<base::FundamentalValue>( | 547 base::MakeUnique<base::Value>(container.release_channel_delegated()), |
| 556 container.release_channel_delegated()), | 548 nullptr); |
| 557 nullptr); | |
| 558 } | 549 } |
| 559 } | 550 } |
| 560 | 551 |
| 561 if (policy.has_auto_update_settings()) { | 552 if (policy.has_auto_update_settings()) { |
| 562 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); | 553 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); |
| 563 if (container.has_update_disabled()) { | 554 if (container.has_update_disabled()) { |
| 564 policies->Set( | 555 policies->Set(key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY, |
| 565 key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY, | 556 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 566 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 557 base::MakeUnique<base::Value>(container.update_disabled()), |
| 567 base::MakeUnique<base::FundamentalValue>(container.update_disabled()), | 558 nullptr); |
| 568 nullptr); | |
| 569 } | 559 } |
| 570 | 560 |
| 571 if (container.has_target_version_prefix()) { | 561 if (container.has_target_version_prefix()) { |
| 572 policies->Set(key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY, | 562 policies->Set(key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY, |
| 573 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 563 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 574 base::MakeUnique<base::StringValue>( | 564 base::MakeUnique<base::StringValue>( |
| 575 container.target_version_prefix()), | 565 container.target_version_prefix()), |
| 576 nullptr); | 566 nullptr); |
| 577 } | 567 } |
| 578 | 568 |
| 579 // target_version_display_name is not actually a policy, but a display | 569 // target_version_display_name is not actually a policy, but a display |
| 580 // string for target_version_prefix, so we ignore it. | 570 // string for target_version_prefix, so we ignore it. |
| 581 | 571 |
| 582 if (container.has_scatter_factor_in_seconds()) { | 572 if (container.has_scatter_factor_in_seconds()) { |
| 583 // TODO(dcheng): Shouldn't this use DecodeIntegerValue? | 573 // TODO(dcheng): Shouldn't this use DecodeIntegerValue? |
| 584 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY, | 574 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY, |
| 585 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 575 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 586 base::MakeUnique<base::FundamentalValue>(static_cast<int>( | 576 base::MakeUnique<base::Value>(static_cast<int>( |
| 587 container.scatter_factor_in_seconds())), | 577 container.scatter_factor_in_seconds())), |
| 588 nullptr); | 578 nullptr); |
| 589 } | 579 } |
| 590 | 580 |
| 591 if (container.allowed_connection_types_size()) { | 581 if (container.allowed_connection_types_size()) { |
| 592 std::unique_ptr<base::ListValue> allowed_connection_types( | 582 std::unique_ptr<base::ListValue> allowed_connection_types( |
| 593 new base::ListValue); | 583 new base::ListValue); |
| 594 for (const auto& entry : container.allowed_connection_types()) { | 584 for (const auto& entry : container.allowed_connection_types()) { |
| 595 std::unique_ptr<base::Value> value = DecodeConnectionType(entry); | 585 std::unique_ptr<base::Value> value = DecodeConnectionType(entry); |
| 596 if (value) | 586 if (value) |
| 597 allowed_connection_types->Append(std::move(value)); | 587 allowed_connection_types->Append(std::move(value)); |
| 598 } | 588 } |
| 599 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, | 589 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, |
| 600 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 590 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 601 POLICY_SOURCE_CLOUD, std::move(allowed_connection_types), | 591 POLICY_SOURCE_CLOUD, std::move(allowed_connection_types), |
| 602 nullptr); | 592 nullptr); |
| 603 } | 593 } |
| 604 | 594 |
| 605 if (container.has_http_downloads_enabled()) { | 595 if (container.has_http_downloads_enabled()) { |
| 606 policies->Set(key::kDeviceUpdateHttpDownloadsEnabled, | 596 policies->Set( |
| 607 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 597 key::kDeviceUpdateHttpDownloadsEnabled, POLICY_LEVEL_MANDATORY, |
| 608 POLICY_SOURCE_CLOUD, | 598 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 609 base::MakeUnique<base::FundamentalValue>( | 599 base::MakeUnique<base::Value>(container.http_downloads_enabled()), |
| 610 container.http_downloads_enabled()), | 600 nullptr); |
| 611 nullptr); | |
| 612 } | 601 } |
| 613 | 602 |
| 614 if (container.has_reboot_after_update()) { | 603 if (container.has_reboot_after_update()) { |
| 615 policies->Set(key::kRebootAfterUpdate, POLICY_LEVEL_MANDATORY, | 604 policies->Set( |
| 616 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 605 key::kRebootAfterUpdate, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 617 base::MakeUnique<base::FundamentalValue>( | 606 POLICY_SOURCE_CLOUD, |
| 618 container.reboot_after_update()), | 607 base::MakeUnique<base::Value>(container.reboot_after_update()), |
| 619 nullptr); | 608 nullptr); |
| 620 } | 609 } |
| 621 | 610 |
| 622 if (container.has_p2p_enabled()) { | 611 if (container.has_p2p_enabled()) { |
| 623 policies->Set( | 612 policies->Set(key::kDeviceAutoUpdateP2PEnabled, POLICY_LEVEL_MANDATORY, |
| 624 key::kDeviceAutoUpdateP2PEnabled, POLICY_LEVEL_MANDATORY, | 613 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 625 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 614 base::MakeUnique<base::Value>(container.p2p_enabled()), |
| 626 base::MakeUnique<base::FundamentalValue>(container.p2p_enabled()), | 615 nullptr); |
| 627 nullptr); | |
| 628 } | 616 } |
| 629 } | 617 } |
| 630 | 618 |
| 631 if (policy.has_allow_kiosk_app_control_chrome_version()) { | 619 if (policy.has_allow_kiosk_app_control_chrome_version()) { |
| 632 const em::AllowKioskAppControlChromeVersionProto& container( | 620 const em::AllowKioskAppControlChromeVersionProto& container( |
| 633 policy.allow_kiosk_app_control_chrome_version()); | 621 policy.allow_kiosk_app_control_chrome_version()); |
| 634 if (container.has_allow_kiosk_app_control_chrome_version()) { | 622 if (container.has_allow_kiosk_app_control_chrome_version()) { |
| 635 policies->Set(key::kAllowKioskAppControlChromeVersion, | 623 policies->Set(key::kAllowKioskAppControlChromeVersion, |
| 636 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 624 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 637 POLICY_SOURCE_CLOUD, | 625 POLICY_SOURCE_CLOUD, |
| 638 base::MakeUnique<base::FundamentalValue>( | 626 base::MakeUnique<base::Value>( |
| 639 container.allow_kiosk_app_control_chrome_version()), | 627 container.allow_kiosk_app_control_chrome_version()), |
| 640 nullptr); | 628 nullptr); |
| 641 } | 629 } |
| 642 } | 630 } |
| 643 } | 631 } |
| 644 | 632 |
| 645 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, | 633 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 646 PolicyMap* policies) { | 634 PolicyMap* policies) { |
| 647 if (policy.has_accessibility_settings()) { | 635 if (policy.has_accessibility_settings()) { |
| 648 const em::AccessibilitySettingsProto& | 636 const em::AccessibilitySettingsProto& |
| 649 container(policy.accessibility_settings()); | 637 container(policy.accessibility_settings()); |
| 650 | 638 |
| 651 if (container.has_login_screen_default_large_cursor_enabled()) { | 639 if (container.has_login_screen_default_large_cursor_enabled()) { |
| 652 policies->Set(key::kDeviceLoginScreenDefaultLargeCursorEnabled, | 640 policies->Set(key::kDeviceLoginScreenDefaultLargeCursorEnabled, |
| 653 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 641 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 654 POLICY_SOURCE_CLOUD, | 642 POLICY_SOURCE_CLOUD, |
| 655 base::MakeUnique<base::FundamentalValue>( | 643 base::MakeUnique<base::Value>( |
| 656 container.login_screen_default_large_cursor_enabled()), | 644 container.login_screen_default_large_cursor_enabled()), |
| 657 nullptr); | 645 nullptr); |
| 658 } | 646 } |
| 659 | 647 |
| 660 if (container.has_login_screen_default_spoken_feedback_enabled()) { | 648 if (container.has_login_screen_default_spoken_feedback_enabled()) { |
| 661 policies->Set( | 649 policies->Set( |
| 662 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, | 650 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, |
| 663 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 651 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 664 base::MakeUnique<base::FundamentalValue>( | 652 base::MakeUnique<base::Value>( |
| 665 container.login_screen_default_spoken_feedback_enabled()), | 653 container.login_screen_default_spoken_feedback_enabled()), |
| 666 nullptr); | 654 nullptr); |
| 667 } | 655 } |
| 668 | 656 |
| 669 if (container.has_login_screen_default_high_contrast_enabled()) { | 657 if (container.has_login_screen_default_high_contrast_enabled()) { |
| 670 policies->Set(key::kDeviceLoginScreenDefaultHighContrastEnabled, | 658 policies->Set(key::kDeviceLoginScreenDefaultHighContrastEnabled, |
| 671 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 659 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 672 POLICY_SOURCE_CLOUD, | 660 POLICY_SOURCE_CLOUD, |
| 673 base::MakeUnique<base::FundamentalValue>( | 661 base::MakeUnique<base::Value>( |
| 674 container.login_screen_default_high_contrast_enabled()), | 662 container.login_screen_default_high_contrast_enabled()), |
| 675 nullptr); | 663 nullptr); |
| 676 } | 664 } |
| 677 | 665 |
| 678 if (container.has_login_screen_default_screen_magnifier_type()) { | 666 if (container.has_login_screen_default_screen_magnifier_type()) { |
| 679 policies->Set(key::kDeviceLoginScreenDefaultScreenMagnifierType, | 667 policies->Set(key::kDeviceLoginScreenDefaultScreenMagnifierType, |
| 680 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 668 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 681 POLICY_SOURCE_CLOUD, | 669 POLICY_SOURCE_CLOUD, |
| 682 DecodeIntegerValue( | 670 DecodeIntegerValue( |
| 683 container.login_screen_default_screen_magnifier_type()), | 671 container.login_screen_default_screen_magnifier_type()), |
| 684 nullptr); | 672 nullptr); |
| 685 } | 673 } |
| 686 | 674 |
| 687 if (container.has_login_screen_default_virtual_keyboard_enabled()) { | 675 if (container.has_login_screen_default_virtual_keyboard_enabled()) { |
| 688 policies->Set( | 676 policies->Set( |
| 689 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, | 677 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, |
| 690 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 678 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 691 base::MakeUnique<base::FundamentalValue>( | 679 base::MakeUnique<base::Value>( |
| 692 container.login_screen_default_virtual_keyboard_enabled()), | 680 container.login_screen_default_virtual_keyboard_enabled()), |
| 693 nullptr); | 681 nullptr); |
| 694 } | 682 } |
| 695 } | 683 } |
| 696 } | 684 } |
| 697 | 685 |
| 698 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, | 686 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 699 PolicyMap* policies) { | 687 PolicyMap* policies) { |
| 700 if (policy.has_device_policy_refresh_rate()) { | 688 if (policy.has_device_policy_refresh_rate()) { |
| 701 const em::DevicePolicyRefreshRateProto& container( | 689 const em::DevicePolicyRefreshRateProto& container( |
| 702 policy.device_policy_refresh_rate()); | 690 policy.device_policy_refresh_rate()); |
| 703 if (container.has_device_policy_refresh_rate()) { | 691 if (container.has_device_policy_refresh_rate()) { |
| 704 policies->Set(key::kDevicePolicyRefreshRate, POLICY_LEVEL_MANDATORY, | 692 policies->Set(key::kDevicePolicyRefreshRate, POLICY_LEVEL_MANDATORY, |
| 705 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 693 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 706 DecodeIntegerValue(container.device_policy_refresh_rate()), | 694 DecodeIntegerValue(container.device_policy_refresh_rate()), |
| 707 nullptr); | 695 nullptr); |
| 708 } | 696 } |
| 709 } | 697 } |
| 710 | 698 |
| 711 if (policy.has_metrics_enabled()) { | 699 if (policy.has_metrics_enabled()) { |
| 712 const em::MetricsEnabledProto& container(policy.metrics_enabled()); | 700 const em::MetricsEnabledProto& container(policy.metrics_enabled()); |
| 713 if (container.has_metrics_enabled()) { | 701 if (container.has_metrics_enabled()) { |
| 714 policies->Set( | 702 policies->Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, |
| 715 key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, | 703 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 716 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 704 base::MakeUnique<base::Value>(container.metrics_enabled()), |
| 717 base::MakeUnique<base::FundamentalValue>(container.metrics_enabled()), | 705 nullptr); |
| 718 nullptr); | |
| 719 } | 706 } |
| 720 } | 707 } |
| 721 | 708 |
| 722 if (policy.has_system_timezone()) { | 709 if (policy.has_system_timezone()) { |
| 723 if (policy.system_timezone().has_timezone()) { | 710 if (policy.system_timezone().has_timezone()) { |
| 724 policies->Set(key::kSystemTimezone, POLICY_LEVEL_MANDATORY, | 711 policies->Set(key::kSystemTimezone, POLICY_LEVEL_MANDATORY, |
| 725 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 712 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 726 base::MakeUnique<base::StringValue>( | 713 base::MakeUnique<base::StringValue>( |
| 727 policy.system_timezone().timezone()), | 714 policy.system_timezone().timezone()), |
| 728 nullptr); | 715 nullptr); |
| 729 } | 716 } |
| 730 | 717 |
| 731 if (policy.system_timezone().has_timezone_detection_type()) { | 718 if (policy.system_timezone().has_timezone_detection_type()) { |
| 732 std::unique_ptr<base::Value> value(DecodeIntegerValue( | 719 std::unique_ptr<base::Value> value(DecodeIntegerValue( |
| 733 policy.system_timezone().timezone_detection_type())); | 720 policy.system_timezone().timezone_detection_type())); |
| 734 if (value) { | 721 if (value) { |
| 735 policies->Set(key::kSystemTimezoneAutomaticDetection, | 722 policies->Set(key::kSystemTimezoneAutomaticDetection, |
| 736 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 723 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 737 POLICY_SOURCE_CLOUD, std::move(value), nullptr); | 724 POLICY_SOURCE_CLOUD, std::move(value), nullptr); |
| 738 } | 725 } |
| 739 } | 726 } |
| 740 } | 727 } |
| 741 | 728 |
| 742 if (policy.has_use_24hour_clock()) { | 729 if (policy.has_use_24hour_clock()) { |
| 743 if (policy.use_24hour_clock().has_use_24hour_clock()) { | 730 if (policy.use_24hour_clock().has_use_24hour_clock()) { |
| 744 policies->Set(key::kSystemUse24HourClock, POLICY_LEVEL_MANDATORY, | 731 policies->Set(key::kSystemUse24HourClock, POLICY_LEVEL_MANDATORY, |
| 745 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 732 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 746 base::MakeUnique<base::FundamentalValue>( | 733 base::MakeUnique<base::Value>( |
| 747 policy.use_24hour_clock().use_24hour_clock()), | 734 policy.use_24hour_clock().use_24hour_clock()), |
| 748 nullptr); | 735 nullptr); |
| 749 } | 736 } |
| 750 } | 737 } |
| 751 | 738 |
| 752 if (policy.has_allow_redeem_offers()) { | 739 if (policy.has_allow_redeem_offers()) { |
| 753 const em::AllowRedeemChromeOsRegistrationOffersProto& container( | 740 const em::AllowRedeemChromeOsRegistrationOffersProto& container( |
| 754 policy.allow_redeem_offers()); | 741 policy.allow_redeem_offers()); |
| 755 if (container.has_allow_redeem_offers()) { | 742 if (container.has_allow_redeem_offers()) { |
| 756 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, | 743 policies->Set( |
| 757 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 744 key::kDeviceAllowRedeemChromeOsRegistrationOffers, |
| 758 POLICY_SOURCE_CLOUD, | 745 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 759 base::MakeUnique<base::FundamentalValue>( | 746 base::MakeUnique<base::Value>(container.allow_redeem_offers()), |
| 760 container.allow_redeem_offers()), | 747 nullptr); |
| 761 nullptr); | |
| 762 } | 748 } |
| 763 } | 749 } |
| 764 | 750 |
| 765 if (policy.has_uptime_limit()) { | 751 if (policy.has_uptime_limit()) { |
| 766 const em::UptimeLimitProto& container(policy.uptime_limit()); | 752 const em::UptimeLimitProto& container(policy.uptime_limit()); |
| 767 if (container.has_uptime_limit()) { | 753 if (container.has_uptime_limit()) { |
| 768 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY, | 754 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY, |
| 769 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 755 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 770 DecodeIntegerValue(container.uptime_limit()), nullptr); | 756 DecodeIntegerValue(container.uptime_limit()), nullptr); |
| 771 } | 757 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 789 base::MakeUnique<base::StringValue>( | 775 base::MakeUnique<base::StringValue>( |
| 790 policy.variations_parameter().parameter()), | 776 policy.variations_parameter().parameter()), |
| 791 nullptr); | 777 nullptr); |
| 792 } | 778 } |
| 793 } | 779 } |
| 794 | 780 |
| 795 if (policy.has_attestation_settings()) { | 781 if (policy.has_attestation_settings()) { |
| 796 if (policy.attestation_settings().has_attestation_enabled()) { | 782 if (policy.attestation_settings().has_attestation_enabled()) { |
| 797 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY, | 783 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY, |
| 798 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 784 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 799 base::MakeUnique<base::FundamentalValue>( | 785 base::MakeUnique<base::Value>( |
| 800 policy.attestation_settings().attestation_enabled()), | 786 policy.attestation_settings().attestation_enabled()), |
| 801 nullptr); | 787 nullptr); |
| 802 } | 788 } |
| 803 if (policy.attestation_settings().has_content_protection_enabled()) { | 789 if (policy.attestation_settings().has_content_protection_enabled()) { |
| 804 policies->Set( | 790 policies->Set( |
| 805 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY, | 791 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY, |
| 806 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 792 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 807 base::MakeUnique<base::FundamentalValue>( | 793 base::MakeUnique<base::Value>( |
| 808 policy.attestation_settings().content_protection_enabled()), | 794 policy.attestation_settings().content_protection_enabled()), |
| 809 nullptr); | 795 nullptr); |
| 810 } | 796 } |
| 811 } | 797 } |
| 812 | 798 |
| 813 if (policy.has_system_settings()) { | 799 if (policy.has_system_settings()) { |
| 814 const em::SystemSettingsProto& container(policy.system_settings()); | 800 const em::SystemSettingsProto& container(policy.system_settings()); |
| 815 if (container.has_block_devmode()) { | 801 if (container.has_block_devmode()) { |
| 816 policies->Set( | 802 policies->Set(key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY, |
| 817 key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY, | 803 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 818 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 804 base::MakeUnique<base::Value>(container.block_devmode()), |
| 819 base::MakeUnique<base::FundamentalValue>(container.block_devmode()), | 805 nullptr); |
| 820 nullptr); | |
| 821 } | 806 } |
| 822 } | 807 } |
| 823 | 808 |
| 824 if (policy.has_extension_cache_size()) { | 809 if (policy.has_extension_cache_size()) { |
| 825 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); | 810 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); |
| 826 if (container.has_extension_cache_size()) { | 811 if (container.has_extension_cache_size()) { |
| 827 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, | 812 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, |
| 828 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 813 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 829 DecodeIntegerValue(container.extension_cache_size()), | 814 DecodeIntegerValue(container.extension_cache_size()), |
| 830 nullptr); | 815 nullptr); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 856 } | 841 } |
| 857 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY, | 842 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY, |
| 858 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 843 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 859 std::move(whitelist), nullptr); | 844 std::move(whitelist), nullptr); |
| 860 } | 845 } |
| 861 | 846 |
| 862 if (policy.has_quirks_download_enabled()) { | 847 if (policy.has_quirks_download_enabled()) { |
| 863 const em::DeviceQuirksDownloadEnabledProto& container( | 848 const em::DeviceQuirksDownloadEnabledProto& container( |
| 864 policy.quirks_download_enabled()); | 849 policy.quirks_download_enabled()); |
| 865 if (container.has_quirks_download_enabled()) { | 850 if (container.has_quirks_download_enabled()) { |
| 866 policies->Set(key::kDeviceQuirksDownloadEnabled, POLICY_LEVEL_MANDATORY, | 851 policies->Set( |
| 867 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 852 key::kDeviceQuirksDownloadEnabled, POLICY_LEVEL_MANDATORY, |
| 868 base::MakeUnique<base::FundamentalValue>( | 853 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 869 container.quirks_download_enabled()), | 854 base::MakeUnique<base::Value>(container.quirks_download_enabled()), |
| 870 nullptr); | 855 nullptr); |
| 871 } | 856 } |
| 872 } | 857 } |
| 873 | 858 |
| 874 if (policy.has_device_wallpaper_image()) { | 859 if (policy.has_device_wallpaper_image()) { |
| 875 const em::DeviceWallpaperImageProto& container( | 860 const em::DeviceWallpaperImageProto& container( |
| 876 policy.device_wallpaper_image()); | 861 policy.device_wallpaper_image()); |
| 877 if (container.has_device_wallpaper_image()) { | 862 if (container.has_device_wallpaper_image()) { |
| 878 std::unique_ptr<base::DictionaryValue> dict_val = | 863 std::unique_ptr<base::DictionaryValue> dict_val = |
| 879 base::DictionaryValue::From( | 864 base::DictionaryValue::From( |
| 880 base::JSONReader::Read(container.device_wallpaper_image())); | 865 base::JSONReader::Read(container.device_wallpaper_image())); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 892 // Decode the various groups of policies. | 877 // Decode the various groups of policies. |
| 893 DecodeLoginPolicies(policy, policies); | 878 DecodeLoginPolicies(policy, policies); |
| 894 DecodeNetworkPolicies(policy, policies); | 879 DecodeNetworkPolicies(policy, policies); |
| 895 DecodeReportingPolicies(policy, policies); | 880 DecodeReportingPolicies(policy, policies); |
| 896 DecodeAutoUpdatePolicies(policy, policies); | 881 DecodeAutoUpdatePolicies(policy, policies); |
| 897 DecodeAccessibilityPolicies(policy, policies); | 882 DecodeAccessibilityPolicies(policy, policies); |
| 898 DecodeGenericPolicies(policy, policies); | 883 DecodeGenericPolicies(policy, policies); |
| 899 } | 884 } |
| 900 | 885 |
| 901 } // namespace policy | 886 } // namespace policy |
| OLD | NEW |