• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
6 #define CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 
14 namespace chromeos {
15 class CryptohomeLibrary;
16 }
17 
18 namespace policy {
19 
20 // Brokers access to the enterprise-related installation-time attributes on
21 // ChromeOS.
22 class EnterpriseInstallAttributes {
23  public:
24   // Return codes for LockDevice().
25   enum LockResult {
26     LOCK_SUCCESS,
27     LOCK_NOT_READY,
28     LOCK_BACKEND_ERROR,
29     LOCK_WRONG_USER,
30   };
31 
32   explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome);
33 
34   // 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
36   // case it checks that the passed user agrees with the locked attribute.
37   LockResult LockDevice(const std::string& user) WARN_UNUSED_RESULT;
38 
39   // Checks whether this is an enterprise device.
40   bool IsEnterpriseDevice();
41 
42   // Gets the domain this device belongs to or an empty string if the device is
43   // not an enterprise device.
44   std::string GetDomain();
45 
46   // Gets the user that registered the device. Returns an empty string if the
47   // device is not an enterprise device.
48   std::string GetRegistrationUser();
49 
50  private:
51   // Makes sure the local caches for enterprise-related install attributes are
52   // up-to-date with what cryptohome has.
53   void ReadImmutableAttributes();
54 
55   chromeos::CryptohomeLibrary* cryptohome_;
56 
57   bool device_locked_;
58   std::string registration_user_;
59 
60   DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes);
61 };
62 
63 }  // namespace policy
64 
65 #endif  // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
66