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/memory/ref_counted.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/ssl/ssl_client_auth_observer.h"
15 #include "chrome/browser/ssl/ssl_client_certificate_selector.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/table/table_view_observer.h"
18 #include "ui/views/view.h"
19 #include "ui/views/window/dialog_delegate.h"
21 // This header file exists only for testing. Chrome should access the
22 // certificate selector only through the cross-platform interface
23 // chrome/browser/ssl_client_certificate_selector.h.
26 class SSLCertRequestInfo
;
27 class X509Certificate
;
36 class CertificateSelectorTableModel
;
38 class SSLClientCertificateSelector
: public SSLClientAuthObserver
,
39 public views::DialogDelegateView
,
40 public views::ButtonListener
,
41 public views::TableViewObserver
{
43 SSLClientCertificateSelector(
44 content::WebContents
* web_contents
,
45 const net::HttpNetworkSession
* network_session
,
46 net::SSLCertRequestInfo
* cert_request_info
,
47 const chrome::SelectCertificateCallback
& callback
);
48 virtual ~SSLClientCertificateSelector();
52 net::X509Certificate
* GetSelectedCert() const;
54 // SSLClientAuthObserver implementation:
55 virtual void OnCertSelectedByNotification() OVERRIDE
;
57 // DialogDelegateView:
58 virtual bool CanResize() const OVERRIDE
;
59 virtual base::string16
GetWindowTitle() const OVERRIDE
;
60 virtual void DeleteDelegate() OVERRIDE
;
61 virtual bool IsDialogButtonEnabled(ui::DialogButton button
) const OVERRIDE
;
62 virtual bool Cancel() OVERRIDE
;
63 virtual bool Accept() OVERRIDE
;
64 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
65 virtual views::View
* CreateExtraView() OVERRIDE
;
66 virtual ui::ModalType
GetModalType() const OVERRIDE
;
68 // views::ButtonListener:
69 virtual void ButtonPressed(views::Button
* sender
,
70 const ui::Event
& event
) OVERRIDE
;
72 // views::TableViewObserver:
73 virtual void OnSelectionChanged() OVERRIDE
;
74 virtual void OnDoubleClick() OVERRIDE
;
77 void CreateCertTable();
79 // Callback after unlocking certificate slot.
80 void Unlocked(net::X509Certificate
* cert
);
82 scoped_ptr
<CertificateSelectorTableModel
> model_
;
84 content::WebContents
* web_contents_
;
86 views::Widget
* window_
;
87 views::TableView
* table_
;
88 views::LabelButton
* view_cert_button_
;
90 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector
);
93 #endif // CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_