| 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" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/policy/device_local_account.h" | 15 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 17 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
| 18 #include "chromeos/dbus/update_engine_client.h" | 18 #include "chromeos/dbus/update_engine_client.h" |
| 19 #include "chromeos/settings/cros_settings_names.h" | 19 #include "chromeos/settings/cros_settings_names.h" |
| 20 #include "components/policy/core/browser/browser_policy_connector.h" | 20 #include "components/policy/core/browser/browser_policy_connector.h" |
| 21 #include "components/policy/core/common/external_data_fetcher.h" | 21 #include "components/policy/core/common/external_data_fetcher.h" |
| 22 #include "components/policy/core/common/policy_map.h" | 22 #include "components/policy/core/common/policy_map.h" |
| 23 #include "components/policy/core/common/policy_types.h" |
| 23 #include "components/policy/core/common/schema.h" | 24 #include "components/policy/core/common/schema.h" |
| 24 #include "policy/policy_constants.h" | 25 #include "policy/policy_constants.h" |
| 25 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 26 | 27 |
| 27 using google::protobuf::RepeatedField; | 28 using google::protobuf::RepeatedField; |
| 28 using google::protobuf::RepeatedPtrField; | 29 using google::protobuf::RepeatedPtrField; |
| 29 | 30 |
| 30 namespace em = enterprise_management; | 31 namespace em = enterprise_management; |
| 31 | 32 |
| 32 namespace policy { | 33 namespace policy { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 109 } |
| 109 | 110 |
| 110 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, | 111 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 111 PolicyMap* policies) { | 112 PolicyMap* policies) { |
| 112 if (policy.has_guest_mode_enabled()) { | 113 if (policy.has_guest_mode_enabled()) { |
| 113 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); | 114 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); |
| 114 if (container.has_guest_mode_enabled()) { | 115 if (container.has_guest_mode_enabled()) { |
| 115 policies->Set(key::kDeviceGuestModeEnabled, | 116 policies->Set(key::kDeviceGuestModeEnabled, |
| 116 POLICY_LEVEL_MANDATORY, | 117 POLICY_LEVEL_MANDATORY, |
| 117 POLICY_SCOPE_MACHINE, | 118 POLICY_SCOPE_MACHINE, |
| 119 POLICY_SOURCE_CLOUD, |
| 118 new base::FundamentalValue( | 120 new base::FundamentalValue( |
| 119 container.guest_mode_enabled()), | 121 container.guest_mode_enabled()), |
| 120 NULL); | 122 NULL); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 if (policy.has_reboot_on_shutdown()) { | 126 if (policy.has_reboot_on_shutdown()) { |
| 125 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown()); | 127 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown()); |
| 126 if (container.has_reboot_on_shutdown()) { | 128 if (container.has_reboot_on_shutdown()) { |
| 127 policies->Set(key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY, | 129 policies->Set(key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY, |
| 128 POLICY_SCOPE_MACHINE, | 130 POLICY_SCOPE_MACHINE, |
| 131 POLICY_SOURCE_CLOUD, |
| 129 new base::FundamentalValue(container.reboot_on_shutdown()), | 132 new base::FundamentalValue(container.reboot_on_shutdown()), |
| 130 NULL); | 133 NULL); |
| 131 } | 134 } |
| 132 } | 135 } |
| 133 | 136 |
| 134 if (policy.has_show_user_names()) { | 137 if (policy.has_show_user_names()) { |
| 135 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names()); | 138 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names()); |
| 136 if (container.has_show_user_names()) { | 139 if (container.has_show_user_names()) { |
| 137 policies->Set(key::kDeviceShowUserNamesOnSignin, | 140 policies->Set(key::kDeviceShowUserNamesOnSignin, |
| 138 POLICY_LEVEL_MANDATORY, | 141 POLICY_LEVEL_MANDATORY, |
| 139 POLICY_SCOPE_MACHINE, | 142 POLICY_SCOPE_MACHINE, |
| 143 POLICY_SOURCE_CLOUD, |
| 140 new base::FundamentalValue( | 144 new base::FundamentalValue( |
| 141 container.show_user_names()), | 145 container.show_user_names()), |
| 142 NULL); | 146 NULL); |
| 143 } | 147 } |
| 144 } | 148 } |
| 145 | 149 |
| 146 if (policy.has_allow_new_users()) { | 150 if (policy.has_allow_new_users()) { |
| 147 const em::AllowNewUsersProto& container(policy.allow_new_users()); | 151 const em::AllowNewUsersProto& container(policy.allow_new_users()); |
| 148 if (container.has_allow_new_users()) { | 152 if (container.has_allow_new_users()) { |
| 149 policies->Set(key::kDeviceAllowNewUsers, | 153 policies->Set(key::kDeviceAllowNewUsers, |
| 150 POLICY_LEVEL_MANDATORY, | 154 POLICY_LEVEL_MANDATORY, |
| 151 POLICY_SCOPE_MACHINE, | 155 POLICY_SCOPE_MACHINE, |
| 156 POLICY_SOURCE_CLOUD, |
| 152 new base::FundamentalValue( | 157 new base::FundamentalValue( |
| 153 container.allow_new_users()), | 158 container.allow_new_users()), |
| 154 NULL); | 159 NULL); |
| 155 } | 160 } |
| 156 } | 161 } |
| 157 | 162 |
| 158 if (policy.has_user_whitelist()) { | 163 if (policy.has_user_whitelist()) { |
| 159 const em::UserWhitelistProto& container(policy.user_whitelist()); | 164 const em::UserWhitelistProto& container(policy.user_whitelist()); |
| 160 base::ListValue* whitelist = new base::ListValue(); | 165 base::ListValue* whitelist = new base::ListValue(); |
| 161 RepeatedPtrField<std::string>::const_iterator entry; | 166 RepeatedPtrField<std::string>::const_iterator entry; |
| 162 for (entry = container.user_whitelist().begin(); | 167 for (entry = container.user_whitelist().begin(); |
| 163 entry != container.user_whitelist().end(); | 168 entry != container.user_whitelist().end(); |
| 164 ++entry) { | 169 ++entry) { |
| 165 whitelist->Append(new base::StringValue(*entry)); | 170 whitelist->Append(new base::StringValue(*entry)); |
| 166 } | 171 } |
| 167 policies->Set(key::kDeviceUserWhitelist, | 172 policies->Set(key::kDeviceUserWhitelist, |
| 168 POLICY_LEVEL_MANDATORY, | 173 POLICY_LEVEL_MANDATORY, |
| 169 POLICY_SCOPE_MACHINE, | 174 POLICY_SCOPE_MACHINE, |
| 175 POLICY_SOURCE_CLOUD, |
| 170 whitelist, | 176 whitelist, |
| 171 NULL); | 177 NULL); |
| 172 } | 178 } |
| 173 | 179 |
| 174 if (policy.has_ephemeral_users_enabled()) { | 180 if (policy.has_ephemeral_users_enabled()) { |
| 175 const em::EphemeralUsersEnabledProto& container( | 181 const em::EphemeralUsersEnabledProto& container( |
| 176 policy.ephemeral_users_enabled()); | 182 policy.ephemeral_users_enabled()); |
| 177 if (container.has_ephemeral_users_enabled()) { | 183 if (container.has_ephemeral_users_enabled()) { |
| 178 policies->Set(key::kDeviceEphemeralUsersEnabled, | 184 policies->Set(key::kDeviceEphemeralUsersEnabled, |
| 179 POLICY_LEVEL_MANDATORY, | 185 POLICY_LEVEL_MANDATORY, |
| 180 POLICY_SCOPE_MACHINE, | 186 POLICY_SCOPE_MACHINE, |
| 187 POLICY_SOURCE_CLOUD, |
| 181 new base::FundamentalValue( | 188 new base::FundamentalValue( |
| 182 container.ephemeral_users_enabled()), | 189 container.ephemeral_users_enabled()), |
| 183 NULL); | 190 NULL); |
| 184 } | 191 } |
| 185 } | 192 } |
| 186 | 193 |
| 187 if (policy.has_device_local_accounts()) { | 194 if (policy.has_device_local_accounts()) { |
| 188 const em::DeviceLocalAccountsProto& container( | 195 const em::DeviceLocalAccountsProto& container( |
| 189 policy.device_local_accounts()); | 196 policy.device_local_accounts()); |
| 190 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 197 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 219 entry->deprecated_public_session_id()); | 226 entry->deprecated_public_session_id()); |
| 220 entry_dict->SetIntegerWithoutPathExpansion( | 227 entry_dict->SetIntegerWithoutPathExpansion( |
| 221 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, | 228 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, |
| 222 DeviceLocalAccount::TYPE_PUBLIC_SESSION); | 229 DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
| 223 } | 230 } |
| 224 account_list->Append(entry_dict.release()); | 231 account_list->Append(entry_dict.release()); |
| 225 } | 232 } |
| 226 policies->Set(key::kDeviceLocalAccounts, | 233 policies->Set(key::kDeviceLocalAccounts, |
| 227 POLICY_LEVEL_MANDATORY, | 234 POLICY_LEVEL_MANDATORY, |
| 228 POLICY_SCOPE_MACHINE, | 235 POLICY_SCOPE_MACHINE, |
| 236 POLICY_SOURCE_CLOUD, |
| 229 account_list.release(), | 237 account_list.release(), |
| 230 NULL); | 238 NULL); |
| 231 if (container.has_auto_login_id()) { | 239 if (container.has_auto_login_id()) { |
| 232 policies->Set(key::kDeviceLocalAccountAutoLoginId, | 240 policies->Set(key::kDeviceLocalAccountAutoLoginId, |
| 233 POLICY_LEVEL_MANDATORY, | 241 POLICY_LEVEL_MANDATORY, |
| 234 POLICY_SCOPE_MACHINE, | 242 POLICY_SCOPE_MACHINE, |
| 243 POLICY_SOURCE_CLOUD, |
| 235 new base::StringValue(container.auto_login_id()), | 244 new base::StringValue(container.auto_login_id()), |
| 236 NULL); | 245 NULL); |
| 237 } | 246 } |
| 238 if (container.has_auto_login_delay()) { | 247 if (container.has_auto_login_delay()) { |
| 239 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, | 248 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, |
| 240 POLICY_LEVEL_MANDATORY, | 249 POLICY_LEVEL_MANDATORY, |
| 241 POLICY_SCOPE_MACHINE, | 250 POLICY_SCOPE_MACHINE, |
| 251 POLICY_SOURCE_CLOUD, |
| 242 DecodeIntegerValue(container.auto_login_delay()).release(), | 252 DecodeIntegerValue(container.auto_login_delay()).release(), |
| 243 NULL); | 253 NULL); |
| 244 } | 254 } |
| 245 if (container.has_enable_auto_login_bailout()) { | 255 if (container.has_enable_auto_login_bailout()) { |
| 246 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, | 256 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, |
| 247 POLICY_LEVEL_MANDATORY, | 257 POLICY_LEVEL_MANDATORY, |
| 248 POLICY_SCOPE_MACHINE, | 258 POLICY_SCOPE_MACHINE, |
| 259 POLICY_SOURCE_CLOUD, |
| 249 new base::FundamentalValue( | 260 new base::FundamentalValue( |
| 250 container.enable_auto_login_bailout()), | 261 container.enable_auto_login_bailout()), |
| 251 NULL); | 262 NULL); |
| 252 } | 263 } |
| 253 if (container.has_prompt_for_network_when_offline()) { | 264 if (container.has_prompt_for_network_when_offline()) { |
| 254 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, | 265 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, |
| 255 POLICY_LEVEL_MANDATORY, | 266 POLICY_LEVEL_MANDATORY, |
| 256 POLICY_SCOPE_MACHINE, | 267 POLICY_SCOPE_MACHINE, |
| 268 POLICY_SOURCE_CLOUD, |
| 257 new base::FundamentalValue( | 269 new base::FundamentalValue( |
| 258 container.prompt_for_network_when_offline()), | 270 container.prompt_for_network_when_offline()), |
| 259 NULL); | 271 NULL); |
| 260 } | 272 } |
| 261 } | 273 } |
| 262 | 274 |
| 263 if (policy.has_supervised_users_settings()) { | 275 if (policy.has_supervised_users_settings()) { |
| 264 const em::SupervisedUsersSettingsProto& container = | 276 const em::SupervisedUsersSettingsProto& container = |
| 265 policy.supervised_users_settings(); | 277 policy.supervised_users_settings(); |
| 266 if (container.has_supervised_users_enabled()) { | 278 if (container.has_supervised_users_enabled()) { |
| 267 base::Value* value = new base::FundamentalValue( | 279 base::Value* value = new base::FundamentalValue( |
| 268 container.supervised_users_enabled()); | 280 container.supervised_users_enabled()); |
| 269 policies->Set(key::kSupervisedUsersEnabled, | 281 policies->Set(key::kSupervisedUsersEnabled, |
| 270 POLICY_LEVEL_MANDATORY, | 282 POLICY_LEVEL_MANDATORY, |
| 271 POLICY_SCOPE_MACHINE, | 283 POLICY_SCOPE_MACHINE, |
| 284 POLICY_SOURCE_CLOUD, |
| 272 value, | 285 value, |
| 273 NULL); | 286 NULL); |
| 274 } | 287 } |
| 275 } | 288 } |
| 276 | 289 |
| 277 if (policy.has_saml_settings()) { | 290 if (policy.has_saml_settings()) { |
| 278 const em::SAMLSettingsProto& container(policy.saml_settings()); | 291 const em::SAMLSettingsProto& container(policy.saml_settings()); |
| 279 if (container.has_transfer_saml_cookies()) { | 292 if (container.has_transfer_saml_cookies()) { |
| 280 policies->Set(key::kDeviceTransferSAMLCookies, | 293 policies->Set(key::kDeviceTransferSAMLCookies, |
| 281 POLICY_LEVEL_MANDATORY, | 294 POLICY_LEVEL_MANDATORY, |
| 282 POLICY_SCOPE_MACHINE, | 295 POLICY_SCOPE_MACHINE, |
| 296 POLICY_SOURCE_CLOUD, |
| 283 new base::FundamentalValue( | 297 new base::FundamentalValue( |
| 284 container.transfer_saml_cookies()), | 298 container.transfer_saml_cookies()), |
| 285 NULL); | 299 NULL); |
| 286 } | 300 } |
| 287 } | 301 } |
| 288 } | 302 } |
| 289 | 303 |
| 290 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, | 304 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 291 PolicyMap* policies) { | 305 PolicyMap* policies) { |
| 292 if (policy.has_data_roaming_enabled()) { | 306 if (policy.has_data_roaming_enabled()) { |
| 293 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); | 307 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); |
| 294 if (container.has_data_roaming_enabled()) { | 308 if (container.has_data_roaming_enabled()) { |
| 295 policies->Set(key::kDeviceDataRoamingEnabled, | 309 policies->Set(key::kDeviceDataRoamingEnabled, |
| 296 POLICY_LEVEL_MANDATORY, | 310 POLICY_LEVEL_MANDATORY, |
| 297 POLICY_SCOPE_MACHINE, | 311 POLICY_SCOPE_MACHINE, |
| 312 POLICY_SOURCE_CLOUD, |
| 298 new base::FundamentalValue( | 313 new base::FundamentalValue( |
| 299 container.data_roaming_enabled()), | 314 container.data_roaming_enabled()), |
| 300 NULL); | 315 NULL); |
| 301 } | 316 } |
| 302 } | 317 } |
| 303 | 318 |
| 304 if (policy.has_open_network_configuration() && | 319 if (policy.has_open_network_configuration() && |
| 305 policy.open_network_configuration().has_open_network_configuration()) { | 320 policy.open_network_configuration().has_open_network_configuration()) { |
| 306 std::string config( | 321 std::string config( |
| 307 policy.open_network_configuration().open_network_configuration()); | 322 policy.open_network_configuration().open_network_configuration()); |
| 308 policies->Set(key::kDeviceOpenNetworkConfiguration, | 323 policies->Set(key::kDeviceOpenNetworkConfiguration, |
| 309 POLICY_LEVEL_MANDATORY, | 324 POLICY_LEVEL_MANDATORY, |
| 310 POLICY_SCOPE_MACHINE, | 325 POLICY_SCOPE_MACHINE, |
| 326 POLICY_SOURCE_CLOUD, |
| 311 new base::StringValue(config), | 327 new base::StringValue(config), |
| 312 NULL); | 328 NULL); |
| 313 } | 329 } |
| 314 } | 330 } |
| 315 | 331 |
| 316 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, | 332 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 317 PolicyMap* policies) { | 333 PolicyMap* policies) { |
| 318 if (policy.has_device_reporting()) { | 334 if (policy.has_device_reporting()) { |
| 319 const em::DeviceReportingProto& container(policy.device_reporting()); | 335 const em::DeviceReportingProto& container(policy.device_reporting()); |
| 320 if (container.has_report_version_info()) { | 336 if (container.has_report_version_info()) { |
| 321 policies->Set(key::kReportDeviceVersionInfo, | 337 policies->Set(key::kReportDeviceVersionInfo, |
| 322 POLICY_LEVEL_MANDATORY, | 338 POLICY_LEVEL_MANDATORY, |
| 323 POLICY_SCOPE_MACHINE, | 339 POLICY_SCOPE_MACHINE, |
| 340 POLICY_SOURCE_CLOUD, |
| 324 new base::FundamentalValue( | 341 new base::FundamentalValue( |
| 325 container.report_version_info()), | 342 container.report_version_info()), |
| 326 NULL); | 343 NULL); |
| 327 } | 344 } |
| 328 if (container.has_report_activity_times()) { | 345 if (container.has_report_activity_times()) { |
| 329 policies->Set(key::kReportDeviceActivityTimes, | 346 policies->Set(key::kReportDeviceActivityTimes, |
| 330 POLICY_LEVEL_MANDATORY, | 347 POLICY_LEVEL_MANDATORY, |
| 331 POLICY_SCOPE_MACHINE, | 348 POLICY_SCOPE_MACHINE, |
| 349 POLICY_SOURCE_CLOUD, |
| 332 new base::FundamentalValue( | 350 new base::FundamentalValue( |
| 333 container.report_activity_times()), | 351 container.report_activity_times()), |
| 334 NULL); | 352 NULL); |
| 335 } | 353 } |
| 336 if (container.has_report_boot_mode()) { | 354 if (container.has_report_boot_mode()) { |
| 337 policies->Set(key::kReportDeviceBootMode, | 355 policies->Set(key::kReportDeviceBootMode, |
| 338 POLICY_LEVEL_MANDATORY, | 356 POLICY_LEVEL_MANDATORY, |
| 339 POLICY_SCOPE_MACHINE, | 357 POLICY_SCOPE_MACHINE, |
| 358 POLICY_SOURCE_CLOUD, |
| 340 new base::FundamentalValue( | 359 new base::FundamentalValue( |
| 341 container.report_boot_mode()), | 360 container.report_boot_mode()), |
| 342 NULL); | 361 NULL); |
| 343 } | 362 } |
| 344 if (container.has_report_location()) { | 363 if (container.has_report_location()) { |
| 345 policies->Set(key::kReportDeviceLocation, | 364 policies->Set(key::kReportDeviceLocation, |
| 346 POLICY_LEVEL_MANDATORY, | 365 POLICY_LEVEL_MANDATORY, |
| 347 POLICY_SCOPE_MACHINE, | 366 POLICY_SCOPE_MACHINE, |
| 367 POLICY_SOURCE_CLOUD, |
| 348 new base::FundamentalValue( | 368 new base::FundamentalValue( |
| 349 container.report_location()), | 369 container.report_location()), |
| 350 NULL); | 370 NULL); |
| 351 } | 371 } |
| 352 if (container.has_report_network_interfaces()) { | 372 if (container.has_report_network_interfaces()) { |
| 353 policies->Set(key::kReportDeviceNetworkInterfaces, | 373 policies->Set(key::kReportDeviceNetworkInterfaces, |
| 354 POLICY_LEVEL_MANDATORY, | 374 POLICY_LEVEL_MANDATORY, |
| 355 POLICY_SCOPE_MACHINE, | 375 POLICY_SCOPE_MACHINE, |
| 376 POLICY_SOURCE_CLOUD, |
| 356 new base::FundamentalValue( | 377 new base::FundamentalValue( |
| 357 container.report_network_interfaces()), | 378 container.report_network_interfaces()), |
| 358 NULL); | 379 NULL); |
| 359 } | 380 } |
| 360 if (container.has_report_users()) { | 381 if (container.has_report_users()) { |
| 361 policies->Set(key::kReportDeviceUsers, | 382 policies->Set(key::kReportDeviceUsers, |
| 362 POLICY_LEVEL_MANDATORY, | 383 POLICY_LEVEL_MANDATORY, |
| 363 POLICY_SCOPE_MACHINE, | 384 POLICY_SCOPE_MACHINE, |
| 385 POLICY_SOURCE_CLOUD, |
| 364 new base::FundamentalValue(container.report_users()), | 386 new base::FundamentalValue(container.report_users()), |
| 365 NULL); | 387 NULL); |
| 366 } | 388 } |
| 367 if (container.has_report_hardware_status()) { | 389 if (container.has_report_hardware_status()) { |
| 368 policies->Set(key::kReportDeviceHardwareStatus, | 390 policies->Set(key::kReportDeviceHardwareStatus, |
| 369 POLICY_LEVEL_MANDATORY, | 391 POLICY_LEVEL_MANDATORY, |
| 370 POLICY_SCOPE_MACHINE, | 392 POLICY_SCOPE_MACHINE, |
| 393 POLICY_SOURCE_CLOUD, |
| 371 new base::FundamentalValue( | 394 new base::FundamentalValue( |
| 372 container.report_hardware_status()), | 395 container.report_hardware_status()), |
| 373 NULL); | 396 NULL); |
| 374 } | 397 } |
| 375 if (container.has_report_session_status()) { | 398 if (container.has_report_session_status()) { |
| 376 policies->Set(key::kReportDeviceSessionStatus, | 399 policies->Set(key::kReportDeviceSessionStatus, |
| 377 POLICY_LEVEL_MANDATORY, | 400 POLICY_LEVEL_MANDATORY, |
| 378 POLICY_SCOPE_MACHINE, | 401 POLICY_SCOPE_MACHINE, |
| 402 POLICY_SOURCE_CLOUD, |
| 379 new base::FundamentalValue( | 403 new base::FundamentalValue( |
| 380 container.report_session_status()), | 404 container.report_session_status()), |
| 381 NULL); | 405 NULL); |
| 382 } | 406 } |
| 383 if (container.has_device_status_frequency()) { | 407 if (container.has_device_status_frequency()) { |
| 384 policies->Set(key::kReportUploadFrequency, | 408 policies->Set(key::kReportUploadFrequency, |
| 385 POLICY_LEVEL_MANDATORY, | 409 POLICY_LEVEL_MANDATORY, |
| 386 POLICY_SCOPE_MACHINE, | 410 POLICY_SCOPE_MACHINE, |
| 411 POLICY_SOURCE_CLOUD, |
| 387 DecodeIntegerValue( | 412 DecodeIntegerValue( |
| 388 container.device_status_frequency()).release(), | 413 container.device_status_frequency()).release(), |
| 389 NULL); | 414 NULL); |
| 390 } | 415 } |
| 391 } | 416 } |
| 392 | 417 |
| 393 if (policy.has_device_heartbeat_settings()) { | 418 if (policy.has_device_heartbeat_settings()) { |
| 394 const em::DeviceHeartbeatSettingsProto& container( | 419 const em::DeviceHeartbeatSettingsProto& container( |
| 395 policy.device_heartbeat_settings()); | 420 policy.device_heartbeat_settings()); |
| 396 if (container.has_heartbeat_enabled()) { | 421 if (container.has_heartbeat_enabled()) { |
| 397 policies->Set(key::kHeartbeatEnabled, | 422 policies->Set(key::kHeartbeatEnabled, |
| 398 POLICY_LEVEL_MANDATORY, | 423 POLICY_LEVEL_MANDATORY, |
| 399 POLICY_SCOPE_MACHINE, | 424 POLICY_SCOPE_MACHINE, |
| 425 POLICY_SOURCE_CLOUD, |
| 400 new base::FundamentalValue( | 426 new base::FundamentalValue( |
| 401 container.heartbeat_enabled()), | 427 container.heartbeat_enabled()), |
| 402 NULL); | 428 NULL); |
| 403 } | 429 } |
| 404 if (container.has_heartbeat_frequency()) { | 430 if (container.has_heartbeat_frequency()) { |
| 405 policies->Set(key::kHeartbeatFrequency, | 431 policies->Set(key::kHeartbeatFrequency, |
| 406 POLICY_LEVEL_MANDATORY, | 432 POLICY_LEVEL_MANDATORY, |
| 407 POLICY_SCOPE_MACHINE, | 433 POLICY_SCOPE_MACHINE, |
| 434 POLICY_SOURCE_CLOUD, |
| 408 DecodeIntegerValue( | 435 DecodeIntegerValue( |
| 409 container.heartbeat_frequency()).release(), | 436 container.heartbeat_frequency()).release(), |
| 410 NULL); | 437 NULL); |
| 411 } | 438 } |
| 412 } | 439 } |
| 413 | 440 |
| 414 if (policy.has_device_log_upload_settings()) { | 441 if (policy.has_device_log_upload_settings()) { |
| 415 const em::DeviceLogUploadSettingsProto& container( | 442 const em::DeviceLogUploadSettingsProto& container( |
| 416 policy.device_log_upload_settings()); | 443 policy.device_log_upload_settings()); |
| 417 if (container.has_system_log_upload_enabled()) { | 444 if (container.has_system_log_upload_enabled()) { |
| 418 policies->Set( | 445 policies->Set( |
| 419 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 446 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 447 POLICY_SOURCE_CLOUD, |
| 420 new base::FundamentalValue(container.system_log_upload_enabled()), | 448 new base::FundamentalValue(container.system_log_upload_enabled()), |
| 421 NULL); | 449 NULL); |
| 422 } | 450 } |
| 423 } | 451 } |
| 424 } | 452 } |
| 425 | 453 |
| 426 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, | 454 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, |
| 427 PolicyMap* policies) { | 455 PolicyMap* policies) { |
| 428 if (policy.has_release_channel()) { | 456 if (policy.has_release_channel()) { |
| 429 const em::ReleaseChannelProto& container(policy.release_channel()); | 457 const em::ReleaseChannelProto& container(policy.release_channel()); |
| 430 if (container.has_release_channel()) { | 458 if (container.has_release_channel()) { |
| 431 std::string channel(container.release_channel()); | 459 std::string channel(container.release_channel()); |
| 432 policies->Set(key::kChromeOsReleaseChannel, | 460 policies->Set(key::kChromeOsReleaseChannel, |
| 433 POLICY_LEVEL_MANDATORY, | 461 POLICY_LEVEL_MANDATORY, |
| 434 POLICY_SCOPE_MACHINE, | 462 POLICY_SCOPE_MACHINE, |
| 463 POLICY_SOURCE_CLOUD, |
| 435 new base::StringValue(channel), | 464 new base::StringValue(channel), |
| 436 NULL); | 465 NULL); |
| 437 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't | 466 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't |
| 438 // have to pass the channel in here, only ping the update engine to tell | 467 // have to pass the channel in here, only ping the update engine to tell |
| 439 // it to fetch the channel from the policy. | 468 // it to fetch the channel from the policy. |
| 440 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> | 469 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> |
| 441 SetChannel(channel, false); | 470 SetChannel(channel, false); |
| 442 } | 471 } |
| 443 if (container.has_release_channel_delegated()) { | 472 if (container.has_release_channel_delegated()) { |
| 444 policies->Set(key::kChromeOsReleaseChannelDelegated, | 473 policies->Set(key::kChromeOsReleaseChannelDelegated, |
| 445 POLICY_LEVEL_MANDATORY, | 474 POLICY_LEVEL_MANDATORY, |
| 446 POLICY_SCOPE_MACHINE, | 475 POLICY_SCOPE_MACHINE, |
| 476 POLICY_SOURCE_CLOUD, |
| 447 new base::FundamentalValue( | 477 new base::FundamentalValue( |
| 448 container.release_channel_delegated()), | 478 container.release_channel_delegated()), |
| 449 NULL); | 479 NULL); |
| 450 } | 480 } |
| 451 } | 481 } |
| 452 | 482 |
| 453 if (policy.has_auto_update_settings()) { | 483 if (policy.has_auto_update_settings()) { |
| 454 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); | 484 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); |
| 455 if (container.has_update_disabled()) { | 485 if (container.has_update_disabled()) { |
| 456 policies->Set(key::kDeviceAutoUpdateDisabled, | 486 policies->Set(key::kDeviceAutoUpdateDisabled, |
| 457 POLICY_LEVEL_MANDATORY, | 487 POLICY_LEVEL_MANDATORY, |
| 458 POLICY_SCOPE_MACHINE, | 488 POLICY_SCOPE_MACHINE, |
| 489 POLICY_SOURCE_CLOUD, |
| 459 new base::FundamentalValue( | 490 new base::FundamentalValue( |
| 460 container.update_disabled()), | 491 container.update_disabled()), |
| 461 NULL); | 492 NULL); |
| 462 } | 493 } |
| 463 | 494 |
| 464 if (container.has_target_version_prefix()) { | 495 if (container.has_target_version_prefix()) { |
| 465 policies->Set(key::kDeviceTargetVersionPrefix, | 496 policies->Set(key::kDeviceTargetVersionPrefix, |
| 466 POLICY_LEVEL_MANDATORY, | 497 POLICY_LEVEL_MANDATORY, |
| 467 POLICY_SCOPE_MACHINE, | 498 POLICY_SCOPE_MACHINE, |
| 499 POLICY_SOURCE_CLOUD, |
| 468 new base::StringValue( | 500 new base::StringValue( |
| 469 container.target_version_prefix()), | 501 container.target_version_prefix()), |
| 470 NULL); | 502 NULL); |
| 471 } | 503 } |
| 472 | 504 |
| 473 // target_version_display_name is not actually a policy, but a display | 505 // target_version_display_name is not actually a policy, but a display |
| 474 // string for target_version_prefix, so we ignore it. | 506 // string for target_version_prefix, so we ignore it. |
| 475 | 507 |
| 476 if (container.has_scatter_factor_in_seconds()) { | 508 if (container.has_scatter_factor_in_seconds()) { |
| 477 policies->Set(key::kDeviceUpdateScatterFactor, | 509 policies->Set(key::kDeviceUpdateScatterFactor, |
| 478 POLICY_LEVEL_MANDATORY, | 510 POLICY_LEVEL_MANDATORY, |
| 479 POLICY_SCOPE_MACHINE, | 511 POLICY_SCOPE_MACHINE, |
| 512 POLICY_SOURCE_CLOUD, |
| 480 new base::FundamentalValue(static_cast<int>( | 513 new base::FundamentalValue(static_cast<int>( |
| 481 container.scatter_factor_in_seconds())), | 514 container.scatter_factor_in_seconds())), |
| 482 NULL); | 515 NULL); |
| 483 } | 516 } |
| 484 | 517 |
| 485 if (container.allowed_connection_types_size()) { | 518 if (container.allowed_connection_types_size()) { |
| 486 base::ListValue* allowed_connection_types = new base::ListValue(); | 519 base::ListValue* allowed_connection_types = new base::ListValue(); |
| 487 RepeatedField<int>::const_iterator entry; | 520 RepeatedField<int>::const_iterator entry; |
| 488 for (entry = container.allowed_connection_types().begin(); | 521 for (entry = container.allowed_connection_types().begin(); |
| 489 entry != container.allowed_connection_types().end(); | 522 entry != container.allowed_connection_types().end(); |
| 490 ++entry) { | 523 ++entry) { |
| 491 base::Value* value = DecodeConnectionType(*entry); | 524 base::Value* value = DecodeConnectionType(*entry); |
| 492 if (value) | 525 if (value) |
| 493 allowed_connection_types->Append(value); | 526 allowed_connection_types->Append(value); |
| 494 } | 527 } |
| 495 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, | 528 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, |
| 496 POLICY_LEVEL_MANDATORY, | 529 POLICY_LEVEL_MANDATORY, |
| 497 POLICY_SCOPE_MACHINE, | 530 POLICY_SCOPE_MACHINE, |
| 531 POLICY_SOURCE_CLOUD, |
| 498 allowed_connection_types, | 532 allowed_connection_types, |
| 499 NULL); | 533 NULL); |
| 500 } | 534 } |
| 501 | 535 |
| 502 if (container.has_http_downloads_enabled()) { | 536 if (container.has_http_downloads_enabled()) { |
| 503 policies->Set( | 537 policies->Set( |
| 504 key::kDeviceUpdateHttpDownloadsEnabled, | 538 key::kDeviceUpdateHttpDownloadsEnabled, |
| 505 POLICY_LEVEL_MANDATORY, | 539 POLICY_LEVEL_MANDATORY, |
| 506 POLICY_SCOPE_MACHINE, | 540 POLICY_SCOPE_MACHINE, |
| 541 POLICY_SOURCE_CLOUD, |
| 507 new base::FundamentalValue(container.http_downloads_enabled()), | 542 new base::FundamentalValue(container.http_downloads_enabled()), |
| 508 NULL); | 543 NULL); |
| 509 } | 544 } |
| 510 | 545 |
| 511 if (container.has_reboot_after_update()) { | 546 if (container.has_reboot_after_update()) { |
| 512 policies->Set(key::kRebootAfterUpdate, | 547 policies->Set(key::kRebootAfterUpdate, |
| 513 POLICY_LEVEL_MANDATORY, | 548 POLICY_LEVEL_MANDATORY, |
| 514 POLICY_SCOPE_MACHINE, | 549 POLICY_SCOPE_MACHINE, |
| 550 POLICY_SOURCE_CLOUD, |
| 515 new base::FundamentalValue( | 551 new base::FundamentalValue( |
| 516 container.reboot_after_update()), | 552 container.reboot_after_update()), |
| 517 NULL); | 553 NULL); |
| 518 } | 554 } |
| 519 | 555 |
| 520 if (container.has_p2p_enabled()) { | 556 if (container.has_p2p_enabled()) { |
| 521 policies->Set(key::kDeviceAutoUpdateP2PEnabled, | 557 policies->Set(key::kDeviceAutoUpdateP2PEnabled, |
| 522 POLICY_LEVEL_MANDATORY, | 558 POLICY_LEVEL_MANDATORY, |
| 523 POLICY_SCOPE_MACHINE, | 559 POLICY_SCOPE_MACHINE, |
| 560 POLICY_SOURCE_CLOUD, |
| 524 new base::FundamentalValue(container.p2p_enabled()), | 561 new base::FundamentalValue(container.p2p_enabled()), |
| 525 NULL); | 562 NULL); |
| 526 } | 563 } |
| 527 } | 564 } |
| 528 } | 565 } |
| 529 | 566 |
| 530 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, | 567 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 531 PolicyMap* policies) { | 568 PolicyMap* policies) { |
| 532 if (policy.has_accessibility_settings()) { | 569 if (policy.has_accessibility_settings()) { |
| 533 const em::AccessibilitySettingsProto& | 570 const em::AccessibilitySettingsProto& |
| 534 container(policy.accessibility_settings()); | 571 container(policy.accessibility_settings()); |
| 535 | 572 |
| 536 if (container.has_login_screen_default_large_cursor_enabled()) { | 573 if (container.has_login_screen_default_large_cursor_enabled()) { |
| 537 policies->Set( | 574 policies->Set( |
| 538 key::kDeviceLoginScreenDefaultLargeCursorEnabled, | 575 key::kDeviceLoginScreenDefaultLargeCursorEnabled, |
| 539 POLICY_LEVEL_MANDATORY, | 576 POLICY_LEVEL_MANDATORY, |
| 540 POLICY_SCOPE_MACHINE, | 577 POLICY_SCOPE_MACHINE, |
| 578 POLICY_SOURCE_CLOUD, |
| 541 new base::FundamentalValue( | 579 new base::FundamentalValue( |
| 542 container.login_screen_default_large_cursor_enabled()), | 580 container.login_screen_default_large_cursor_enabled()), |
| 543 NULL); | 581 NULL); |
| 544 } | 582 } |
| 545 | 583 |
| 546 if (container.has_login_screen_default_spoken_feedback_enabled()) { | 584 if (container.has_login_screen_default_spoken_feedback_enabled()) { |
| 547 policies->Set( | 585 policies->Set( |
| 548 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, | 586 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, |
| 549 POLICY_LEVEL_MANDATORY, | 587 POLICY_LEVEL_MANDATORY, |
| 550 POLICY_SCOPE_MACHINE, | 588 POLICY_SCOPE_MACHINE, |
| 589 POLICY_SOURCE_CLOUD, |
| 551 new base::FundamentalValue( | 590 new base::FundamentalValue( |
| 552 container.login_screen_default_spoken_feedback_enabled()), | 591 container.login_screen_default_spoken_feedback_enabled()), |
| 553 NULL); | 592 NULL); |
| 554 } | 593 } |
| 555 | 594 |
| 556 if (container.has_login_screen_default_high_contrast_enabled()) { | 595 if (container.has_login_screen_default_high_contrast_enabled()) { |
| 557 policies->Set( | 596 policies->Set( |
| 558 key::kDeviceLoginScreenDefaultHighContrastEnabled, | 597 key::kDeviceLoginScreenDefaultHighContrastEnabled, |
| 559 POLICY_LEVEL_MANDATORY, | 598 POLICY_LEVEL_MANDATORY, |
| 560 POLICY_SCOPE_MACHINE, | 599 POLICY_SCOPE_MACHINE, |
| 600 POLICY_SOURCE_CLOUD, |
| 561 new base::FundamentalValue( | 601 new base::FundamentalValue( |
| 562 container.login_screen_default_high_contrast_enabled()), | 602 container.login_screen_default_high_contrast_enabled()), |
| 563 NULL); | 603 NULL); |
| 564 } | 604 } |
| 565 | 605 |
| 566 if (container.has_login_screen_default_screen_magnifier_type()) { | 606 if (container.has_login_screen_default_screen_magnifier_type()) { |
| 567 policies->Set( | 607 policies->Set( |
| 568 key::kDeviceLoginScreenDefaultScreenMagnifierType, | 608 key::kDeviceLoginScreenDefaultScreenMagnifierType, |
| 569 POLICY_LEVEL_MANDATORY, | 609 POLICY_LEVEL_MANDATORY, |
| 570 POLICY_SCOPE_MACHINE, | 610 POLICY_SCOPE_MACHINE, |
| 611 POLICY_SOURCE_CLOUD, |
| 571 DecodeIntegerValue( | 612 DecodeIntegerValue( |
| 572 container.login_screen_default_screen_magnifier_type()).release(), | 613 container.login_screen_default_screen_magnifier_type()).release(), |
| 573 NULL); | 614 NULL); |
| 574 } | 615 } |
| 575 | 616 |
| 576 if (container.has_login_screen_default_virtual_keyboard_enabled()) { | 617 if (container.has_login_screen_default_virtual_keyboard_enabled()) { |
| 577 policies->Set( | 618 policies->Set( |
| 578 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, | 619 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, |
| 579 POLICY_LEVEL_MANDATORY, | 620 POLICY_LEVEL_MANDATORY, |
| 580 POLICY_SCOPE_MACHINE, | 621 POLICY_SCOPE_MACHINE, |
| 622 POLICY_SOURCE_CLOUD, |
| 581 new base::FundamentalValue( | 623 new base::FundamentalValue( |
| 582 container.login_screen_default_virtual_keyboard_enabled()), | 624 container.login_screen_default_virtual_keyboard_enabled()), |
| 583 NULL); | 625 NULL); |
| 584 } | 626 } |
| 585 } | 627 } |
| 586 } | 628 } |
| 587 | 629 |
| 588 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, | 630 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 589 PolicyMap* policies) { | 631 PolicyMap* policies) { |
| 590 if (policy.has_device_policy_refresh_rate()) { | 632 if (policy.has_device_policy_refresh_rate()) { |
| 591 const em::DevicePolicyRefreshRateProto& container( | 633 const em::DevicePolicyRefreshRateProto& container( |
| 592 policy.device_policy_refresh_rate()); | 634 policy.device_policy_refresh_rate()); |
| 593 if (container.has_device_policy_refresh_rate()) { | 635 if (container.has_device_policy_refresh_rate()) { |
| 594 policies->Set( | 636 policies->Set( |
| 595 key::kDevicePolicyRefreshRate, | 637 key::kDevicePolicyRefreshRate, |
| 596 POLICY_LEVEL_MANDATORY, | 638 POLICY_LEVEL_MANDATORY, |
| 597 POLICY_SCOPE_MACHINE, | 639 POLICY_SCOPE_MACHINE, |
| 640 POLICY_SOURCE_CLOUD, |
| 598 DecodeIntegerValue(container.device_policy_refresh_rate()).release(), | 641 DecodeIntegerValue(container.device_policy_refresh_rate()).release(), |
| 599 NULL); | 642 NULL); |
| 600 } | 643 } |
| 601 } | 644 } |
| 602 | 645 |
| 603 if (policy.has_metrics_enabled()) { | 646 if (policy.has_metrics_enabled()) { |
| 604 const em::MetricsEnabledProto& container(policy.metrics_enabled()); | 647 const em::MetricsEnabledProto& container(policy.metrics_enabled()); |
| 605 if (container.has_metrics_enabled()) { | 648 if (container.has_metrics_enabled()) { |
| 606 policies->Set(key::kDeviceMetricsReportingEnabled, | 649 policies->Set(key::kDeviceMetricsReportingEnabled, |
| 607 POLICY_LEVEL_MANDATORY, | 650 POLICY_LEVEL_MANDATORY, |
| 608 POLICY_SCOPE_MACHINE, | 651 POLICY_SCOPE_MACHINE, |
| 652 POLICY_SOURCE_CLOUD, |
| 609 new base::FundamentalValue( | 653 new base::FundamentalValue( |
| 610 container.metrics_enabled()), | 654 container.metrics_enabled()), |
| 611 NULL); | 655 NULL); |
| 612 } | 656 } |
| 613 } | 657 } |
| 614 | 658 |
| 615 if (policy.has_system_timezone()) { | 659 if (policy.has_system_timezone()) { |
| 616 if (policy.system_timezone().has_timezone()) { | 660 if (policy.system_timezone().has_timezone()) { |
| 617 policies->Set(key::kSystemTimezone, | 661 policies->Set(key::kSystemTimezone, |
| 618 POLICY_LEVEL_MANDATORY, | 662 POLICY_LEVEL_MANDATORY, |
| 619 POLICY_SCOPE_MACHINE, | 663 POLICY_SCOPE_MACHINE, |
| 664 POLICY_SOURCE_CLOUD, |
| 620 new base::StringValue( | 665 new base::StringValue( |
| 621 policy.system_timezone().timezone()), | 666 policy.system_timezone().timezone()), |
| 622 NULL); | 667 NULL); |
| 623 } | 668 } |
| 624 } | 669 } |
| 625 | 670 |
| 626 if (policy.has_use_24hour_clock()) { | 671 if (policy.has_use_24hour_clock()) { |
| 627 if (policy.use_24hour_clock().has_use_24hour_clock()) { | 672 if (policy.use_24hour_clock().has_use_24hour_clock()) { |
| 628 policies->Set(key::kSystemUse24HourClock, | 673 policies->Set(key::kSystemUse24HourClock, |
| 629 POLICY_LEVEL_MANDATORY, | 674 POLICY_LEVEL_MANDATORY, |
| 630 POLICY_SCOPE_MACHINE, | 675 POLICY_SCOPE_MACHINE, |
| 676 POLICY_SOURCE_CLOUD, |
| 631 new base::FundamentalValue( | 677 new base::FundamentalValue( |
| 632 policy.use_24hour_clock().use_24hour_clock()), | 678 policy.use_24hour_clock().use_24hour_clock()), |
| 633 NULL); | 679 NULL); |
| 634 } | 680 } |
| 635 } | 681 } |
| 636 | 682 |
| 637 if (policy.has_allow_redeem_offers()) { | 683 if (policy.has_allow_redeem_offers()) { |
| 638 const em::AllowRedeemChromeOsRegistrationOffersProto& container( | 684 const em::AllowRedeemChromeOsRegistrationOffersProto& container( |
| 639 policy.allow_redeem_offers()); | 685 policy.allow_redeem_offers()); |
| 640 if (container.has_allow_redeem_offers()) { | 686 if (container.has_allow_redeem_offers()) { |
| 641 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, | 687 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, |
| 642 POLICY_LEVEL_MANDATORY, | 688 POLICY_LEVEL_MANDATORY, |
| 643 POLICY_SCOPE_MACHINE, | 689 POLICY_SCOPE_MACHINE, |
| 690 POLICY_SOURCE_CLOUD, |
| 644 new base::FundamentalValue( | 691 new base::FundamentalValue( |
| 645 container.allow_redeem_offers()), | 692 container.allow_redeem_offers()), |
| 646 NULL); | 693 NULL); |
| 647 } | 694 } |
| 648 } | 695 } |
| 649 | 696 |
| 650 if (policy.has_uptime_limit()) { | 697 if (policy.has_uptime_limit()) { |
| 651 const em::UptimeLimitProto& container(policy.uptime_limit()); | 698 const em::UptimeLimitProto& container(policy.uptime_limit()); |
| 652 if (container.has_uptime_limit()) { | 699 if (container.has_uptime_limit()) { |
| 653 policies->Set(key::kUptimeLimit, | 700 policies->Set(key::kUptimeLimit, |
| 654 POLICY_LEVEL_MANDATORY, | 701 POLICY_LEVEL_MANDATORY, |
| 655 POLICY_SCOPE_MACHINE, | 702 POLICY_SCOPE_MACHINE, |
| 703 POLICY_SOURCE_CLOUD, |
| 656 DecodeIntegerValue(container.uptime_limit()).release(), | 704 DecodeIntegerValue(container.uptime_limit()).release(), |
| 657 NULL); | 705 NULL); |
| 658 } | 706 } |
| 659 } | 707 } |
| 660 | 708 |
| 661 if (policy.has_start_up_flags()) { | 709 if (policy.has_start_up_flags()) { |
| 662 const em::StartUpFlagsProto& container(policy.start_up_flags()); | 710 const em::StartUpFlagsProto& container(policy.start_up_flags()); |
| 663 base::ListValue* flags = new base::ListValue(); | 711 base::ListValue* flags = new base::ListValue(); |
| 664 RepeatedPtrField<std::string>::const_iterator entry; | 712 RepeatedPtrField<std::string>::const_iterator entry; |
| 665 for (entry = container.flags().begin(); | 713 for (entry = container.flags().begin(); |
| 666 entry != container.flags().end(); | 714 entry != container.flags().end(); |
| 667 ++entry) { | 715 ++entry) { |
| 668 flags->Append(new base::StringValue(*entry)); | 716 flags->Append(new base::StringValue(*entry)); |
| 669 } | 717 } |
| 670 policies->Set(key::kDeviceStartUpFlags, | 718 policies->Set(key::kDeviceStartUpFlags, |
| 671 POLICY_LEVEL_MANDATORY, | 719 POLICY_LEVEL_MANDATORY, |
| 672 POLICY_SCOPE_MACHINE, | 720 POLICY_SCOPE_MACHINE, |
| 721 POLICY_SOURCE_CLOUD, |
| 673 flags, | 722 flags, |
| 674 NULL); | 723 NULL); |
| 675 } | 724 } |
| 676 | 725 |
| 677 if (policy.has_variations_parameter()) { | 726 if (policy.has_variations_parameter()) { |
| 678 if (policy.variations_parameter().has_parameter()) { | 727 if (policy.variations_parameter().has_parameter()) { |
| 679 policies->Set(key::kDeviceVariationsRestrictParameter, | 728 policies->Set(key::kDeviceVariationsRestrictParameter, |
| 680 POLICY_LEVEL_MANDATORY, | 729 POLICY_LEVEL_MANDATORY, |
| 681 POLICY_SCOPE_MACHINE, | 730 POLICY_SCOPE_MACHINE, |
| 731 POLICY_SOURCE_CLOUD, |
| 682 new base::StringValue( | 732 new base::StringValue( |
| 683 policy.variations_parameter().parameter()), | 733 policy.variations_parameter().parameter()), |
| 684 NULL); | 734 NULL); |
| 685 } | 735 } |
| 686 } | 736 } |
| 687 | 737 |
| 688 if (policy.has_attestation_settings()) { | 738 if (policy.has_attestation_settings()) { |
| 689 if (policy.attestation_settings().has_attestation_enabled()) { | 739 if (policy.attestation_settings().has_attestation_enabled()) { |
| 690 policies->Set(key::kAttestationEnabledForDevice, | 740 policies->Set(key::kAttestationEnabledForDevice, |
| 691 POLICY_LEVEL_MANDATORY, | 741 POLICY_LEVEL_MANDATORY, |
| 692 POLICY_SCOPE_MACHINE, | 742 POLICY_SCOPE_MACHINE, |
| 743 POLICY_SOURCE_CLOUD, |
| 693 new base::FundamentalValue( | 744 new base::FundamentalValue( |
| 694 policy.attestation_settings().attestation_enabled()), | 745 policy.attestation_settings().attestation_enabled()), |
| 695 NULL); | 746 NULL); |
| 696 } | 747 } |
| 697 if (policy.attestation_settings().has_content_protection_enabled()) { | 748 if (policy.attestation_settings().has_content_protection_enabled()) { |
| 698 policies->Set( | 749 policies->Set( |
| 699 key::kAttestationForContentProtectionEnabled, | 750 key::kAttestationForContentProtectionEnabled, |
| 700 POLICY_LEVEL_MANDATORY, | 751 POLICY_LEVEL_MANDATORY, |
| 701 POLICY_SCOPE_MACHINE, | 752 POLICY_SCOPE_MACHINE, |
| 753 POLICY_SOURCE_CLOUD, |
| 702 new base::FundamentalValue( | 754 new base::FundamentalValue( |
| 703 policy.attestation_settings().content_protection_enabled()), | 755 policy.attestation_settings().content_protection_enabled()), |
| 704 NULL); | 756 NULL); |
| 705 } | 757 } |
| 706 } | 758 } |
| 707 | 759 |
| 708 if (policy.has_login_screen_power_management()) { | 760 if (policy.has_login_screen_power_management()) { |
| 709 const em::LoginScreenPowerManagementProto& container( | 761 const em::LoginScreenPowerManagementProto& container( |
| 710 policy.login_screen_power_management()); | 762 policy.login_screen_power_management()); |
| 711 if (container.has_login_screen_power_management()) { | 763 if (container.has_login_screen_power_management()) { |
| 712 scoped_ptr<base::Value> decoded_json; | 764 scoped_ptr<base::Value> decoded_json; |
| 713 decoded_json = DecodeJsonStringAndDropUnknownBySchema( | 765 decoded_json = DecodeJsonStringAndDropUnknownBySchema( |
| 714 container.login_screen_power_management(), | 766 container.login_screen_power_management(), |
| 715 key::kDeviceLoginScreenPowerManagement); | 767 key::kDeviceLoginScreenPowerManagement); |
| 716 if (decoded_json) { | 768 if (decoded_json) { |
| 717 policies->Set(key::kDeviceLoginScreenPowerManagement, | 769 policies->Set(key::kDeviceLoginScreenPowerManagement, |
| 718 POLICY_LEVEL_MANDATORY, | 770 POLICY_LEVEL_MANDATORY, |
| 719 POLICY_SCOPE_MACHINE, | 771 POLICY_SCOPE_MACHINE, |
| 772 POLICY_SOURCE_CLOUD, |
| 720 decoded_json.release(), | 773 decoded_json.release(), |
| 721 NULL); | 774 NULL); |
| 722 } | 775 } |
| 723 } | 776 } |
| 724 } | 777 } |
| 725 | 778 |
| 726 if (policy.has_system_settings()) { | 779 if (policy.has_system_settings()) { |
| 727 const em::SystemSettingsProto& container(policy.system_settings()); | 780 const em::SystemSettingsProto& container(policy.system_settings()); |
| 728 if (container.has_block_devmode()) { | 781 if (container.has_block_devmode()) { |
| 729 policies->Set( | 782 policies->Set( |
| 730 key::kDeviceBlockDevmode, | 783 key::kDeviceBlockDevmode, |
| 731 POLICY_LEVEL_MANDATORY, | 784 POLICY_LEVEL_MANDATORY, |
| 732 POLICY_SCOPE_MACHINE, | 785 POLICY_SCOPE_MACHINE, |
| 786 POLICY_SOURCE_CLOUD, |
| 733 new base::FundamentalValue(container.block_devmode()), | 787 new base::FundamentalValue(container.block_devmode()), |
| 734 NULL); | 788 NULL); |
| 735 } | 789 } |
| 736 } | 790 } |
| 737 | 791 |
| 738 if (policy.has_extension_cache_size()) { | 792 if (policy.has_extension_cache_size()) { |
| 739 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); | 793 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); |
| 740 if (container.has_extension_cache_size()) { | 794 if (container.has_extension_cache_size()) { |
| 741 policies->Set( | 795 policies->Set( |
| 742 key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, | 796 key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, |
| 743 POLICY_SCOPE_MACHINE, | 797 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 744 DecodeIntegerValue(container.extension_cache_size()).release(), | 798 DecodeIntegerValue(container.extension_cache_size()).release(), |
| 745 nullptr); | 799 nullptr); |
| 746 } | 800 } |
| 747 } | 801 } |
| 748 | 802 |
| 749 if (policy.has_login_screen_domain_auto_complete()) { | 803 if (policy.has_login_screen_domain_auto_complete()) { |
| 750 const em::LoginScreenDomainAutoCompleteProto& container( | 804 const em::LoginScreenDomainAutoCompleteProto& container( |
| 751 policy.login_screen_domain_auto_complete()); | 805 policy.login_screen_domain_auto_complete()); |
| 752 policies->Set( | 806 policies->Set( |
| 753 key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY, | 807 key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY, |
| 754 POLICY_SCOPE_MACHINE, | 808 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 755 new base::StringValue(container.login_screen_domain_auto_complete()), | 809 new base::StringValue(container.login_screen_domain_auto_complete()), |
| 756 nullptr); | 810 nullptr); |
| 757 } | 811 } |
| 758 } | 812 } |
| 759 | 813 |
| 760 } // namespace | 814 } // namespace |
| 761 | 815 |
| 762 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 816 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 763 PolicyMap* policies) { | 817 PolicyMap* policies) { |
| 764 // Decode the various groups of policies. | 818 // Decode the various groups of policies. |
| 765 DecodeLoginPolicies(policy, policies); | 819 DecodeLoginPolicies(policy, policies); |
| 766 DecodeNetworkPolicies(policy, policies); | 820 DecodeNetworkPolicies(policy, policies); |
| 767 DecodeReportingPolicies(policy, policies); | 821 DecodeReportingPolicies(policy, policies); |
| 768 DecodeAutoUpdatePolicies(policy, policies); | 822 DecodeAutoUpdatePolicies(policy, policies); |
| 769 DecodeAccessibilityPolicies(policy, policies); | 823 DecodeAccessibilityPolicies(policy, policies); |
| 770 DecodeGenericPolicies(policy, policies); | 824 DecodeGenericPolicies(policy, policies); |
| 771 } | 825 } |
| 772 | 826 |
| 773 } // namespace policy | 827 } // namespace policy |
| OLD | NEW |