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

Unified Diff: chromeos/tpm_token_loader.h

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Linux implementation. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/tpm_token_loader.h
diff --git a/chromeos/tpm_token_loader.h b/chromeos/tpm_token_loader.h
index 16e20ef12e98d7054e172c0cdd9547f52ffada9e..33fffa2d19b55cb6d565742a68347bf759f9e236 100644
--- a/chromeos/tpm_token_loader.h
+++ b/chromeos/tpm_token_loader.h
@@ -32,16 +32,15 @@ namespace chromeos {
// See CryptohomeClient::OnPkcs11GetTpmTokenInfo.
class CHROMEOS_EXPORT TPMTokenLoader : public LoginState::Observer {
public:
- class Observer {
- public:
- // Called when the TPM token initialization is done or the case where TPM
- // should stay disabled is detected (e.g. on guest login).
- virtual void OnTPMTokenReady() = 0;
-
- protected:
- virtual ~Observer() {}
+ enum TPMTokenStatus {
+ TPM_TOKEN_STATUS_UNDETERMINED,
+ TPM_TOKEN_STATUS_ENABLED,
+ TPM_TOKEN_STATUS_DISABLED
};
+ typedef base::Callback<void(bool)> TPMReadyCallback;
+ typedef std::vector<TPMReadyCallback> TPMReadyCallbackList;
+
// Sets the global instance. Must be called before any calls to Get().
// The global instance will immediately start observing |LoginState|.
static void Initialize();
@@ -65,11 +64,9 @@ class CHROMEOS_EXPORT TPMTokenLoader : public LoginState::Observer {
void SetCryptoTaskRunner(
const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner);
- void AddObserver(TPMTokenLoader::Observer* observer);
- void RemoveObserver(TPMTokenLoader::Observer* observer);
-
- // Checks if the TPM token in ready to be used.
- bool IsTPMTokenReady() const;
+ // Checks if the TPM token is enabled. If the state is unknown, |callback|
+ // will be called back once the TPM state is known.
+ TPMTokenStatus IsTPMTokenEnabled(const TPMReadyCallback& callback);
std::string tpm_user_pin() const { return tpm_user_pin_; }
@@ -77,6 +74,8 @@ class CHROMEOS_EXPORT TPMTokenLoader : public LoginState::Observer {
explicit TPMTokenLoader(bool for_test);
virtual ~TPMTokenLoader();
+ bool IsTPMLoadingEnabled() const;
+
// Starts tpm token initialization if the user is logged in and the crypto
// task runner is set.
void MaybeStartTokenInitialization();
@@ -106,7 +105,7 @@ class CHROMEOS_EXPORT TPMTokenLoader : public LoginState::Observer {
bool initialized_for_test_;
- ObserverList<Observer> observers_;
+ TPMReadyCallbackList tpm_ready_callback_list_;
// The states are traversed in this order but some might get omitted or never
// be left.

Powered by Google App Engine
This is Rietveld 408576698