OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ | 5 #ifndef CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ |
6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ | 6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ChromeNSSCryptoModuleDelegate | 24 class ChromeNSSCryptoModuleDelegate |
25 : public crypto::NSSCryptoModuleDelegate { | 25 : public crypto::NSSCryptoModuleDelegate { |
26 public: | 26 public: |
27 // Create a ChromeNSSCryptoModuleDelegate. |reason| is used to select what | 27 // Create a ChromeNSSCryptoModuleDelegate. |reason| is used to select what |
28 // string to show the user, |server| is displayed to indicate which connection | 28 // string to show the user, |server| is displayed to indicate which connection |
29 // is causing the dialog to appear. |slot| can be NULL. | 29 // is causing the dialog to appear. |slot| can be NULL. |
30 ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason, | 30 ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason, |
31 const net::HostPortPair& server, | 31 const net::HostPortPair& server, |
32 crypto::ScopedPK11Slot slot); | 32 crypto::ScopedPK11Slot slot); |
33 | 33 |
34 ~ChromeNSSCryptoModuleDelegate() override; | |
35 | |
36 // Must be called on IO thread. Creates a delegate and returns it | 34 // Must be called on IO thread. Creates a delegate and returns it |
37 // synchronously or asynchronously to |callback|. If the delegate could not be | 35 // synchronously or asynchronously to |callback|. If the delegate could not be |
38 // created, |callback| is called with NULL. | 36 // created, |callback| is called with NULL. |
39 static void CreateForResourceContext( | 37 static void CreateForResourceContext( |
40 chrome::CryptoModulePasswordReason reason, | 38 chrome::CryptoModulePasswordReason reason, |
41 const net::HostPortPair& server, | 39 const net::HostPortPair& server, |
42 content::ResourceContext* context, | 40 content::ResourceContext* context, |
43 const base::Callback< | 41 const base::Callback<void(scoped_refptr<ChromeNSSCryptoModuleDelegate>)>& |
44 void(std::unique_ptr<ChromeNSSCryptoModuleDelegate>)>& callback); | 42 callback); |
45 | 43 |
46 // crypto::NSSCryptoModuleDelegate implementation. | 44 // crypto::NSSCryptoModuleDelegate implementation. |
47 crypto::ScopedPK11Slot RequestSlot() override; | 45 crypto::ScopedPK11Slot RequestSlot() override; |
48 | 46 |
49 // crypto::CryptoModuleBlockingPasswordDelegate implementation. | 47 // crypto::CryptoModuleBlockingPasswordDelegate implementation. |
50 std::string RequestPassword(const std::string& slot_name, | 48 std::string RequestPassword(const std::string& slot_name, |
51 bool retry, | 49 bool retry, |
52 bool* cancelled) override; | 50 bool* cancelled) override; |
53 | 51 |
54 private: | 52 private: |
| 53 friend class base::RefCountedThreadSafe<ChromeNSSCryptoModuleDelegate>; |
| 54 |
| 55 ~ChromeNSSCryptoModuleDelegate() override; |
| 56 |
55 void ShowDialog(const std::string& slot_name, bool retry); | 57 void ShowDialog(const std::string& slot_name, bool retry); |
56 | 58 |
57 void GotPassword(const std::string& password); | 59 void GotPassword(const std::string& password); |
58 | 60 |
59 // Parameters displayed in the dialog. | 61 // Parameters displayed in the dialog. |
60 const chrome::CryptoModulePasswordReason reason_; | 62 const chrome::CryptoModulePasswordReason reason_; |
61 net::HostPortPair server_; | 63 net::HostPortPair server_; |
62 | 64 |
63 // Event to block worker thread while waiting for dialog on UI thread. | 65 // Event to block worker thread while waiting for dialog on UI thread. |
64 base::WaitableEvent event_; | 66 base::WaitableEvent event_; |
65 | 67 |
66 // Stores the results from the dialog for access on worker thread. | 68 // Stores the results from the dialog for access on worker thread. |
67 std::string password_; | 69 std::string password_; |
68 bool cancelled_; | 70 bool cancelled_; |
69 | 71 |
70 // The slot which will be returned by RequestSlot. | 72 // The slot which will be returned by RequestSlot. |
71 crypto::ScopedPK11Slot slot_; | 73 crypto::ScopedPK11Slot slot_; |
72 | 74 |
73 DISALLOW_COPY_AND_ASSIGN(ChromeNSSCryptoModuleDelegate); | 75 DISALLOW_COPY_AND_ASSIGN(ChromeNSSCryptoModuleDelegate); |
74 }; | 76 }; |
75 | 77 |
76 // Create a delegate which only handles unlocking slots. | 78 // Create a delegate which only handles unlocking slots. |
77 crypto::CryptoModuleBlockingPasswordDelegate* | 79 crypto::CryptoModuleBlockingPasswordDelegate* |
78 CreateCryptoModuleBlockingPasswordDelegate( | 80 CreateCryptoModuleBlockingPasswordDelegate( |
79 chrome::CryptoModulePasswordReason reason, | 81 chrome::CryptoModulePasswordReason reason, |
80 const net::HostPortPair& server); | 82 const net::HostPortPair& server); |
81 | 83 |
82 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ | 84 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ |
OLD | NEW |