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

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

Issue 1189203003: Add UMA for consistency between TPM and install attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master3
Patch Set: Fix more tests. Created 5 years, 5 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
OLDNEW
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_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 typedef base::Callback<void(LockResult lock_result)> LockResultCallback; 45 typedef base::Callback<void(LockResult lock_result)> LockResultCallback;
46 46
47 // Return serialized InstallAttributes of an enterprise-owned configuration. 47 // Return serialized InstallAttributes of an enterprise-owned configuration.
48 static std::string GetEnterpriseOwnedInstallAttributesBlobForTesting( 48 static std::string GetEnterpriseOwnedInstallAttributesBlobForTesting(
49 const std::string& user_name); 49 const std::string& user_name);
50 50
51 explicit EnterpriseInstallAttributes( 51 explicit EnterpriseInstallAttributes(
52 chromeos::CryptohomeClient* cryptohome_client); 52 chromeos::CryptohomeClient* cryptohome_client);
53 ~EnterpriseInstallAttributes(); 53 ~EnterpriseInstallAttributes();
54 54
55 // Reads data from the cache file which is created early during the boot 55 // Tries to read install attributes from the cache file which is created early
56 // process. The cache file is used to work around slow cryptohome startup, 56 // during the boot process. The cache file is used to work around slow
57 // which takes a while to register its DBus interface. See 57 // cryptohome startup, which takes a while to register its DBus interface.
58 // http://crosbug.com/37367 for background on this. 58 // (See http://crosbug.com/37367 for background on this.)
59 void ReadCacheFile(const base::FilePath& cache_file); 59 void Init(const base::FilePath& cache_file);
60 60
61 // Makes sure the local caches for enterprise-related install attributes are 61 // Makes sure the local caches for enterprise-related install attributes are
62 // up-to-date with what cryptohome has. This method checks the readiness of 62 // up-to-date with what cryptohome has. This method checks the readiness of
63 // attributes and read them if ready. Actual read will be performed in 63 // attributes and read them if ready. Actual read will be performed in
64 // ReadAttributesIfReady(). 64 // ReadAttributesIfReady().
65 void ReadImmutableAttributes(const base::Closure& callback); 65 void ReadImmutableAttributes(const base::Closure& callback);
66 66
67 // Locks the device to be an enterprise device registered by the given user. 67 // Locks the device to be an enterprise device registered by the given user.
68 // This can also be called after the lock has already been taken, in which 68 // This can also be called after the lock has already been taken, in which
69 // case it checks that the passed user agrees with the locked attribute. 69 // case it checks that the passed user agrees with the locked attribute.
70 // |callback| must not be null and is called with the result. 70 // |callback| must not be null and is called with the result. Must not be
71 // called while a previous LockDevice() invocation is still pending.
71 void LockDevice(const std::string& user, 72 void LockDevice(const std::string& user,
72 DeviceMode device_mode, 73 DeviceMode device_mode,
73 const std::string& device_id, 74 const std::string& device_id,
74 const LockResultCallback& callback); 75 const LockResultCallback& callback);
75 76
76 // Checks whether this is an enterprise device. 77 // Checks whether this is an enterprise device.
77 bool IsEnterpriseDevice(); 78 bool IsEnterpriseDevice();
78 79
79 // Checks whether this is a consumer kiosk enabled device. 80 // Checks whether this is a consumer kiosk enabled device.
80 bool IsConsumerKioskDeviceWithAutoLaunch(); 81 bool IsConsumerKioskDeviceWithAutoLaunch();
81 82
82 // Gets the domain this device belongs to or an empty string if the device is 83 // Gets the domain this device belongs to or an empty string if the device is
83 // not an enterprise device. 84 // not an enterprise device.
84 std::string GetDomain(); 85 std::string GetDomain();
85 86
86 // Gets the user that registered the device. Returns an empty string if the 87 // Gets the user that registered the device. Returns an empty string if the
87 // device is not an enterprise device. 88 // device is not an enterprise device.
88 std::string GetRegistrationUser(); 89 std::string GetRegistrationUser();
89 90
90 // Gets the device id that was generated when the device was registered. 91 // Gets the device id that was generated when the device was registered.
91 // Returns an empty string if the device is not an enterprise device or the 92 // Returns an empty string if the device is not an enterprise device or the
92 // device id was not stored in the lockbox (prior to R19). 93 // device id was not stored in the lockbox (prior to R19).
93 std::string GetDeviceId(); 94 std::string GetDeviceId();
94 95
95 // Gets the mode the device was enrolled to. The return value for devices that 96 // Gets the mode the device was enrolled to. The return value for devices that
96 // are not locked yet will be DEVICE_MODE_UNKNOWN. 97 // are not locked yet will be DEVICE_MODE_UNKNOWN.
97 DeviceMode GetMode(); 98 DeviceMode GetMode();
98 99
99 protected: 100 protected:
101 // True if install attributes have been read successfully. False if read
102 // failed or no read attempt was made.
100 bool device_locked_; 103 bool device_locked_;
104
105 // Whether the TPM / install attributes consistency check is running.
106 bool consistency_check_running_;
107
108 // To be run after the consistency check has finished.
109 base::Closure post_check_action_;
110
111 // Wether the LockDevice() initiated TPM calls are running.
112 bool device_lock_running_;
113
101 std::string registration_user_; 114 std::string registration_user_;
102 std::string registration_domain_; 115 std::string registration_domain_;
103 std::string registration_device_id_; 116 std::string registration_device_id_;
104 DeviceMode registration_mode_; 117 DeviceMode registration_mode_;
105 118
106 private: 119 private:
107 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, 120 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
108 DeviceLockedFromOlderVersion); 121 DeviceLockedFromOlderVersion);
122 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, Init);
109 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, 123 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
110 ReadCacheFile); 124 InitForConsumerKiosk);
111 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
112 ReadCacheFileForConsumerKiosk);
113 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, 125 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
114 VerifyFakeInstallAttributesCache); 126 VerifyFakeInstallAttributesCache);
115 127
116 // Constants for the possible device modes that can be stored in the lockbox. 128 // Constants for the possible device modes that can be stored in the lockbox.
117 static const char kConsumerDeviceMode[]; 129 static const char kConsumerDeviceMode[];
118 static const char kEnterpriseDeviceMode[]; 130 static const char kEnterpriseDeviceMode[];
119 static const char kLegacyRetailDeviceMode[]; 131 static const char kLegacyRetailDeviceMode[];
120 static const char kConsumerKioskDeviceMode[]; 132 static const char kConsumerKioskDeviceMode[];
121 static const char kUnknownDeviceMode[]; 133 static const char kUnknownDeviceMode[];
122 134
(...skipping 28 matching lines...) Expand all
151 DeviceMode device_mode, 163 DeviceMode device_mode,
152 const std::string& device_id, 164 const std::string& device_id,
153 const LockResultCallback& callback, 165 const LockResultCallback& callback,
154 chromeos::DBusMethodCallStatus call_status, 166 chromeos::DBusMethodCallStatus call_status,
155 bool result); 167 bool result);
156 168
157 // Confirms the registered user and invoke the callback. 169 // Confirms the registered user and invoke the callback.
158 void OnReadImmutableAttributes(const std::string& user, 170 void OnReadImmutableAttributes(const std::string& user,
159 const LockResultCallback& callback); 171 const LockResultCallback& callback);
160 172
173 // Check state of install attributes against TPM lock state and generate UMA
174 // for the result. Asynchronously retry |dbus_retries| times in case of DBUS
175 // errors (cryptohomed startup is slow).
176 void TriggerConsistencyCheck(int dbus_retries);
177
178 // Callback for TpmIsOwned() DBUS call. Generates UMA or schedules retry in
179 // case of DBUS error.
180 void OnTpmOwnerCheckCompleted(int dbus_retries_remaining,
181 chromeos::DBusMethodCallStatus call_status,
182 bool result);
183
161 chromeos::CryptohomeClient* cryptohome_client_; 184 chromeos::CryptohomeClient* cryptohome_client_;
162 185
163 base::WeakPtrFactory<EnterpriseInstallAttributes> weak_ptr_factory_; 186 base::WeakPtrFactory<EnterpriseInstallAttributes> weak_ptr_factory_;
164 187
165 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); 188 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes);
166 }; 189 };
167 190
168 } // namespace policy 191 } // namespace policy
169 192
170 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 193 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698