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

Side by Side Diff: chrome/browser/ui/crypto_module_delegate_nss.h

Issue 2922423002: Remove NSSCryptoModuleDelegate. (Closed)
Patch Set: Created 3 years, 6 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 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"
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
13 #include "chrome/browser/ui/crypto_module_password_dialog.h" 12 #include "chrome/browser/ui/crypto_module_password_dialog.h"
14 #include "crypto/nss_crypto_module_delegate.h" 13 #include "crypto/nss_crypto_module_delegate.h"
15 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
16 15
17 namespace content {
18 class ResourceContext;
19 }
20
21 // Delegate to handle unlocking a slot or indicating which slot to store a key 16 // Delegate to handle unlocking a slot or indicating which slot to store a key
22 // in. When passing to NSS functions which take a wincx argument, use the value 17 // in. When passing to NSS functions which take a wincx argument, use the value
23 // returned from the wincx() method. 18 // returned from the wincx() method.
24 class ChromeNSSCryptoModuleDelegate 19 class ChromeNSSCryptoModuleDelegate
25 : public crypto::NSSCryptoModuleDelegate { 20 : public crypto::CryptoModuleBlockingPasswordDelegate {
26 public: 21 public:
27 // Create a ChromeNSSCryptoModuleDelegate. |reason| is used to select what 22 // Create a ChromeNSSCryptoModuleDelegate. |reason| is used to select what
28 // string to show the user, |server| is displayed to indicate which connection 23 // string to show the user, |server| is displayed to indicate which connection
29 // is causing the dialog to appear. |slot| can be NULL. 24 // is causing the dialog to appear. |slot| can be NULL.
30 ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason, 25 ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason,
31 const net::HostPortPair& server, 26 const net::HostPortPair& server);
32 crypto::ScopedPK11Slot slot);
33 27
34 ~ChromeNSSCryptoModuleDelegate() override; 28 ~ChromeNSSCryptoModuleDelegate() override;
35 29
36 // Must be called on IO thread. Creates a delegate and returns it
37 // synchronously or asynchronously to |callback|. If the delegate could not be
38 // created, |callback| is called with NULL.
39 static void CreateForResourceContext(
40 chrome::CryptoModulePasswordReason reason,
41 const net::HostPortPair& server,
42 content::ResourceContext* context,
43 const base::Callback<
44 void(std::unique_ptr<ChromeNSSCryptoModuleDelegate>)>& callback);
45
46 // crypto::NSSCryptoModuleDelegate implementation.
47 crypto::ScopedPK11Slot RequestSlot() override;
48
49 // crypto::CryptoModuleBlockingPasswordDelegate implementation. 30 // crypto::CryptoModuleBlockingPasswordDelegate implementation.
50 std::string RequestPassword(const std::string& slot_name, 31 std::string RequestPassword(const std::string& slot_name,
51 bool retry, 32 bool retry,
52 bool* cancelled) override; 33 bool* cancelled) override;
53 34
54 private: 35 private:
55 void ShowDialog(const std::string& slot_name, bool retry); 36 void ShowDialog(const std::string& slot_name, bool retry);
56 37
57 void GotPassword(const std::string& password); 38 void GotPassword(const std::string& password);
58 39
59 // Parameters displayed in the dialog. 40 // Parameters displayed in the dialog.
60 const chrome::CryptoModulePasswordReason reason_; 41 const chrome::CryptoModulePasswordReason reason_;
61 net::HostPortPair server_; 42 net::HostPortPair server_;
62 43
63 // Event to block worker thread while waiting for dialog on UI thread. 44 // Event to block worker thread while waiting for dialog on UI thread.
64 base::WaitableEvent event_; 45 base::WaitableEvent event_;
65 46
66 // Stores the results from the dialog for access on worker thread. 47 // Stores the results from the dialog for access on worker thread.
67 std::string password_; 48 std::string password_;
68 bool cancelled_; 49 bool cancelled_;
69 50
70 // The slot which will be returned by RequestSlot.
71 crypto::ScopedPK11Slot slot_;
72
73 DISALLOW_COPY_AND_ASSIGN(ChromeNSSCryptoModuleDelegate); 51 DISALLOW_COPY_AND_ASSIGN(ChromeNSSCryptoModuleDelegate);
74 }; 52 };
75 53
76 // Create a delegate which only handles unlocking slots. 54 // Create a delegate which only handles unlocking slots.
77 crypto::CryptoModuleBlockingPasswordDelegate* 55 crypto::CryptoModuleBlockingPasswordDelegate*
78 CreateCryptoModuleBlockingPasswordDelegate( 56 CreateCryptoModuleBlockingPasswordDelegate(
79 chrome::CryptoModulePasswordReason reason, 57 chrome::CryptoModulePasswordReason reason,
80 const net::HostPortPair& server); 58 const net::HostPortPair& server);
81 59
82 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ 60 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/nss_context_linux.cc ('k') | chrome/browser/ui/crypto_module_delegate_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698