Chromium Code Reviews| 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/enterprise_install_attributes.h" | |
| 17 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/update_engine_client.h" | 18 #include "chromeos/dbus/update_engine_client.h" |
| 20 #include "chromeos/settings/cros_settings_names.h" | 19 #include "chromeos/settings/cros_settings_names.h" |
| 21 #include "components/policy/core/browser/browser_policy_connector.h" | 20 #include "components/policy/core/browser/browser_policy_connector.h" |
| 22 #include "components/policy/core/common/external_data_fetcher.h" | 21 #include "components/policy/core/common/external_data_fetcher.h" |
| 23 #include "components/policy/core/common/policy_map.h" | 22 #include "components/policy/core/common/policy_map.h" |
| 24 #include "components/policy/core/common/schema.h" | 23 #include "components/policy/core/common/schema.h" |
| 25 #include "policy/policy_constants.h" | 24 #include "policy/policy_constants.h" |
| 26 #include "third_party/cros_system_api/dbus/service_constants.h" | 25 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 policies->Set(key::kDeviceTransferSAMLCookies, | 270 policies->Set(key::kDeviceTransferSAMLCookies, |
| 272 POLICY_LEVEL_MANDATORY, | 271 POLICY_LEVEL_MANDATORY, |
| 273 POLICY_SCOPE_MACHINE, | 272 POLICY_SCOPE_MACHINE, |
| 274 new base::FundamentalValue( | 273 new base::FundamentalValue( |
| 275 container.transfer_saml_cookies()), | 274 container.transfer_saml_cookies()), |
| 276 NULL); | 275 NULL); |
| 277 } | 276 } |
| 278 } | 277 } |
| 279 } | 278 } |
| 280 | 279 |
| 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, | 280 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 366 PolicyMap* policies, | 281 PolicyMap* policies) { |
| 367 EnterpriseInstallAttributes* install_attributes) { | |
| 368 if (policy.has_device_proxy_settings()) { | 282 if (policy.has_device_proxy_settings()) { |
| 369 const em::DeviceProxySettingsProto& container( | 283 const em::DeviceProxySettingsProto& container( |
| 370 policy.device_proxy_settings()); | 284 policy.device_proxy_settings()); |
| 371 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); | 285 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); |
| 372 if (container.has_proxy_mode()) | 286 if (container.has_proxy_mode()) |
| 373 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); | 287 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); |
| 374 if (container.has_proxy_server()) | 288 if (container.has_proxy_server()) |
| 375 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); | 289 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); |
| 376 if (container.has_proxy_pac_url()) | 290 if (container.has_proxy_pac_url()) |
| 377 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); | 291 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); |
| 378 if (container.has_proxy_bypass_list()) { | 292 if (container.has_proxy_bypass_list()) { |
| 379 proxy_settings->SetString(key::kProxyBypassList, | 293 proxy_settings->SetString(key::kProxyBypassList, |
| 380 container.proxy_bypass_list()); | 294 container.proxy_bypass_list()); |
| 381 } | 295 } |
| 382 | 296 |
| 383 // Figure out the level. Proxy policy is mandatory in kiosk mode. | |
| 384 PolicyLevel level = POLICY_LEVEL_RECOMMENDED; | |
| 385 if (install_attributes->GetMode() == DEVICE_MODE_RETAIL_KIOSK) | |
| 386 level = POLICY_LEVEL_MANDATORY; | |
| 387 | |
| 388 if (!proxy_settings->empty()) { | 297 if (!proxy_settings->empty()) { |
| 389 policies->Set(key::kProxySettings, | 298 policies->Set(key::kProxySettings, POLICY_LEVEL_RECOMMENDED, |
| 390 level, | 299 POLICY_SCOPE_MACHINE, proxy_settings.release(), NULL); |
|
bartfab (slow)
2014/12/02 21:25:27
Nit: Now that you are touching this line, s/NULL/n
rkc
2014/12/04 19:50:07
Done.
| |
| 391 POLICY_SCOPE_MACHINE, | |
| 392 proxy_settings.release(), | |
| 393 NULL); | |
| 394 } | 300 } |
| 395 } | 301 } |
| 396 | 302 |
| 397 if (policy.has_data_roaming_enabled()) { | 303 if (policy.has_data_roaming_enabled()) { |
| 398 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); | 304 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); |
| 399 if (container.has_data_roaming_enabled()) { | 305 if (container.has_data_roaming_enabled()) { |
| 400 policies->Set(key::kDeviceDataRoamingEnabled, | 306 policies->Set(key::kDeviceDataRoamingEnabled, |
| 401 POLICY_LEVEL_MANDATORY, | 307 POLICY_LEVEL_MANDATORY, |
| 402 POLICY_SCOPE_MACHINE, | 308 POLICY_SCOPE_MACHINE, |
| 403 new base::FundamentalValue( | 309 new base::FundamentalValue( |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 if (container.has_metrics_enabled()) { | 559 if (container.has_metrics_enabled()) { |
| 654 policies->Set(key::kDeviceMetricsReportingEnabled, | 560 policies->Set(key::kDeviceMetricsReportingEnabled, |
| 655 POLICY_LEVEL_MANDATORY, | 561 POLICY_LEVEL_MANDATORY, |
| 656 POLICY_SCOPE_MACHINE, | 562 POLICY_SCOPE_MACHINE, |
| 657 new base::FundamentalValue( | 563 new base::FundamentalValue( |
| 658 container.metrics_enabled()), | 564 container.metrics_enabled()), |
| 659 NULL); | 565 NULL); |
| 660 } | 566 } |
| 661 } | 567 } |
| 662 | 568 |
| 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()) { | 569 if (policy.has_system_timezone()) { |
| 680 if (policy.system_timezone().has_timezone()) { | 570 if (policy.system_timezone().has_timezone()) { |
| 681 policies->Set(key::kSystemTimezone, | 571 policies->Set(key::kSystemTimezone, |
| 682 POLICY_LEVEL_MANDATORY, | 572 POLICY_LEVEL_MANDATORY, |
| 683 POLICY_SCOPE_MACHINE, | 573 POLICY_SCOPE_MACHINE, |
| 684 new base::StringValue( | 574 new base::StringValue( |
| 685 policy.system_timezone().timezone()), | 575 policy.system_timezone().timezone()), |
| 686 NULL); | 576 NULL); |
| 687 } | 577 } |
| 688 } | 578 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 POLICY_SCOPE_MACHINE, | 686 POLICY_SCOPE_MACHINE, |
| 797 new base::FundamentalValue(container.block_devmode()), | 687 new base::FundamentalValue(container.block_devmode()), |
| 798 NULL); | 688 NULL); |
| 799 } | 689 } |
| 800 } | 690 } |
| 801 } | 691 } |
| 802 | 692 |
| 803 } // namespace | 693 } // namespace |
| 804 | 694 |
| 805 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 695 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 806 PolicyMap* policies, | 696 PolicyMap* policies) { |
| 807 EnterpriseInstallAttributes* install_attributes) { | |
| 808 // TODO(achuith): Remove this once crbug.com/263527 is resolved. | 697 // TODO(achuith): Remove this once crbug.com/263527 is resolved. |
| 809 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); | 698 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); |
| 810 | 699 |
| 811 // Decode the various groups of policies. | 700 // Decode the various groups of policies. |
| 812 DecodeLoginPolicies(policy, policies); | 701 DecodeLoginPolicies(policy, policies); |
| 813 DecodeKioskPolicies(policy, policies, install_attributes); | 702 DecodeNetworkPolicies(policy, policies); |
| 814 DecodeNetworkPolicies(policy, policies, install_attributes); | |
| 815 DecodeReportingPolicies(policy, policies); | 703 DecodeReportingPolicies(policy, policies); |
| 816 DecodeAutoUpdatePolicies(policy, policies); | 704 DecodeAutoUpdatePolicies(policy, policies); |
| 817 DecodeAccessibilityPolicies(policy, policies); | 705 DecodeAccessibilityPolicies(policy, policies); |
| 818 DecodeGenericPolicies(policy, policies); | 706 DecodeGenericPolicies(policy, policies); |
| 819 } | 707 } |
| 820 | 708 |
| 821 } // namespace policy | 709 } // namespace policy |
| OLD | NEW |