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.
5 #ifndef CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_
6 #define CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_
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"
16 class SSLAddCertHandler
;
19 class HttpNetworkSession
;
20 class SSLCertRequestInfo
;
21 class X509Certificate
;
24 class SSLTabHelper
: public content::WebContentsObserver
,
25 public content::WebContentsUserData
<SSLTabHelper
> {
27 virtual ~SSLTabHelper();
29 // content::WebContentsObserver:
30 virtual void DidChangeVisibleSSLState() OVERRIDE
;
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
);
40 // Called when |handler| requests the user's confirmation in adding a client
42 void AskToAddClientCertificate(
43 scoped_refptr
<SSLAddCertHandler
> handler
);
45 // Called when |handler| successfully adds a client certificate.
46 void OnAddClientCertificateSuccess(
47 scoped_refptr
<SSLAddCertHandler
> handler
);
49 // Called when |handler| encounters an error adding a client certificate.
50 void OnAddClientCertificateError(
51 scoped_refptr
<SSLAddCertHandler
> handler
, int error_code
);
53 // Called when |handler| has completed, so the delegate may release any state
55 void OnAddClientCertificateFinished(
56 scoped_refptr
<SSLAddCertHandler
> handler
);
58 // Displays a dialog for selecting a client certificate and returns it to
60 void ShowClientCertificateRequestDialog(
61 const net::HttpNetworkSession
* network_session
,
62 net::SSLCertRequestInfo
* cert_request_info
,
63 const base::Callback
<void(net::X509Certificate
*)>& callback
);
66 explicit SSLTabHelper(content::WebContents
* contents
);
67 friend class content::WebContentsUserData
<SSLTabHelper
>;
69 content::WebContents
* web_contents_
;
72 std::map
<int, linked_ptr
<SSLAddCertData
> > request_id_to_add_cert_data_
;
74 SSLAddCertData
* GetAddCertData(SSLAddCertHandler
* handler
);
76 DISALLOW_COPY_AND_ASSIGN(SSLTabHelper
);
79 #endif // CHROME_BROWSER_SSL_SSL_TAB_HELPER_H_