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/enterprise_install_attributes.h" | 5 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace cryptohome_util = chromeos::cryptohome_util; | 21 namespace cryptohome_util = chromeos::cryptohome_util; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Translates DeviceMode constants to strings used in the lockbox. | 25 // Translates DeviceMode constants to strings used in the lockbox. |
26 std::string GetDeviceModeString(DeviceMode mode) { | 26 std::string GetDeviceModeString(DeviceMode mode) { |
27 switch (mode) { | 27 switch (mode) { |
28 case DEVICE_MODE_CONSUMER: | 28 case DEVICE_MODE_CONSUMER: |
29 return EnterpriseInstallAttributes::kConsumerDeviceMode; | 29 return EnterpriseInstallAttributes::kConsumerDeviceMode; |
30 case DEVICE_MODE_ENTERPRISE: | 30 case DEVICE_MODE_ENTERPRISE: |
31 return EnterpriseInstallAttributes::kEnterpiseDeviceMode; | 31 return EnterpriseInstallAttributes::kEnterpriseDeviceMode; |
32 case DEVICE_MODE_RETAIL_KIOSK: | 32 case DEVICE_MODE_RETAIL_KIOSK: |
33 return EnterpriseInstallAttributes::kRetailKioskDeviceMode; | 33 return EnterpriseInstallAttributes::kRetailKioskDeviceMode; |
34 case DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH: | 34 case DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH: |
35 return EnterpriseInstallAttributes::kConsumerKioskDeviceMode; | 35 return EnterpriseInstallAttributes::kConsumerKioskDeviceMode; |
36 case DEVICE_MODE_PENDING: | 36 case DEVICE_MODE_PENDING: |
37 case DEVICE_MODE_NOT_SET: | 37 case DEVICE_MODE_NOT_SET: |
38 break; | 38 break; |
39 } | 39 } |
40 NOTREACHED() << "Invalid device mode: " << mode; | 40 NOTREACHED() << "Invalid device mode: " << mode; |
41 return EnterpriseInstallAttributes::kUnknownDeviceMode; | 41 return EnterpriseInstallAttributes::kUnknownDeviceMode; |
42 } | 42 } |
43 | 43 |
44 // Translates strings used in the lockbox to DeviceMode values. | 44 // Translates strings used in the lockbox to DeviceMode values. |
45 DeviceMode GetDeviceModeFromString( | 45 DeviceMode GetDeviceModeFromString( |
46 const std::string& mode) { | 46 const std::string& mode) { |
47 if (mode == EnterpriseInstallAttributes::kConsumerDeviceMode) | 47 if (mode == EnterpriseInstallAttributes::kConsumerDeviceMode) |
48 return DEVICE_MODE_CONSUMER; | 48 return DEVICE_MODE_CONSUMER; |
49 else if (mode == EnterpriseInstallAttributes::kEnterpiseDeviceMode) | 49 else if (mode == EnterpriseInstallAttributes::kEnterpriseDeviceMode) |
50 return DEVICE_MODE_ENTERPRISE; | 50 return DEVICE_MODE_ENTERPRISE; |
51 else if (mode == EnterpriseInstallAttributes::kRetailKioskDeviceMode) | 51 else if (mode == EnterpriseInstallAttributes::kRetailKioskDeviceMode) |
52 return DEVICE_MODE_RETAIL_KIOSK; | 52 return DEVICE_MODE_RETAIL_KIOSK; |
53 else if (mode == EnterpriseInstallAttributes::kConsumerKioskDeviceMode) | 53 else if (mode == EnterpriseInstallAttributes::kConsumerKioskDeviceMode) |
54 return DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; | 54 return DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; |
55 NOTREACHED() << "Unknown device mode string: " << mode; | 55 NOTREACHED() << "Unknown device mode string: " << mode; |
56 return DEVICE_MODE_NOT_SET; | 56 return DEVICE_MODE_NOT_SET; |
57 } | 57 } |
58 | 58 |
59 bool ReadMapKey(const std::map<std::string, std::string>& map, | 59 bool ReadMapKey(const std::map<std::string, std::string>& map, |
60 const std::string& key, | 60 const std::string& key, |
61 std::string* value) { | 61 std::string* value) { |
62 std::map<std::string, std::string>::const_iterator entry = map.find(key); | 62 std::map<std::string, std::string>::const_iterator entry = map.find(key); |
63 if (entry == map.end()) | 63 if (entry == map.end()) |
64 return false; | 64 return false; |
65 | 65 |
66 *value = entry->second; | 66 *value = entry->second; |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 const char EnterpriseInstallAttributes::kConsumerDeviceMode[] = "consumer"; | 72 const char EnterpriseInstallAttributes::kConsumerDeviceMode[] = "consumer"; |
73 const char EnterpriseInstallAttributes::kEnterpiseDeviceMode[] = "enterprise"; | 73 const char EnterpriseInstallAttributes::kEnterpriseDeviceMode[] = "enterprise"; |
74 const char EnterpriseInstallAttributes::kRetailKioskDeviceMode[] = "kiosk"; | 74 const char EnterpriseInstallAttributes::kRetailKioskDeviceMode[] = "kiosk"; |
75 const char EnterpriseInstallAttributes::kConsumerKioskDeviceMode[] = | 75 const char EnterpriseInstallAttributes::kConsumerKioskDeviceMode[] = |
76 "consumer_kiosk"; | 76 "consumer_kiosk"; |
77 const char EnterpriseInstallAttributes::kUnknownDeviceMode[] = "unknown"; | 77 const char EnterpriseInstallAttributes::kUnknownDeviceMode[] = "unknown"; |
78 | 78 |
79 const char EnterpriseInstallAttributes::kAttrEnterpriseDeviceId[] = | 79 const char EnterpriseInstallAttributes::kAttrEnterpriseDeviceId[] = |
80 "enterprise.device_id"; | 80 "enterprise.device_id"; |
81 const char EnterpriseInstallAttributes::kAttrEnterpriseDomain[] = | 81 const char EnterpriseInstallAttributes::kAttrEnterpriseDomain[] = |
82 "enterprise.domain"; | 82 "enterprise.domain"; |
83 const char EnterpriseInstallAttributes::kAttrEnterpriseMode[] = | 83 const char EnterpriseInstallAttributes::kAttrEnterpriseMode[] = |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 &consumer_kiosk_enabled) && | 367 &consumer_kiosk_enabled) && |
368 consumer_kiosk_enabled == "true") { | 368 consumer_kiosk_enabled == "true") { |
369 registration_mode_ = DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; | 369 registration_mode_ = DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; |
370 } else if (enterprise_user.empty() && enterprise_owned != "true") { | 370 } else if (enterprise_user.empty() && enterprise_owned != "true") { |
371 // |registration_user_| is empty on consumer devices. | 371 // |registration_user_| is empty on consumer devices. |
372 registration_mode_ = DEVICE_MODE_CONSUMER; | 372 registration_mode_ = DEVICE_MODE_CONSUMER; |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 } // namespace policy | 376 } // namespace policy |
OLD | NEW |