| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 policies->Set(key::kDeviceTransferSAMLCookies, | 271 policies->Set(key::kDeviceTransferSAMLCookies, |
| 272 POLICY_LEVEL_MANDATORY, | 272 POLICY_LEVEL_MANDATORY, |
| 273 POLICY_SCOPE_MACHINE, | 273 POLICY_SCOPE_MACHINE, |
| 274 new base::FundamentalValue( | 274 new base::FundamentalValue( |
| 275 container.transfer_saml_cookies()), | 275 container.transfer_saml_cookies()), |
| 276 NULL); | 276 NULL); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, | |
| 282 PolicyMap* policies, | |
| 283 EnterpriseInstallAttributes* install_attributes) { | |
| 284 // No policies if this is not KIOSK. | |
| 285 if (install_attributes->GetMode() != DEVICE_MODE_RETAIL_KIOSK) | |
| 286 return; | |
| 287 | |
| 288 if (policy.has_forced_logout_timeouts()) { | |
| 289 const em::ForcedLogoutTimeoutsProto& container( | |
| 290 policy.forced_logout_timeouts()); | |
| 291 if (container.has_idle_logout_timeout()) { | |
| 292 policies->Set( | |
| 293 key::kDeviceIdleLogoutTimeout, | |
| 294 POLICY_LEVEL_MANDATORY, | |
| 295 POLICY_SCOPE_MACHINE, | |
| 296 DecodeIntegerValue(container.idle_logout_timeout()).release(), | |
| 297 NULL); | |
| 298 } | |
| 299 if (container.has_idle_logout_warning_duration()) { | |
| 300 policies->Set(key::kDeviceIdleLogoutWarningDuration, | |
| 301 POLICY_LEVEL_MANDATORY, | |
| 302 POLICY_SCOPE_MACHINE, | |
| 303 DecodeIntegerValue(container.idle_logout_warning_duration()) | |
| 304 .release(), | |
| 305 NULL); | |
| 306 } | |
| 307 } | |
| 308 | |
| 309 if (policy.has_login_screen_saver()) { | |
| 310 const em::ScreenSaverProto& container( | |
| 311 policy.login_screen_saver()); | |
| 312 if (container.has_screen_saver_extension_id()) { | |
| 313 policies->Set(key::kDeviceLoginScreenSaverId, | |
| 314 POLICY_LEVEL_MANDATORY, | |
| 315 POLICY_SCOPE_MACHINE, | |
| 316 new base::StringValue( | |
| 317 container.screen_saver_extension_id()), | |
| 318 NULL); | |
| 319 } | |
| 320 if (container.has_screen_saver_timeout()) { | |
| 321 policies->Set( | |
| 322 key::kDeviceLoginScreenSaverTimeout, | |
| 323 POLICY_LEVEL_MANDATORY, | |
| 324 POLICY_SCOPE_MACHINE, | |
| 325 DecodeIntegerValue(container.screen_saver_timeout()).release(), | |
| 326 NULL); | |
| 327 } | |
| 328 } | |
| 329 | |
| 330 if (policy.has_app_pack()) { | |
| 331 const em::AppPackProto& container(policy.app_pack()); | |
| 332 base::ListValue* app_pack_list = new base::ListValue(); | |
| 333 for (int i = 0; i < container.app_pack_size(); ++i) { | |
| 334 const em::AppPackEntryProto& entry(container.app_pack(i)); | |
| 335 if (entry.has_extension_id() && entry.has_update_url()) { | |
| 336 base::DictionaryValue* dict = new base::DictionaryValue(); | |
| 337 dict->SetString(chromeos::kAppPackKeyExtensionId, entry.extension_id()); | |
| 338 dict->SetString(chromeos::kAppPackKeyUpdateUrl, entry.update_url()); | |
| 339 app_pack_list->Append(dict); | |
| 340 } | |
| 341 } | |
| 342 policies->Set(key::kDeviceAppPack, | |
| 343 POLICY_LEVEL_MANDATORY, | |
| 344 POLICY_SCOPE_MACHINE, | |
| 345 app_pack_list, | |
| 346 NULL); | |
| 347 } | |
| 348 | |
| 349 if (policy.has_pinned_apps()) { | |
| 350 const em::PinnedAppsProto& container(policy.pinned_apps()); | |
| 351 base::ListValue* pinned_apps_list = new base::ListValue(); | |
| 352 for (int i = 0; i < container.app_id_size(); ++i) { | |
| 353 pinned_apps_list->Append( | |
| 354 new base::StringValue(container.app_id(i))); | |
| 355 } | |
| 356 | |
| 357 policies->Set(key::kPinnedLauncherApps, | |
| 358 POLICY_LEVEL_RECOMMENDED, | |
| 359 POLICY_SCOPE_MACHINE, | |
| 360 pinned_apps_list, | |
| 361 NULL); | |
| 362 } | |
| 363 } | |
| 364 | |
| 365 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, | 281 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 366 PolicyMap* policies, | 282 PolicyMap* policies, |
| 367 EnterpriseInstallAttributes* install_attributes) { | 283 EnterpriseInstallAttributes* install_attributes) { |
| 368 if (policy.has_device_proxy_settings()) { | 284 if (policy.has_device_proxy_settings()) { |
| 369 const em::DeviceProxySettingsProto& container( | 285 const em::DeviceProxySettingsProto& container( |
| 370 policy.device_proxy_settings()); | 286 policy.device_proxy_settings()); |
| 371 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); | 287 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); |
| 372 if (container.has_proxy_mode()) | 288 if (container.has_proxy_mode()) |
| 373 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); | 289 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); |
| 374 if (container.has_proxy_server()) | 290 if (container.has_proxy_server()) |
| 375 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); | 291 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); |
| 376 if (container.has_proxy_pac_url()) | 292 if (container.has_proxy_pac_url()) |
| 377 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); | 293 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); |
| 378 if (container.has_proxy_bypass_list()) { | 294 if (container.has_proxy_bypass_list()) { |
| 379 proxy_settings->SetString(key::kProxyBypassList, | 295 proxy_settings->SetString(key::kProxyBypassList, |
| 380 container.proxy_bypass_list()); | 296 container.proxy_bypass_list()); |
| 381 } | 297 } |
| 382 | 298 |
| 383 // Figure out the level. Proxy policy is mandatory in kiosk mode. | 299 // Figure out the level. Proxy policy is mandatory in kiosk mode. |
| 384 PolicyLevel level = POLICY_LEVEL_RECOMMENDED; | 300 PolicyLevel level = POLICY_LEVEL_RECOMMENDED; |
| 385 if (install_attributes->GetMode() == DEVICE_MODE_RETAIL_KIOSK) | 301 if (install_attributes->GetMode() == DEVICE_MODE_LEGACY_RETAIL_MODE) |
| 386 level = POLICY_LEVEL_MANDATORY; | 302 level = POLICY_LEVEL_MANDATORY; |
| 387 | 303 |
| 388 if (!proxy_settings->empty()) { | 304 if (!proxy_settings->empty()) { |
| 389 policies->Set(key::kProxySettings, | 305 policies->Set(key::kProxySettings, |
| 390 level, | 306 level, |
| 391 POLICY_SCOPE_MACHINE, | 307 POLICY_SCOPE_MACHINE, |
| 392 proxy_settings.release(), | 308 proxy_settings.release(), |
| 393 NULL); | 309 NULL); |
| 394 } | 310 } |
| 395 } | 311 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 if (container.has_metrics_enabled()) { | 569 if (container.has_metrics_enabled()) { |
| 654 policies->Set(key::kDeviceMetricsReportingEnabled, | 570 policies->Set(key::kDeviceMetricsReportingEnabled, |
| 655 POLICY_LEVEL_MANDATORY, | 571 POLICY_LEVEL_MANDATORY, |
| 656 POLICY_SCOPE_MACHINE, | 572 POLICY_SCOPE_MACHINE, |
| 657 new base::FundamentalValue( | 573 new base::FundamentalValue( |
| 658 container.metrics_enabled()), | 574 container.metrics_enabled()), |
| 659 NULL); | 575 NULL); |
| 660 } | 576 } |
| 661 } | 577 } |
| 662 | 578 |
| 663 if (policy.has_start_up_urls()) { | |
| 664 const em::StartUpUrlsProto& container(policy.start_up_urls()); | |
| 665 base::ListValue* urls = new base::ListValue(); | |
| 666 RepeatedPtrField<std::string>::const_iterator entry; | |
| 667 for (entry = container.start_up_urls().begin(); | |
| 668 entry != container.start_up_urls().end(); | |
| 669 ++entry) { | |
| 670 urls->Append(new base::StringValue(*entry)); | |
| 671 } | |
| 672 policies->Set(key::kDeviceStartUpUrls, | |
| 673 POLICY_LEVEL_MANDATORY, | |
| 674 POLICY_SCOPE_MACHINE, | |
| 675 urls, | |
| 676 NULL); | |
| 677 } | |
| 678 | |
| 679 if (policy.has_system_timezone()) { | 579 if (policy.has_system_timezone()) { |
| 680 if (policy.system_timezone().has_timezone()) { | 580 if (policy.system_timezone().has_timezone()) { |
| 681 policies->Set(key::kSystemTimezone, | 581 policies->Set(key::kSystemTimezone, |
| 682 POLICY_LEVEL_MANDATORY, | 582 POLICY_LEVEL_MANDATORY, |
| 683 POLICY_SCOPE_MACHINE, | 583 POLICY_SCOPE_MACHINE, |
| 684 new base::StringValue( | 584 new base::StringValue( |
| 685 policy.system_timezone().timezone()), | 585 policy.system_timezone().timezone()), |
| 686 NULL); | 586 NULL); |
| 687 } | 587 } |
| 688 } | 588 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } // namespace | 703 } // namespace |
| 804 | 704 |
| 805 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 705 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 806 PolicyMap* policies, | 706 PolicyMap* policies, |
| 807 EnterpriseInstallAttributes* install_attributes) { | 707 EnterpriseInstallAttributes* install_attributes) { |
| 808 // TODO(achuith): Remove this once crbug.com/263527 is resolved. | 708 // TODO(achuith): Remove this once crbug.com/263527 is resolved. |
| 809 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); | 709 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); |
| 810 | 710 |
| 811 // Decode the various groups of policies. | 711 // Decode the various groups of policies. |
| 812 DecodeLoginPolicies(policy, policies); | 712 DecodeLoginPolicies(policy, policies); |
| 813 DecodeKioskPolicies(policy, policies, install_attributes); | |
| 814 DecodeNetworkPolicies(policy, policies, install_attributes); | 713 DecodeNetworkPolicies(policy, policies, install_attributes); |
| 815 DecodeReportingPolicies(policy, policies); | 714 DecodeReportingPolicies(policy, policies); |
| 816 DecodeAutoUpdatePolicies(policy, policies); | 715 DecodeAutoUpdatePolicies(policy, policies); |
| 817 DecodeAccessibilityPolicies(policy, policies); | 716 DecodeAccessibilityPolicies(policy, policies); |
| 818 DecodeGenericPolicies(policy, policies); | 717 DecodeGenericPolicies(policy, policies); |
| 819 } | 718 } |
| 820 | 719 |
| 821 } // namespace policy | 720 } // namespace policy |
| OLD | NEW |