OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_ | |
6 #define CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/memory/linked_ptr.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "content/public/browser/web_contents_observer.h" | |
14 #include "content/public/browser/web_contents_user_data.h" | |
15 | |
16 class SSLAddCertHandler; | |
17 | |
18 namespace net { | |
19 class HttpNetworkSession; | |
20 class SSLCertRequestInfo; | |
21 class X509Certificate; | |
22 } | |
23 | |
24 class SSLTabHelper : public content::WebContentsObserver, | |
25 public content::WebContentsUserData<SSLTabHelper> { | |
26 public: | |
27 virtual ~SSLTabHelper(); | |
28 | |
29 // content::WebContentsObserver: | |
30 virtual void DidChangeVisibleSSLState() OVERRIDE; | |
31 | |
32 // Called when |handler| encounters an error in verifying a received client | |
33 // certificate. Note that, because CAs often will not send us intermediate | |
34 // certificates, the verification we can do is minimal: we verify the | |
35 // certificate is parseable, that we have the corresponding private key, and | |
36 // that the certificate has not expired. | |
37 void OnVerifyClientCertificateError( | |
38 scoped_refptr<SSLAddCertHandler> handler, int error_code); | |
39 | |
40 // Called when |handler| requests the user's confirmation in adding a client | |
41 // certificate. | |
42 void AskToAddClientCertificate( | |
43 scoped_refptr<SSLAddCertHandler> handler); | |
44 | |
45 // Called when |handler| successfully adds a client certificate. | |
46 void OnAddClientCertificateSuccess( | |
47 scoped_refptr<SSLAddCertHandler> handler); | |
48 | |
49 // Called when |handler| encounters an error adding a client certificate. | |
50 void OnAddClientCertificateError( | |
51 scoped_refptr<SSLAddCertHandler> handler, int error_code); | |
52 | |
53 // Called when |handler| has completed, so the delegate may release any state | |
54 // accumulated. | |
55 void OnAddClientCertificateFinished( | |
56 scoped_refptr<SSLAddCertHandler> handler); | |
57 | |
58 // Displays a dialog for selecting a client certificate and returns it to | |
59 // the |handler|. | |
60 void ShowClientCertificateRequestDialog( | |
61 const net::HttpNetworkSession* network_session, | |
62 net::SSLCertRequestInfo* cert_request_info, | |
63 const base::Callback<void(net::X509Certificate*)>& callback); | |
64 | |
65 private: | |
66 explicit SSLTabHelper(content::WebContents* contents); | |
67 friend class content::WebContentsUserData<SSLTabHelper>; | |
68 | |
69 content::WebContents* web_contents_; | |
70 | |
71 class SSLAddCertData; | |
72 std::map<int, linked_ptr<SSLAddCertData> > request_id_to_add_cert_data_; | |
73 | |
74 SSLAddCertData* GetAddCertData(SSLAddCertHandler* handler); | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(SSLTabHelper); | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_ | |
OLD | NEW |