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 #ifndef CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ | 5 #ifndef CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ |
6 #define CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ | 6 #define CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ |
7 | 7 |
8 #include <map> | |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | |
12 #include "chrome/browser/policy/cloud_policy_constants.h" | 14 #include "chrome/browser/policy/cloud_policy_constants.h" |
13 | 15 |
16 class FilePath; | |
Joao da Silva
2013/01/17 19:53:25
file_path.h already included
Mattias Nissler (ping if slow)
2013/01/17 20:34:43
Done.
| |
17 | |
14 namespace chromeos { | 18 namespace chromeos { |
15 class CryptohomeLibrary; | 19 class CryptohomeLibrary; |
16 } | 20 } |
17 | 21 |
18 namespace policy { | 22 namespace policy { |
19 | 23 |
20 // Brokers access to the enterprise-related installation-time attributes on | 24 // Brokers access to the enterprise-related installation-time attributes on |
21 // ChromeOS. | 25 // ChromeOS. |
22 class EnterpriseInstallAttributes { | 26 class EnterpriseInstallAttributes { |
23 public: | 27 public: |
24 // Return codes for LockDevice(). | 28 // Return codes for LockDevice(). |
25 enum LockResult { | 29 enum LockResult { |
26 LOCK_SUCCESS, | 30 LOCK_SUCCESS, |
27 LOCK_NOT_READY, | 31 LOCK_NOT_READY, |
28 LOCK_BACKEND_ERROR, | 32 LOCK_BACKEND_ERROR, |
29 LOCK_WRONG_USER, | 33 LOCK_WRONG_USER, |
30 }; | 34 }; |
31 | 35 |
36 // Standard cache file name. | |
37 static const FilePath::CharType kCacheFilePath[]; | |
38 | |
32 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome); | 39 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome); |
33 | 40 |
41 // Reads data from the cache file. The cache file is used to work around slow | |
42 // cryptohome startup, which takes a while to register its DBus interface. | |
43 // See http://crosbug.com/37367 for background on this. | |
44 void ReadCacheFile(const FilePath& cache_file); | |
Joao da Silva
2013/01/17 19:53:25
Why the argument and the static const? Just ReadCa
Mattias Nissler (ping if slow)
2013/01/17 20:34:43
Wrote the test :)
| |
45 | |
34 // Locks the device to be an enterprise device registered by the given user. | 46 // Locks the device to be an enterprise device registered by the given user. |
35 // This can also be called after the lock has already been taken, in which | 47 // This can also be called after the lock has already been taken, in which |
36 // case it checks that the passed user agrees with the locked attribute. | 48 // case it checks that the passed user agrees with the locked attribute. |
37 LockResult LockDevice(const std::string& user, | 49 LockResult LockDevice(const std::string& user, |
38 DeviceMode device_mode, | 50 DeviceMode device_mode, |
39 const std::string& device_id) WARN_UNUSED_RESULT; | 51 const std::string& device_id) WARN_UNUSED_RESULT; |
40 | 52 |
41 // Checks whether this is an enterprise device. | 53 // Checks whether this is an enterprise device. |
42 bool IsEnterpriseDevice(); | 54 bool IsEnterpriseDevice(); |
43 | 55 |
(...skipping 12 matching lines...) Expand all Loading... | |
56 | 68 |
57 // Gets the mode the device was enrolled to. The return value for devices that | 69 // Gets the mode the device was enrolled to. The return value for devices that |
58 // are not locked yet will be DEVICE_MODE_UNKNOWN. | 70 // are not locked yet will be DEVICE_MODE_UNKNOWN. |
59 DeviceMode GetMode(); | 71 DeviceMode GetMode(); |
60 | 72 |
61 private: | 73 private: |
62 // Makes sure the local caches for enterprise-related install attributes are | 74 // Makes sure the local caches for enterprise-related install attributes are |
63 // up-to-date with what cryptohome has. | 75 // up-to-date with what cryptohome has. |
64 void ReadImmutableAttributes(); | 76 void ReadImmutableAttributes(); |
65 | 77 |
78 // Decodes the install attributes provided in |attr_map|. | |
79 void DecodeInstallAttributes( | |
80 const std::map<std::string, std::string>& attr_map); | |
81 | |
66 chromeos::CryptohomeLibrary* cryptohome_; | 82 chromeos::CryptohomeLibrary* cryptohome_; |
67 | 83 |
84 bool attrs_read_; | |
85 | |
68 bool device_locked_; | 86 bool device_locked_; |
69 std::string registration_user_; | 87 std::string registration_user_; |
70 std::string registration_domain_; | 88 std::string registration_domain_; |
71 std::string registration_device_id_; | 89 std::string registration_device_id_; |
72 DeviceMode registration_mode_; | 90 DeviceMode registration_mode_; |
73 | 91 |
74 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); | 92 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); |
75 }; | 93 }; |
76 | 94 |
77 } // namespace policy | 95 } // namespace policy |
78 | 96 |
79 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ | 97 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ |
OLD | NEW |