Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc

Issue 608283003: Remove retail mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 policies->Set(key::kDeviceTransferSAMLCookies, 280 policies->Set(key::kDeviceTransferSAMLCookies,
282 POLICY_LEVEL_MANDATORY, 281 POLICY_LEVEL_MANDATORY,
283 POLICY_SCOPE_MACHINE, 282 POLICY_SCOPE_MACHINE,
284 new base::FundamentalValue( 283 new base::FundamentalValue(
285 container.transfer_saml_cookies()), 284 container.transfer_saml_cookies()),
286 NULL); 285 NULL);
287 } 286 }
288 } 287 }
289 } 288 }
290 289
291 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy,
292 PolicyMap* policies,
293 EnterpriseInstallAttributes* install_attributes) {
294 // No policies if this is not KIOSK.
295 if (install_attributes->GetMode() != DEVICE_MODE_RETAIL_KIOSK)
296 return;
297
298 if (policy.has_forced_logout_timeouts()) {
299 const em::ForcedLogoutTimeoutsProto& container(
300 policy.forced_logout_timeouts());
301 if (container.has_idle_logout_timeout()) {
302 policies->Set(
303 key::kDeviceIdleLogoutTimeout,
304 POLICY_LEVEL_MANDATORY,
305 POLICY_SCOPE_MACHINE,
306 DecodeIntegerValue(container.idle_logout_timeout()).release(),
307 NULL);
308 }
309 if (container.has_idle_logout_warning_duration()) {
310 policies->Set(key::kDeviceIdleLogoutWarningDuration,
311 POLICY_LEVEL_MANDATORY,
312 POLICY_SCOPE_MACHINE,
313 DecodeIntegerValue(container.idle_logout_warning_duration())
314 .release(),
315 NULL);
316 }
317 }
318
319 if (policy.has_login_screen_saver()) {
320 const em::ScreenSaverProto& container(
321 policy.login_screen_saver());
322 if (container.has_screen_saver_extension_id()) {
323 policies->Set(key::kDeviceLoginScreenSaverId,
324 POLICY_LEVEL_MANDATORY,
325 POLICY_SCOPE_MACHINE,
326 new base::StringValue(
327 container.screen_saver_extension_id()),
328 NULL);
329 }
330 if (container.has_screen_saver_timeout()) {
331 policies->Set(
332 key::kDeviceLoginScreenSaverTimeout,
333 POLICY_LEVEL_MANDATORY,
334 POLICY_SCOPE_MACHINE,
335 DecodeIntegerValue(container.screen_saver_timeout()).release(),
336 NULL);
337 }
338 }
339
340 if (policy.has_app_pack()) {
341 const em::AppPackProto& container(policy.app_pack());
342 base::ListValue* app_pack_list = new base::ListValue();
343 for (int i = 0; i < container.app_pack_size(); ++i) {
344 const em::AppPackEntryProto& entry(container.app_pack(i));
345 if (entry.has_extension_id() && entry.has_update_url()) {
346 base::DictionaryValue* dict = new base::DictionaryValue();
347 dict->SetString(chromeos::kAppPackKeyExtensionId, entry.extension_id());
348 dict->SetString(chromeos::kAppPackKeyUpdateUrl, entry.update_url());
349 app_pack_list->Append(dict);
350 }
351 }
352 policies->Set(key::kDeviceAppPack,
353 POLICY_LEVEL_MANDATORY,
354 POLICY_SCOPE_MACHINE,
355 app_pack_list,
356 NULL);
357 }
358
359 if (policy.has_pinned_apps()) {
360 const em::PinnedAppsProto& container(policy.pinned_apps());
361 base::ListValue* pinned_apps_list = new base::ListValue();
362 for (int i = 0; i < container.app_id_size(); ++i) {
363 pinned_apps_list->Append(
364 new base::StringValue(container.app_id(i)));
365 }
366
367 policies->Set(key::kPinnedLauncherApps,
368 POLICY_LEVEL_RECOMMENDED,
369 POLICY_SCOPE_MACHINE,
370 pinned_apps_list,
371 NULL);
372 }
373 }
374
375 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, 290 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy,
376 PolicyMap* policies, 291 PolicyMap* policies) {
377 EnterpriseInstallAttributes* install_attributes) { 292 // TODO(bartfab): Once the retail mode removal CL lands, remove this policy
293 // completely since it was only used from retail mode.
294 // http://crbug.com/442466
378 if (policy.has_device_proxy_settings()) { 295 if (policy.has_device_proxy_settings()) {
379 const em::DeviceProxySettingsProto& container( 296 const em::DeviceProxySettingsProto& container(
380 policy.device_proxy_settings()); 297 policy.device_proxy_settings());
381 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); 298 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue);
382 if (container.has_proxy_mode()) 299 if (container.has_proxy_mode())
383 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); 300 proxy_settings->SetString(key::kProxyMode, container.proxy_mode());
384 if (container.has_proxy_server()) 301 if (container.has_proxy_server())
385 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); 302 proxy_settings->SetString(key::kProxyServer, container.proxy_server());
386 if (container.has_proxy_pac_url()) 303 if (container.has_proxy_pac_url())
387 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); 304 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url());
388 if (container.has_proxy_bypass_list()) { 305 if (container.has_proxy_bypass_list()) {
389 proxy_settings->SetString(key::kProxyBypassList, 306 proxy_settings->SetString(key::kProxyBypassList,
390 container.proxy_bypass_list()); 307 container.proxy_bypass_list());
391 } 308 }
392 309
393 // Figure out the level. Proxy policy is mandatory in kiosk mode.
394 PolicyLevel level = POLICY_LEVEL_RECOMMENDED;
395 if (install_attributes->GetMode() == DEVICE_MODE_RETAIL_KIOSK)
396 level = POLICY_LEVEL_MANDATORY;
397
398 if (!proxy_settings->empty()) { 310 if (!proxy_settings->empty()) {
399 policies->Set(key::kProxySettings, 311 policies->Set(key::kProxySettings, POLICY_LEVEL_RECOMMENDED,
400 level, 312 POLICY_SCOPE_MACHINE, proxy_settings.release(), nullptr);
401 POLICY_SCOPE_MACHINE,
402 proxy_settings.release(),
403 NULL);
404 } 313 }
405 } 314 }
406 315
407 if (policy.has_data_roaming_enabled()) { 316 if (policy.has_data_roaming_enabled()) {
408 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); 317 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled());
409 if (container.has_data_roaming_enabled()) { 318 if (container.has_data_roaming_enabled()) {
410 policies->Set(key::kDeviceDataRoamingEnabled, 319 policies->Set(key::kDeviceDataRoamingEnabled,
411 POLICY_LEVEL_MANDATORY, 320 POLICY_LEVEL_MANDATORY,
412 POLICY_SCOPE_MACHINE, 321 POLICY_SCOPE_MACHINE,
413 new base::FundamentalValue( 322 new base::FundamentalValue(
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 if (container.has_metrics_enabled()) { 572 if (container.has_metrics_enabled()) {
664 policies->Set(key::kDeviceMetricsReportingEnabled, 573 policies->Set(key::kDeviceMetricsReportingEnabled,
665 POLICY_LEVEL_MANDATORY, 574 POLICY_LEVEL_MANDATORY,
666 POLICY_SCOPE_MACHINE, 575 POLICY_SCOPE_MACHINE,
667 new base::FundamentalValue( 576 new base::FundamentalValue(
668 container.metrics_enabled()), 577 container.metrics_enabled()),
669 NULL); 578 NULL);
670 } 579 }
671 } 580 }
672 581
673 if (policy.has_start_up_urls()) {
674 const em::StartUpUrlsProto& container(policy.start_up_urls());
675 base::ListValue* urls = new base::ListValue();
676 RepeatedPtrField<std::string>::const_iterator entry;
677 for (entry = container.start_up_urls().begin();
678 entry != container.start_up_urls().end();
679 ++entry) {
680 urls->Append(new base::StringValue(*entry));
681 }
682 policies->Set(key::kDeviceStartUpUrls,
683 POLICY_LEVEL_MANDATORY,
684 POLICY_SCOPE_MACHINE,
685 urls,
686 NULL);
687 }
688
689 if (policy.has_system_timezone()) { 582 if (policy.has_system_timezone()) {
690 if (policy.system_timezone().has_timezone()) { 583 if (policy.system_timezone().has_timezone()) {
691 policies->Set(key::kSystemTimezone, 584 policies->Set(key::kSystemTimezone,
692 POLICY_LEVEL_MANDATORY, 585 POLICY_LEVEL_MANDATORY,
693 POLICY_SCOPE_MACHINE, 586 POLICY_SCOPE_MACHINE,
694 new base::StringValue( 587 new base::StringValue(
695 policy.system_timezone().timezone()), 588 policy.system_timezone().timezone()),
696 NULL); 589 NULL);
697 } 590 }
698 } 591 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 POLICY_SCOPE_MACHINE, 699 POLICY_SCOPE_MACHINE,
807 new base::FundamentalValue(container.block_devmode()), 700 new base::FundamentalValue(container.block_devmode()),
808 NULL); 701 NULL);
809 } 702 }
810 } 703 }
811 } 704 }
812 705
813 } // namespace 706 } // namespace
814 707
815 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, 708 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
816 PolicyMap* policies, 709 PolicyMap* policies) {
817 EnterpriseInstallAttributes* install_attributes) {
818 // TODO(achuith): Remove this once crbug.com/263527 is resolved. 710 // TODO(achuith): Remove this once crbug.com/263527 is resolved.
819 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString(); 711 VLOG(2) << "DecodeDevicePolicy " << policy.SerializeAsString();
820 712
821 // Decode the various groups of policies. 713 // Decode the various groups of policies.
822 DecodeLoginPolicies(policy, policies); 714 DecodeLoginPolicies(policy, policies);
823 DecodeKioskPolicies(policy, policies, install_attributes); 715 DecodeNetworkPolicies(policy, policies);
824 DecodeNetworkPolicies(policy, policies, install_attributes);
825 DecodeReportingPolicies(policy, policies); 716 DecodeReportingPolicies(policy, policies);
826 DecodeAutoUpdatePolicies(policy, policies); 717 DecodeAutoUpdatePolicies(policy, policies);
827 DecodeAccessibilityPolicies(policy, policies); 718 DecodeAccessibilityPolicies(policy, policies);
828 DecodeGenericPolicies(policy, policies); 719 DecodeGenericPolicies(policy, policies);
829 } 720 }
830 721
831 } // namespace policy 722 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698