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/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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 const em::DisplayRotationDefaultProto& container( | 816 const em::DisplayRotationDefaultProto& container( |
| 816 policy.display_rotation_default()); | 817 policy.display_rotation_default()); |
| 817 policies->Set( | 818 policies->Set( |
| 818 key::kDisplayRotationDefault, | 819 key::kDisplayRotationDefault, |
| 819 POLICY_LEVEL_MANDATORY, | 820 POLICY_LEVEL_MANDATORY, |
| 820 POLICY_SCOPE_MACHINE, | 821 POLICY_SCOPE_MACHINE, |
| 821 POLICY_SOURCE_CLOUD, | 822 POLICY_SOURCE_CLOUD, |
| 822 DecodeIntegerValue(container.display_rotation_default()).release(), | 823 DecodeIntegerValue(container.display_rotation_default()).release(), |
| 823 nullptr); | 824 nullptr); |
| 824 } | 825 } |
| 826 | |
| 827 if (policy.has_usb_detachable_whitelist()) { | |
| 828 const em::UsbDetachableWhitelistProto& container( | |
| 829 policy.usb_detachable_whitelist()); | |
| 830 base::ListValue* whitelist = new base::ListValue(); | |
| 831 RepeatedPtrField<em::UsbDeviceIdProto>::const_iterator entry; | |
| 832 for (entry = container.id().begin(); entry != container.id().end(); | |
| 833 ++entry) { | |
| 834 base::ListValue* ids = new base::ListValue(); | |
| 835 const std::string vid = | |
|
bartfab (slow)
2016/03/07 11:16:47
Sorry for the many nits: Rather than a magic value
vpalatin
2016/03/07 16:38:28
Done.
| |
| 836 entry->has_vendor_id() | |
| 837 ? base::StringPrintf("%04X", entry->vendor_id()) | |
| 838 : "<no VID>"; | |
| 839 const std::string pid = | |
| 840 entry->has_product_id() | |
| 841 ? base::StringPrintf("%04X", entry->product_id()) | |
| 842 : "<no PID>"; | |
| 843 ids->Append(new base::StringValue(vid)); | |
| 844 ids->Append(new base::StringValue(pid)); | |
| 845 whitelist->Append(ids); | |
| 846 } | |
| 847 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY, | |
| 848 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, whitelist, | |
| 849 nullptr); | |
| 850 } | |
| 825 } | 851 } |
| 826 | 852 |
| 827 } // namespace | 853 } // namespace |
| 828 | 854 |
| 829 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 855 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 830 PolicyMap* policies) { | 856 PolicyMap* policies) { |
| 831 // Decode the various groups of policies. | 857 // Decode the various groups of policies. |
| 832 DecodeLoginPolicies(policy, policies); | 858 DecodeLoginPolicies(policy, policies); |
| 833 DecodeNetworkPolicies(policy, policies); | 859 DecodeNetworkPolicies(policy, policies); |
| 834 DecodeReportingPolicies(policy, policies); | 860 DecodeReportingPolicies(policy, policies); |
| 835 DecodeAutoUpdatePolicies(policy, policies); | 861 DecodeAutoUpdatePolicies(policy, policies); |
| 836 DecodeAccessibilityPolicies(policy, policies); | 862 DecodeAccessibilityPolicies(policy, policies); |
| 837 DecodeGenericPolicies(policy, policies); | 863 DecodeGenericPolicies(policy, policies); |
| 838 } | 864 } |
| 839 | 865 |
| 840 } // namespace policy | 866 } // namespace policy |
| OLD | NEW |