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

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

Issue 1714473002: Add usb_detachable_whitelist to device policy proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update the policy_templates.json file and the policy decoder code Created 4 years, 9 months 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/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
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 uint16_t vid = entry->has_vendor_id() ? entry->vendor_id() : 0x0000;
bartfab (slow) 2016/03/01 14:49:57 Nit: const.
vpalatin 2016/03/01 17:49:01 Done.
835 uint16_t pid = entry->has_product_id() ? entry->product_id() : 0x0000;
bartfab (slow) 2016/03/01 14:49:57 Nit: const.
vpalatin 2016/03/01 17:49:01 Done.
836 whitelist->Append(
837 new base::StringValue(base::StringPrintf("%04x:%04x", vid, pid)));
bartfab (slow) 2016/03/01 14:49:57 Why not use a base::ListValue of two base::Fundame
vpalatin 2016/03/01 17:49:01 That would look nicer but I really want to print t
bartfab (slow) 2016/03/02 10:40:33 I think there is a compromise that can make both o
838 }
839 policies->Set(key::kUsbDetachableWhitelist, POLICY_LEVEL_MANDATORY,
840 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, whitelist, NULL);
bartfab (slow) 2016/03/01 14:49:57 Nit: s/NULL/nullptr/
vpalatin 2016/03/01 17:49:01 Done.
841 }
825 } 842 }
826 843
827 } // namespace 844 } // namespace
828 845
829 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, 846 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
830 PolicyMap* policies) { 847 PolicyMap* policies) {
831 // Decode the various groups of policies. 848 // Decode the various groups of policies.
832 DecodeLoginPolicies(policy, policies); 849 DecodeLoginPolicies(policy, policies);
833 DecodeNetworkPolicies(policy, policies); 850 DecodeNetworkPolicies(policy, policies);
834 DecodeReportingPolicies(policy, policies); 851 DecodeReportingPolicies(policy, policies);
835 DecodeAutoUpdatePolicies(policy, policies); 852 DecodeAutoUpdatePolicies(policy, policies);
836 DecodeAccessibilityPolicies(policy, policies); 853 DecodeAccessibilityPolicies(policy, policies);
837 DecodeGenericPolicies(policy, policies); 854 DecodeGenericPolicies(policy, policies);
838 } 855 }
839 856
840 } // namespace policy 857 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698