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 CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_TPM_PASSWORD_FETCHER_H_ | 5 #ifndef CHROMEOS_TPM_PASSWORD_FETCHER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_TPM_PASSWORD_FETCHER_H_ | 6 #define CHROMEOS_TPM_PASSWORD_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chromeos/chromeos_export.h" |
12 #include "chromeos/dbus/dbus_method_call_status.h" | 13 #include "chromeos/dbus/dbus_method_call_status.h" |
13 | 14 |
14 namespace chromeos { | 15 namespace chromeos { |
15 | 16 |
16 // Interface which TpmPasswordFetcher uses to notify that password has been | 17 // Interface which TpmPasswordFetcher uses to notify that password has been |
17 // fetched. | 18 // fetched. |
18 class TpmPasswordFetcherDelegate { | 19 class CHROMEOS_EXPORT TpmPasswordFetcherDelegate { |
19 public: | 20 public: |
20 virtual ~TpmPasswordFetcherDelegate() {} | 21 virtual ~TpmPasswordFetcherDelegate() {} |
21 virtual void OnPasswordFetched(const std::string& tpm_password) = 0; | 22 virtual void OnPasswordFetched(const std::string& tpm_password) = 0; |
22 }; | 23 }; |
23 | 24 |
24 // Class for fetching TPM password from the Cryptohome. | 25 // Class for fetching TPM password from the Cryptohome. |
25 class TpmPasswordFetcher { | 26 class CHROMEOS_EXPORT TpmPasswordFetcher { |
26 public: | 27 public: |
27 // Creates fetcher with the given delegate to be notified every time fetching | 28 // Creates fetcher with the given delegate to be notified every time fetching |
28 // is done. | 29 // is done. |
29 explicit TpmPasswordFetcher(TpmPasswordFetcherDelegate* delegate); | 30 explicit TpmPasswordFetcher(TpmPasswordFetcherDelegate* delegate); |
30 ~TpmPasswordFetcher(); | 31 ~TpmPasswordFetcher(); |
31 | 32 |
32 // Fetches TPM password and stores the result. Also notifies |delegate_| with | 33 // Fetches TPM password and stores the result. Also notifies |delegate_| with |
33 // OnPasswordFetched() call. | 34 // OnPasswordFetched() call. |
34 void Fetch(); | 35 void Fetch(); |
35 | 36 |
36 private: | 37 private: |
37 // Used to implement Fetch(). | 38 // Used to implement Fetch(). |
38 void OnTpmIsReady(DBusMethodCallStatus call_status, bool tpm_is_ready); | 39 void OnTpmIsReady(DBusMethodCallStatus call_status, bool tpm_is_ready); |
39 | 40 |
40 // Used to implement Fetch(). | 41 // Used to implement Fetch(). |
41 void OnTpmGetPassword(DBusMethodCallStatus call_status, | 42 void OnTpmGetPassword(DBusMethodCallStatus call_status, |
42 const std::string& password); | 43 const std::string& password); |
43 | 44 |
44 // Posts a task to call Fetch() later. | 45 // Posts a task to call Fetch() later. |
45 void RescheduleFetch(); | 46 void RescheduleFetch(); |
46 | 47 |
47 base::WeakPtrFactory<TpmPasswordFetcher> weak_factory_; | 48 base::WeakPtrFactory<TpmPasswordFetcher> weak_factory_; |
48 TpmPasswordFetcherDelegate* delegate_; | 49 TpmPasswordFetcherDelegate* delegate_; |
49 | 50 |
50 DISALLOW_COPY_AND_ASSIGN(TpmPasswordFetcher); | 51 DISALLOW_COPY_AND_ASSIGN(TpmPasswordFetcher); |
51 }; | 52 }; |
52 | 53 |
53 } // namespace chromeos | 54 } // namespace chromeos |
54 | 55 |
55 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_TPM_PASSWORD_FETCHER_H_ | 56 #endif // CHROMEOS_TPM_PASSWORD_FETCHER_H_ |
OLD | NEW |