Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/policy/cloud_policy_data_store.h" | |
|
Mattias Nissler (ping if slow)
2012/02/20 12:22:54
Let's move the DeviceMode enum to policy constants
pastarmovj
2012/02/20 14:26:30
Done.
| |
| 14 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
|
Mattias Nissler (ping if slow)
2012/02/20 12:22:54
needed? I hope not.
pastarmovj
2012/02/20 14:26:30
Done.
| |
| 13 | 15 |
| 14 namespace chromeos { | 16 namespace chromeos { |
| 15 class CryptohomeLibrary; | 17 class CryptohomeLibrary; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace policy { | 20 namespace policy { |
| 19 | 21 |
| 20 // Brokers access to the enterprise-related installation-time attributes on | 22 // Brokers access to the enterprise-related installation-time attributes on |
| 21 // ChromeOS. | 23 // ChromeOS. |
| 22 class EnterpriseInstallAttributes { | 24 class EnterpriseInstallAttributes { |
| 23 public: | 25 public: |
| 24 // Return codes for LockDevice(). | 26 // Return codes for LockDevice(). |
| 25 enum LockResult { | 27 enum LockResult { |
| 26 LOCK_SUCCESS, | 28 LOCK_SUCCESS, |
| 27 LOCK_NOT_READY, | 29 LOCK_NOT_READY, |
| 28 LOCK_BACKEND_ERROR, | 30 LOCK_BACKEND_ERROR, |
| 29 LOCK_WRONG_USER, | 31 LOCK_WRONG_USER, |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome); | 34 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome); |
| 33 | 35 |
| 34 // Locks the device to be an enterprise device registered by the given user. | 36 // 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 | 37 // 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. | 38 // case it checks that the passed user agrees with the locked attribute. |
| 37 LockResult LockDevice(const std::string& user) WARN_UNUSED_RESULT; | 39 LockResult LockDevice(const std::string& user, |
| 40 CloudPolicyDataStore::DeviceMode device_mode, | |
| 41 const std::string& device_id) WARN_UNUSED_RESULT; | |
| 38 | 42 |
| 39 // Checks whether this is an enterprise device. | 43 // Checks whether this is an enterprise device. |
| 40 bool IsEnterpriseDevice(); | 44 bool IsEnterpriseDevice(); |
| 41 | 45 |
| 42 // Gets the domain this device belongs to or an empty string if the device is | 46 // Gets the domain this device belongs to or an empty string if the device is |
| 43 // not an enterprise device. | 47 // not an enterprise device. |
| 44 std::string GetDomain(); | 48 std::string GetDomain(); |
| 45 | 49 |
| 46 // Gets the user that registered the device. Returns an empty string if the | 50 // Gets the user that registered the device. Returns an empty string if the |
| 47 // device is not an enterprise device. | 51 // device is not an enterprise device. |
| 48 std::string GetRegistrationUser(); | 52 std::string GetRegistrationUser(); |
| 49 | 53 |
| 54 // Gets the device id that was generated when the device was registered. | |
| 55 // Returns an empty string if the device is not an enterprise device or the | |
| 56 // device id was not stored in the lockbox (prior to R19). | |
| 57 std::string GetDeviceId(); | |
| 58 | |
| 59 // Gets the mode the device was enrolled to. The return value for devices that | |
| 60 // are not locked yet will be DEVICE_MODE_UNKNOWN. | |
| 61 CloudPolicyDataStore::DeviceMode GetMode(); | |
| 62 | |
| 50 private: | 63 private: |
| 51 // Makes sure the local caches for enterprise-related install attributes are | 64 // Makes sure the local caches for enterprise-related install attributes are |
| 52 // up-to-date with what cryptohome has. | 65 // up-to-date with what cryptohome has. |
| 53 void ReadImmutableAttributes(); | 66 void ReadImmutableAttributes(); |
| 54 | 67 |
| 55 chromeos::CryptohomeLibrary* cryptohome_; | 68 chromeos::CryptohomeLibrary* cryptohome_; |
| 56 | 69 |
| 57 bool device_locked_; | 70 bool device_locked_; |
| 58 std::string registration_user_; | 71 std::string registration_user_; |
| 72 std::string registration_domain_; | |
| 73 std::string registration_device_id_; | |
| 74 CloudPolicyDataStore::DeviceMode registration_mode_; | |
| 59 | 75 |
| 60 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); | 76 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); |
| 61 }; | 77 }; |
| 62 | 78 |
| 63 } // namespace policy | 79 } // namespace policy |
| 64 | 80 |
| 65 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ | 81 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ |
| OLD | NEW |