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

Side by Side Diff: chrome/browser/policy/enterprise_install_attributes.h

Issue 12189011: Split up chrome/browser/policy subdirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add chrome/browser/chromeos/policy/OWNERS Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
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
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "chrome/browser/policy/cloud_policy_constants.h"
15
16 namespace chromeos {
17 class CryptohomeLibrary;
18 }
19
20 namespace policy {
21
22 // Brokers access to the enterprise-related installation-time attributes on
23 // ChromeOS.
24 class EnterpriseInstallAttributes {
25 public:
26 // Return codes for LockDevice().
27 enum LockResult {
28 LOCK_SUCCESS,
29 LOCK_NOT_READY,
30 LOCK_BACKEND_ERROR,
31 LOCK_WRONG_USER,
32 };
33
34 // Constants for the possible device modes that can be stored in the lockbox.
35 static const char kConsumerDeviceMode[];
36 static const char kEnterpiseDeviceMode[];
37 static const char kKioskDeviceMode[];
38 static const char kUnknownDeviceMode[];
39
40 // Field names in the lockbox.
41 static const char kAttrEnterpriseDeviceId[];
42 static const char kAttrEnterpriseDomain[];
43 static const char kAttrEnterpriseMode[];
44 static const char kAttrEnterpriseOwned[];
45 static const char kAttrEnterpriseUser[];
46
47 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome);
48
49 // Reads data from the cache file. The cache file is used to work around slow
50 // cryptohome startup, which takes a while to register its DBus interface.
51 // See http://crosbug.com/37367 for background on this.
52 void ReadCacheFile(const base::FilePath& cache_file);
53
54 // Makes sure the local caches for enterprise-related install attributes are
55 // up-to-date with what cryptohome has.
56 void ReadImmutableAttributes();
57
58 // Locks the device to be an enterprise device registered by the given user.
59 // This can also be called after the lock has already been taken, in which
60 // case it checks that the passed user agrees with the locked attribute.
61 LockResult LockDevice(const std::string& user,
62 DeviceMode device_mode,
63 const std::string& device_id) WARN_UNUSED_RESULT;
64
65 // Checks whether this is an enterprise device.
66 bool IsEnterpriseDevice();
67
68 // Gets the domain this device belongs to or an empty string if the device is
69 // not an enterprise device.
70 std::string GetDomain();
71
72 // Gets the user that registered the device. Returns an empty string if the
73 // device is not an enterprise device.
74 std::string GetRegistrationUser();
75
76 // Gets the device id that was generated when the device was registered.
77 // Returns an empty string if the device is not an enterprise device or the
78 // device id was not stored in the lockbox (prior to R19).
79 std::string GetDeviceId();
80
81 // Gets the mode the device was enrolled to. The return value for devices that
82 // are not locked yet will be DEVICE_MODE_UNKNOWN.
83 DeviceMode GetMode();
84
85 private:
86 // Decodes the install attributes provided in |attr_map|.
87 void DecodeInstallAttributes(
88 const std::map<std::string, std::string>& attr_map);
89
90 chromeos::CryptohomeLibrary* cryptohome_;
91
92 bool device_locked_;
93 std::string registration_user_;
94 std::string registration_domain_;
95 std::string registration_device_id_;
96 DeviceMode registration_mode_;
97
98 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes);
99 };
100
101 } // namespace policy
102
103 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/enrollment_status_chromeos.cc ('k') | chrome/browser/policy/enterprise_install_attributes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698