OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "content/browser/renderer_host/render_view_host_delegate.h" | 13 #include "content/browser/renderer_host/render_view_host_delegate.h" |
14 | 14 |
15 class SSLAddCertHandler; | 15 class SSLAddCertHandler; |
16 class SSLClientAuthHandler; | 16 class SSLClientAuthHandler; |
17 class TabContentsWrapper; | 17 class TabContentsWrapper; |
18 | 18 |
19 class TabContentsSSLHelper { | 19 class TabContentsSSLHelper { |
20 public: | 20 public: |
21 explicit TabContentsSSLHelper(TabContentsWrapper* tab_contents); | 21 explicit TabContentsSSLHelper(TabContentsWrapper* tab_contents); |
22 virtual ~TabContentsSSLHelper(); | 22 virtual ~TabContentsSSLHelper(); |
23 | 23 |
24 // Selects the client certificate to submit and returns it to the |handler|. | |
25 void SelectClientCertificate(scoped_refptr<SSLClientAuthHandler> handler); | |
26 | |
27 // Called when |handler| encounters an error in verifying a received client | 24 // Called when |handler| encounters an error in verifying a received client |
28 // certificate. Note that, because CAs often will not send us intermediate | 25 // certificate. Note that, because CAs often will not send us intermediate |
29 // certificates, the verification we can do is minimal: we verify the | 26 // certificates, the verification we can do is minimal: we verify the |
30 // certificate is parseable, that we have the corresponding private key, and | 27 // certificate is parseable, that we have the corresponding private key, and |
31 // that the certificate has not expired. | 28 // that the certificate has not expired. |
32 void OnVerifyClientCertificateError( | 29 void OnVerifyClientCertificateError( |
33 scoped_refptr<SSLAddCertHandler> handler, int error_code); | 30 scoped_refptr<SSLAddCertHandler> handler, int error_code); |
34 | 31 |
35 // Called when |handler| requests the user's confirmation in adding a client | 32 // Called when |handler| requests the user's confirmation in adding a client |
36 // certificate. | 33 // certificate. |
37 void AskToAddClientCertificate( | 34 void AskToAddClientCertificate( |
38 scoped_refptr<SSLAddCertHandler> handler); | 35 scoped_refptr<SSLAddCertHandler> handler); |
39 | 36 |
40 // Called when |handler| successfully adds a client certificate. | 37 // Called when |handler| successfully adds a client certificate. |
41 void OnAddClientCertificateSuccess( | 38 void OnAddClientCertificateSuccess( |
42 scoped_refptr<SSLAddCertHandler> handler); | 39 scoped_refptr<SSLAddCertHandler> handler); |
43 | 40 |
44 // Called when |handler| encounters an error adding a client certificate. | 41 // Called when |handler| encounters an error adding a client certificate. |
45 void OnAddClientCertificateError( | 42 void OnAddClientCertificateError( |
46 scoped_refptr<SSLAddCertHandler> handler, int error_code); | 43 scoped_refptr<SSLAddCertHandler> handler, int error_code); |
47 | 44 |
48 // Called when |handler| has completed, so the delegate may release any state | 45 // Called when |handler| has completed, so the delegate may release any state |
49 // accumulated. | 46 // accumulated. |
50 void OnAddClientCertificateFinished( | 47 void OnAddClientCertificateFinished( |
51 scoped_refptr<SSLAddCertHandler> handler); | 48 scoped_refptr<SSLAddCertHandler> handler); |
52 | 49 |
53 private: | |
54 // Displays a dialog for selecting a client certificate and returns it to | 50 // Displays a dialog for selecting a client certificate and returns it to |
55 // the |handler|. | 51 // the |handler|. |
56 void ShowClientCertificateRequestDialog( | 52 void ShowClientCertificateRequestDialog( |
57 scoped_refptr<SSLClientAuthHandler> handler); | 53 scoped_refptr<SSLClientAuthHandler> handler); |
58 | 54 |
| 55 private: |
59 TabContentsWrapper* tab_contents_; | 56 TabContentsWrapper* tab_contents_; |
60 | 57 |
61 class SSLAddCertData; | 58 class SSLAddCertData; |
62 std::map<int, linked_ptr<SSLAddCertData> > request_id_to_add_cert_data_; | 59 std::map<int, linked_ptr<SSLAddCertData> > request_id_to_add_cert_data_; |
63 | 60 |
64 SSLAddCertData* GetAddCertData(SSLAddCertHandler* handler); | 61 SSLAddCertData* GetAddCertData(SSLAddCertHandler* handler); |
65 | 62 |
66 DISALLOW_COPY_AND_ASSIGN(TabContentsSSLHelper); | 63 DISALLOW_COPY_AND_ASSIGN(TabContentsSSLHelper); |
67 }; | 64 }; |
68 | 65 |
69 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ | 66 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_ |
OLD | NEW |