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

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. Created 7 years, 10 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/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 // Standard cache file name.
35 static const FilePath::CharType kCacheFilePath[];
36
37 explicit EnterpriseInstallAttributes(chromeos::CryptohomeLibrary* cryptohome);
38
39 // Reads data from the cache file. The cache file is used to work around slow
40 // cryptohome startup, which takes a while to register its DBus interface.
41 // See http://crosbug.com/37367 for background on this.
42 void ReadCacheFile(const FilePath& cache_file);
43
44 // Makes sure the local caches for enterprise-related install attributes are
45 // up-to-date with what cryptohome has.
46 void ReadImmutableAttributes();
47
48 // Locks the device to be an enterprise device registered by the given user.
49 // This can also be called after the lock has already been taken, in which
50 // case it checks that the passed user agrees with the locked attribute.
51 LockResult LockDevice(const std::string& user,
52 DeviceMode device_mode,
53 const std::string& device_id) WARN_UNUSED_RESULT;
54
55 // Checks whether this is an enterprise device.
56 bool IsEnterpriseDevice();
57
58 // Gets the domain this device belongs to or an empty string if the device is
59 // not an enterprise device.
60 std::string GetDomain();
61
62 // Gets the user that registered the device. Returns an empty string if the
63 // device is not an enterprise device.
64 std::string GetRegistrationUser();
65
66 // Gets the device id that was generated when the device was registered.
67 // Returns an empty string if the device is not an enterprise device or the
68 // device id was not stored in the lockbox (prior to R19).
69 std::string GetDeviceId();
70
71 // Gets the mode the device was enrolled to. The return value for devices that
72 // are not locked yet will be DEVICE_MODE_UNKNOWN.
73 DeviceMode GetMode();
74
75 private:
76 // Decodes the install attributes provided in |attr_map|.
77 void DecodeInstallAttributes(
78 const std::map<std::string, std::string>& attr_map);
79
80 chromeos::CryptohomeLibrary* cryptohome_;
81
82 bool device_locked_;
83 std::string registration_user_;
84 std::string registration_domain_;
85 std::string registration_device_id_;
86 DeviceMode registration_mode_;
87
88 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes);
89 };
90
91 } // namespace policy
92
93 #endif // CHROME_BROWSER_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698