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" | 16 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
|
bartfab (slow)
2014/10/15 09:52:20
Nit: No longer needed.
rkc
2014/11/20 21:06:33
Replied below.
| |
| 17 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 17 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/update_engine_client.h" | 19 #include "chromeos/dbus/update_engine_client.h" |
| 20 #include "chromeos/settings/cros_settings_names.h" | 20 #include "chromeos/settings/cros_settings_names.h" |
| 21 #include "components/policy/core/browser/browser_policy_connector.h" | 21 #include "components/policy/core/browser/browser_policy_connector.h" |
| 22 #include "components/policy/core/common/external_data_fetcher.h" | 22 #include "components/policy/core/common/external_data_fetcher.h" |
| 23 #include "components/policy/core/common/policy_map.h" | 23 #include "components/policy/core/common/policy_map.h" |
| 24 #include "components/policy/core/common/schema.h" | 24 #include "components/policy/core/common/schema.h" |
| 25 #include "policy/policy_constants.h" | 25 #include "policy/policy_constants.h" |
| 26 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 policies->Set(key::kDeviceTransferSAMLCookies, | 266 policies->Set(key::kDeviceTransferSAMLCookies, |
| 267 POLICY_LEVEL_MANDATORY, | 267 POLICY_LEVEL_MANDATORY, |
| 268 POLICY_SCOPE_MACHINE, | 268 POLICY_SCOPE_MACHINE, |
| 269 new base::FundamentalValue( | 269 new base::FundamentalValue( |
| 270 container.transfer_saml_cookies()), | 270 container.transfer_saml_cookies()), |
| 271 NULL); | 271 NULL); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, | |
| 277 PolicyMap* policies, | |
| 278 EnterpriseInstallAttributes* install_attributes) { | |
| 279 // No policies if this is not KIOSK. | |
| 280 if (install_attributes->GetMode() != DEVICE_MODE_RETAIL_KIOSK) | |
| 281 return; | |
| 282 | |
| 283 if (policy.has_forced_logout_timeouts()) { | |
| 284 const em::ForcedLogoutTimeoutsProto& container( | |
| 285 policy.forced_logout_timeouts()); | |
| 286 if (container.has_idle_logout_timeout()) { | |
| 287 policies->Set( | |
| 288 key::kDeviceIdleLogoutTimeout, | |
| 289 POLICY_LEVEL_MANDATORY, | |
| 290 POLICY_SCOPE_MACHINE, | |
| 291 DecodeIntegerValue(container.idle_logout_timeout()).release(), | |
| 292 NULL); | |
| 293 } | |
| 294 if (container.has_idle_logout_warning_duration()) { | |
| 295 policies->Set(key::kDeviceIdleLogoutWarningDuration, | |
| 296 POLICY_LEVEL_MANDATORY, | |
| 297 POLICY_SCOPE_MACHINE, | |
| 298 DecodeIntegerValue(container.idle_logout_warning_duration()) | |
| 299 .release(), | |
| 300 NULL); | |
| 301 } | |
| 302 } | |
| 303 | |
| 304 if (policy.has_login_screen_saver()) { | |
| 305 const em::ScreenSaverProto& container( | |
| 306 policy.login_screen_saver()); | |
| 307 if (container.has_screen_saver_extension_id()) { | |
| 308 policies->Set(key::kDeviceLoginScreenSaverId, | |
| 309 POLICY_LEVEL_MANDATORY, | |
| 310 POLICY_SCOPE_MACHINE, | |
| 311 new base::StringValue( | |
| 312 container.screen_saver_extension_id()), | |
| 313 NULL); | |
| 314 } | |
| 315 if (container.has_screen_saver_timeout()) { | |
| 316 policies->Set( | |
| 317 key::kDeviceLoginScreenSaverTimeout, | |
| 318 POLICY_LEVEL_MANDATORY, | |
| 319 POLICY_SCOPE_MACHINE, | |
| 320 DecodeIntegerValue(container.screen_saver_timeout()).release(), | |
| 321 NULL); | |
| 322 } | |
| 323 } | |
| 324 | |
| 325 if (policy.has_app_pack()) { | |
| 326 const em::AppPackProto& container(policy.app_pack()); | |
| 327 base::ListValue* app_pack_list = new base::ListValue(); | |
| 328 for (int i = 0; i < container.app_pack_size(); ++i) { | |
| 329 const em::AppPackEntryProto& entry(container.app_pack(i)); | |
| 330 if (entry.has_extension_id() && entry.has_update_url()) { | |
| 331 base::DictionaryValue* dict = new base::DictionaryValue(); | |
| 332 dict->SetString(chromeos::kAppPackKeyExtensionId, entry.extension_id()); | |
| 333 dict->SetString(chromeos::kAppPackKeyUpdateUrl, entry.update_url()); | |
| 334 app_pack_list->Append(dict); | |
| 335 } | |
| 336 } | |
| 337 policies->Set(key::kDeviceAppPack, | |
| 338 POLICY_LEVEL_MANDATORY, | |
| 339 POLICY_SCOPE_MACHINE, | |
| 340 app_pack_list, | |
| 341 NULL); | |
| 342 } | |
| 343 | |
| 344 if (policy.has_pinned_apps()) { | |
| 345 const em::PinnedAppsProto& container(policy.pinned_apps()); | |
| 346 base::ListValue* pinned_apps_list = new base::ListValue(); | |
| 347 for (int i = 0; i < container.app_id_size(); ++i) { | |
| 348 pinned_apps_list->Append( | |
| 349 new base::StringValue(container.app_id(i))); | |
| 350 } | |
| 351 | |
| 352 policies->Set(key::kPinnedLauncherApps, | |
| 353 POLICY_LEVEL_RECOMMENDED, | |
| 354 POLICY_SCOPE_MACHINE, | |
| 355 pinned_apps_list, | |
| 356 NULL); | |
| 357 } | |
| 358 } | |
| 359 | |
| 360 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, | 276 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 361 PolicyMap* policies, | 277 PolicyMap* policies, |
| 362 EnterpriseInstallAttributes* install_attributes) { | 278 EnterpriseInstallAttributes* install_attributes) { |
|
bartfab (slow)
2014/10/15 09:52:20
Nit: No longer needed.
rkc
2014/11/20 21:06:33
Since DEVICE_MODE_RETAIL_KIOSK will still exist (a
bartfab (slow)
2014/11/27 16:25:47
If I understand "offline demo mode" correctly, it
rkc
2014/12/01 19:15:04
Ah - I honestly don't completely understand this c
bartfab (slow)
2014/12/02 21:25:26
Proxy settings are documented as a mandatory user
rkc
2014/12/04 19:50:06
I'll leave this behavior as is for now? We can alw
bartfab (slow)
2014/12/10 23:24:39
Please add a TODO and file an M41 bug against me t
rkc
2014/12/15 20:45:57
Done.
| |
| 363 if (policy.has_device_proxy_settings()) { | 279 if (policy.has_device_proxy_settings()) { |
| 364 const em::DeviceProxySettingsProto& container( | 280 const em::DeviceProxySettingsProto& container( |
| 365 policy.device_proxy_settings()); | 281 policy.device_proxy_settings()); |
| 366 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); | 282 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); |
| 367 if (container.has_proxy_mode()) | 283 if (container.has_proxy_mode()) |
| 368 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); | 284 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); |
| 369 if (container.has_proxy_server()) | 285 if (container.has_proxy_server()) |
| 370 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); | 286 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); |
| 371 if (container.has_proxy_pac_url()) | 287 if (container.has_proxy_pac_url()) |
| 372 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); | 288 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); |
| 373 if (container.has_proxy_bypass_list()) { | 289 if (container.has_proxy_bypass_list()) { |
| 374 proxy_settings->SetString(key::kProxyBypassList, | 290 proxy_settings->SetString(key::kProxyBypassList, |
| 375 container.proxy_bypass_list()); | 291 container.proxy_bypass_list()); |
| 376 } | 292 } |
| 377 | 293 |
| 378 // Figure out the level. Proxy policy is mandatory in kiosk mode. | |
| 379 PolicyLevel level = POLICY_LEVEL_RECOMMENDED; | |
| 380 if (install_attributes->GetMode() == DEVICE_MODE_RETAIL_KIOSK) | |
| 381 level = POLICY_LEVEL_MANDATORY; | |
| 382 | |
| 383 if (!proxy_settings->empty()) { | 294 if (!proxy_settings->empty()) { |
| 384 policies->Set(key::kProxySettings, | 295 policies->Set(key::kProxySettings, |
| 385 level, | 296 POLICY_LEVEL_RECOMMENDED, |
| 386 POLICY_SCOPE_MACHINE, | 297 POLICY_SCOPE_MACHINE, |
| 387 proxy_settings.release(), | 298 proxy_settings.release(), |
| 388 NULL); | 299 NULL); |
| 389 } | 300 } |
| 390 } | 301 } |
| 391 | 302 |
| 392 if (policy.has_data_roaming_enabled()) { | 303 if (policy.has_data_roaming_enabled()) { |
| 393 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); | 304 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); |
| 394 if (container.has_data_roaming_enabled()) { | 305 if (container.has_data_roaming_enabled()) { |
| 395 policies->Set(key::kDeviceDataRoamingEnabled, | 306 policies->Set(key::kDeviceDataRoamingEnabled, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 if (container.has_metrics_enabled()) { | 559 if (container.has_metrics_enabled()) { |
| 649 policies->Set(key::kDeviceMetricsReportingEnabled, | 560 policies->Set(key::kDeviceMetricsReportingEnabled, |
| 650 POLICY_LEVEL_MANDATORY, | 561 POLICY_LEVEL_MANDATORY, |
| 651 POLICY_SCOPE_MACHINE, | 562 POLICY_SCOPE_MACHINE, |
| 652 new base::FundamentalValue( | 563 new base::FundamentalValue( |
| 653 container.metrics_enabled()), | 564 container.metrics_enabled()), |
| 654 NULL); | 565 NULL); |
| 655 } | 566 } |
| 656 } | 567 } |
| 657 | 568 |
| 658 if (policy.has_start_up_urls()) { | |
| 659 const em::StartUpUrlsProto& container(policy.start_up_urls()); | |
| 660 base::ListValue* urls = new base::ListValue(); | |
| 661 RepeatedPtrField<std::string>::const_iterator entry; | |
| 662 for (entry = container.start_up_urls().begin(); | |
| 663 entry != container.start_up_urls().end(); | |
| 664 ++entry) { | |
| 665 urls->Append(new base::StringValue(*entry)); | |
| 666 } | |
| 667 policies->Set(key::kDeviceStartUpUrls, | |
| 668 POLICY_LEVEL_MANDATORY, | |
| 669 POLICY_SCOPE_MACHINE, | |
| 670 urls, | |
| 671 NULL); | |
| 672 } | |
| 673 | |
| 674 if (policy.has_system_timezone()) { | 569 if (policy.has_system_timezone()) { |
| 675 if (policy.system_timezone().has_timezone()) { | 570 if (policy.system_timezone().has_timezone()) { |
| 676 policies->Set(key::kSystemTimezone, | 571 policies->Set(key::kSystemTimezone, |
| 677 POLICY_LEVEL_MANDATORY, | 572 POLICY_LEVEL_MANDATORY, |
| 678 POLICY_SCOPE_MACHINE, | 573 POLICY_SCOPE_MACHINE, |
| 679 new base::StringValue( | 574 new base::StringValue( |
| 680 policy.system_timezone().timezone()), | 575 policy.system_timezone().timezone()), |
| 681 NULL); | 576 NULL); |
| 682 } | 577 } |
| 683 } | 578 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 new base::FundamentalValue(container.block_devmode()), | 687 new base::FundamentalValue(container.block_devmode()), |
| 793 NULL); | 688 NULL); |
| 794 } | 689 } |
| 795 } | 690 } |
| 796 } | 691 } |
| 797 | 692 |
| 798 } // namespace | 693 } // namespace |
| 799 | 694 |
| 800 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 695 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 801 PolicyMap* policies, | 696 PolicyMap* policies, |
| 802 EnterpriseInstallAttributes* install_attributes) { | 697 EnterpriseInstallAttributes* install_attributes) { |
|
bartfab (slow)
2014/10/15 09:52:20
Nit: No longer needed.
rkc
2014/11/20 21:06:33
As above.
| |
| 803 // TODO(achuith): Remove this once crbug.com/263527 is resolved. | 698 // TODO(achuith): Remove this once crbug.com/263527 is resolved. |
| 804 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); | 699 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); |
| 805 | 700 |
| 806 // Decode the various groups of policies. | 701 // Decode the various groups of policies. |
| 807 DecodeLoginPolicies(policy, policies); | 702 DecodeLoginPolicies(policy, policies); |
| 808 DecodeKioskPolicies(policy, policies, install_attributes); | |
| 809 DecodeNetworkPolicies(policy, policies, install_attributes); | 703 DecodeNetworkPolicies(policy, policies, install_attributes); |
| 810 DecodeReportingPolicies(policy, policies); | 704 DecodeReportingPolicies(policy, policies); |
| 811 DecodeAutoUpdatePolicies(policy, policies); | 705 DecodeAutoUpdatePolicies(policy, policies); |
| 812 DecodeAccessibilityPolicies(policy, policies); | 706 DecodeAccessibilityPolicies(policy, policies); |
| 813 DecodeGenericPolicies(policy, policies); | 707 DecodeGenericPolicies(policy, policies); |
| 814 } | 708 } |
| 815 | 709 |
| 816 } // namespace policy | 710 } // namespace policy |
| OLD | NEW |