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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/stringprintf.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chromeos/policy/device_local_account.h" | 17 #include "chrome/browser/chromeos/policy/device_local_account.h" |
17 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
18 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
19 #include "chromeos/dbus/update_engine_client.h" | 20 #include "chromeos/dbus/update_engine_client.h" |
20 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
21 #include "components/policy/core/browser/browser_policy_connector.h" | 22 #include "components/policy/core/browser/browser_policy_connector.h" |
22 #include "components/policy/core/common/external_data_fetcher.h" | 23 #include "components/policy/core/common/external_data_fetcher.h" |
23 #include "components/policy/core/common/policy_map.h" | 24 #include "components/policy/core/common/policy_map.h" |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 const em::DisplayRotationDefaultProto& container( | 844 const em::DisplayRotationDefaultProto& container( |
844 policy.display_rotation_default()); | 845 policy.display_rotation_default()); |
845 policies->Set( | 846 policies->Set( |
846 key::kDisplayRotationDefault, | 847 key::kDisplayRotationDefault, |
847 POLICY_LEVEL_MANDATORY, | 848 POLICY_LEVEL_MANDATORY, |
848 POLICY_SCOPE_MACHINE, | 849 POLICY_SCOPE_MACHINE, |
849 POLICY_SOURCE_CLOUD, | 850 POLICY_SOURCE_CLOUD, |
850 DecodeIntegerValue(container.display_rotation_default()).release(), | 851 DecodeIntegerValue(container.display_rotation_default()).release(), |
851 nullptr); | 852 nullptr); |
852 } | 853 } |
| 854 |
| 855 if (policy.has_usb_detachable_whitelist()) { |
| 856 const em::UsbDetachableWhitelistProto& container( |
| 857 policy.usb_detachable_whitelist()); |
| 858 base::ListValue* whitelist = new base::ListValue(); |
| 859 RepeatedPtrField<em::UsbDeviceIdProto>::const_iterator entry; |
| 860 for (entry = container.id().begin(); entry != container.id().end(); |
| 861 ++entry) { |
| 862 base::DictionaryValue* ids = new base::DictionaryValue(); |
| 863 if (entry->has_vendor_id()) { |
| 864 ids->SetString("vid", base::StringPrintf("%04X", entry->vendor_id())); |
| 865 } |
| 866 if (entry->has_product_id()) { |
| 867 ids->SetString("pid", base::StringPrintf("%04X", entry->product_id())); |
| 868 } |
| 869 whitelist->Append(ids); |
| 870 } |
| 871 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY, |
| 872 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, whitelist, |
| 873 nullptr); |
| 874 } |
853 } | 875 } |
854 | 876 |
855 } // namespace | 877 } // namespace |
856 | 878 |
857 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 879 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
858 PolicyMap* policies) { | 880 PolicyMap* policies) { |
859 // Decode the various groups of policies. | 881 // Decode the various groups of policies. |
860 DecodeLoginPolicies(policy, policies); | 882 DecodeLoginPolicies(policy, policies); |
861 DecodeNetworkPolicies(policy, policies); | 883 DecodeNetworkPolicies(policy, policies); |
862 DecodeReportingPolicies(policy, policies); | 884 DecodeReportingPolicies(policy, policies); |
863 DecodeAutoUpdatePolicies(policy, policies); | 885 DecodeAutoUpdatePolicies(policy, policies); |
864 DecodeAccessibilityPolicies(policy, policies); | 886 DecodeAccessibilityPolicies(policy, policies); |
865 DecodeGenericPolicies(policy, policies); | 887 DecodeGenericPolicies(policy, policies); |
866 } | 888 } |
867 | 889 |
868 } // namespace policy | 890 } // namespace policy |
OLD | NEW |