OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROMEOS_TPM_TOKEN_LOADER_H_ | 5 #ifndef CHROMEOS_TPM_TOKEN_LOADER_H_ |
6 #define CHROMEOS_TPM_TOKEN_LOADER_H_ | 6 #define CHROMEOS_TPM_TOKEN_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 private: | 74 private: |
75 explicit TPMTokenLoader(bool for_test); | 75 explicit TPMTokenLoader(bool for_test); |
76 virtual ~TPMTokenLoader(); | 76 virtual ~TPMTokenLoader(); |
77 | 77 |
78 // Starts tpm token initialization if the user is logged in and the crypto | 78 // Starts tpm token initialization if the user is logged in and the crypto |
79 // task runner is set. | 79 // task runner is set. |
80 void MaybeStartTokenInitialization(); | 80 void MaybeStartTokenInitialization(); |
81 | 81 |
82 // This is the cyclic chain of callbacks to initialize the TPM token. | 82 // This is the cyclic chain of callbacks to initialize the TPM token. |
83 void ContinueTokenInitialization(); | 83 void ContinueTokenInitialization(); |
84 void OnPersistentNSSDBOpened(); | 84 void OnTPMTokenEnabledForNSS(); |
85 void OnTpmIsEnabled(DBusMethodCallStatus call_status, | 85 void OnTpmIsEnabled(DBusMethodCallStatus call_status, |
86 bool tpm_is_enabled); | 86 bool tpm_is_enabled); |
87 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, | 87 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, |
88 bool is_tpm_token_ready); | 88 bool is_tpm_token_ready); |
89 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, | 89 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, |
90 const std::string& token_name, | 90 const std::string& token_name, |
91 const std::string& user_pin, | 91 const std::string& user_pin, |
92 int token_slot_id); | 92 int token_slot_id); |
93 void OnTPMTokenInitialized(bool success); | 93 void OnTPMTokenInitialized(bool success); |
94 | 94 |
95 // If token initialization step fails (e.g. if tpm token is not yet ready) | 95 // If token initialization step fails (e.g. if tpm token is not yet ready) |
96 // schedules the initialization step retry attempt after a timeout. | 96 // schedules the initialization step retry attempt after a timeout. |
97 void RetryTokenInitializationLater(); | 97 void RetryTokenInitializationLater(); |
98 | 98 |
99 // Notifies observers that the TPM token is ready. | 99 // Notifies observers that the TPM token is ready. |
100 void NotifyTPMTokenReady(); | 100 void NotifyTPMTokenReady(); |
101 | 101 |
102 // LoginState::Observer | 102 // LoginState::Observer |
103 virtual void LoggedInStateChanged() OVERRIDE; | 103 virtual void LoggedInStateChanged() OVERRIDE; |
104 | 104 |
105 bool initialized_for_test_; | 105 bool initialized_for_test_; |
106 | 106 |
107 ObserverList<Observer> observers_; | 107 ObserverList<Observer> observers_; |
108 | 108 |
109 // The states are traversed in this order but some might get omitted or never | 109 // The states are traversed in this order but some might get omitted or never |
110 // be left. | 110 // be left. |
111 enum TPMTokenState { | 111 enum TPMTokenState { |
112 TPM_STATE_UNKNOWN, | 112 TPM_STATE_UNKNOWN, |
113 TPM_INITIALIZATION_STARTED, | 113 TPM_INITIALIZATION_STARTED, |
114 TPM_DB_OPENED, | 114 TPM_TOKEN_ENABLED_FOR_NSS, |
115 TPM_DISABLED, | 115 TPM_DISABLED, |
116 TPM_ENABLED, | 116 TPM_ENABLED, |
117 TPM_TOKEN_READY, | 117 TPM_TOKEN_READY, |
118 TPM_TOKEN_INFO_RECEIVED, | 118 TPM_TOKEN_INFO_RECEIVED, |
119 TPM_TOKEN_INITIALIZED, | 119 TPM_TOKEN_INITIALIZED, |
120 }; | 120 }; |
121 TPMTokenState tpm_token_state_; | 121 TPMTokenState tpm_token_state_; |
122 | 122 |
123 // The current request delay before the next attempt to initialize the | 123 // The current request delay before the next attempt to initialize the |
124 // TPM. Will be adapted after each attempt. | 124 // TPM. Will be adapted after each attempt. |
(...skipping 10 matching lines...) Expand all Loading... |
135 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; | 135 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; |
136 | 136 |
137 base::WeakPtrFactory<TPMTokenLoader> weak_factory_; | 137 base::WeakPtrFactory<TPMTokenLoader> weak_factory_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(TPMTokenLoader); | 139 DISALLOW_COPY_AND_ASSIGN(TPMTokenLoader); |
140 }; | 140 }; |
141 | 141 |
142 } // namespace chromeos | 142 } // namespace chromeos |
143 | 143 |
144 #endif // CHROMEOS_TPM_TOKEN_LOADER_H_ | 144 #endif // CHROMEOS_TPM_TOKEN_LOADER_H_ |
OLD | NEW |