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_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_
6 #define CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ssl/ssl_client_auth_observer.h"
14 #include "chrome/browser/ssl/ssl_client_certificate_selector.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/table/table_view_observer.h"
17 #include "ui/views/window/dialog_delegate.h"
19 // This header file exists only for testing. Chrome should access the
20 // certificate selector only through the cross-platform interface
21 // chrome/browser/ssl_client_certificate_selector.h.
24 class SSLCertRequestInfo
;
25 class X509Certificate
;
34 class CertificateSelectorTableModel
;
36 class SSLClientCertificateSelector
: public SSLClientAuthObserver
,
37 public views::DialogDelegateView
,
38 public views::ButtonListener
,
39 public views::TableViewObserver
{
41 SSLClientCertificateSelector(
42 content::WebContents
* web_contents
,
43 const net::HttpNetworkSession
* network_session
,
44 net::SSLCertRequestInfo
* cert_request_info
,
45 const chrome::SelectCertificateCallback
& callback
);
46 virtual ~SSLClientCertificateSelector();
50 net::X509Certificate
* GetSelectedCert() const;
52 // SSLClientAuthObserver implementation:
53 virtual void OnCertSelectedByNotification() OVERRIDE
;
55 // DialogDelegateView:
56 virtual bool CanResize() const OVERRIDE
;
57 virtual base::string16
GetWindowTitle() const OVERRIDE
;
58 virtual void DeleteDelegate() OVERRIDE
;
59 virtual bool IsDialogButtonEnabled(ui::DialogButton button
) const OVERRIDE
;
60 virtual bool Cancel() OVERRIDE
;
61 virtual bool Accept() OVERRIDE
;
62 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
63 virtual views::View
* CreateExtraView() OVERRIDE
;
64 virtual ui::ModalType
GetModalType() const OVERRIDE
;
66 // views::ButtonListener:
67 virtual void ButtonPressed(views::Button
* sender
,
68 const ui::Event
& event
) OVERRIDE
;
70 // views::TableViewObserver:
71 virtual void OnSelectionChanged() OVERRIDE
;
72 virtual void OnDoubleClick() OVERRIDE
;
75 void CreateCertTable();
77 // Callback after unlocking certificate slot.
78 void Unlocked(net::X509Certificate
* cert
);
80 scoped_ptr
<CertificateSelectorTableModel
> model_
;
82 content::WebContents
* web_contents_
;
84 views::TableView
* table_
;
85 views::LabelButton
* view_cert_button_
;
87 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector
);
90 #endif // CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_