OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ |
7 | 7 |
8 #include <string> | |
9 #include <vector> | 8 #include <vector> |
bartfab (slow)
2015/02/20 12:19:47
This: This is only needed in the implementation fi
pneubeck (no reviews)
2015/02/20 14:02:50
Done.
| |
10 | 9 |
11 #include "base/basictypes.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | |
bartfab (slow)
2015/02/20 12:19:47
This: This is only needed in the implementation fi
pneubeck (no reviews)
2015/02/20 14:02:50
Done.
| |
12 #include "base/memory/scoped_ptr.h" | |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
13 #include "chrome/browser/ssl/ssl_client_auth_observer.h" | 14 #include "net/cert/x509_certificate.h" |
14 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" | |
15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/controls/table/table_view_observer.h" | 16 #include "ui/views/controls/table/table_view_observer.h" |
17 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
18 | 18 |
19 // This header file exists only for testing. Chrome should access the | 19 namespace content { |
20 // certificate selector only through the cross-platform interface | 20 class WebContents; |
21 // chrome/browser/ssl_client_certificate_selector.h. | |
22 | |
23 namespace net { | |
24 class SSLCertRequestInfo; | |
25 class X509Certificate; | |
26 } | 21 } |
27 | 22 |
28 namespace views { | 23 namespace views { |
29 class LabelButton; | 24 class LabelButton; |
30 class TableView; | 25 class TableView; |
31 class Widget; | |
32 } | 26 } |
33 | 27 |
34 class CertificateSelectorTableModel; | 28 namespace chrome { |
35 | 29 |
36 class SSLClientCertificateSelector : public SSLClientAuthObserver, | 30 // A base class for dialogs that shows a given list of certificates to the user. |
bartfab (slow)
2015/02/20 12:19:47
Nit: s/shows/show/
pneubeck (no reviews)
2015/02/20 14:02:50
Done.
| |
37 public views::DialogDelegateView, | 31 // The user can select a single certificate and look at details of each |
38 public views::ButtonListener, | 32 // certificate. |
39 public views::TableViewObserver { | 33 // The currently selected certificate can be obtained using |GetSelectedCert()|. |
34 // The explanatory text shown to the user must be provided to |Init()|. | |
35 class CertificateSelector : public views::DialogDelegateView, | |
36 public views::ButtonListener, | |
37 public views::TableViewObserver { | |
40 public: | 38 public: |
41 SSLClientCertificateSelector( | 39 class CertificateTableModel; |
42 content::WebContents* web_contents, | |
43 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, | |
44 const chrome::SelectCertificateCallback& callback); | |
45 ~SSLClientCertificateSelector() override; | |
46 | 40 |
47 void Init(); | 41 // |web_contents| must not be null. |
42 CertificateSelector(const net::CertificateList& certificates, | |
43 content::WebContents* web_contents); | |
44 ~CertificateSelector() override; | |
48 | 45 |
46 // Returns the currently selected certificate or null if none is selected. | |
47 // Must be called after Init(). | |
bartfab (slow)
2015/02/20 12:19:47
Nit: This documentation needs updating. There is n
pneubeck (no reviews)
2015/02/20 14:02:50
Done.
| |
49 net::X509Certificate* GetSelectedCert() const; | 48 net::X509Certificate* GetSelectedCert() const; |
50 | 49 |
51 // SSLClientAuthObserver implementation: | 50 // Shows this dialog as a constrained web modal dialog and focuses the first |
52 void OnCertSelectedByNotification() override; | 51 // certificate. |
bartfab (slow)
2015/02/20 12:19:47
Nit: Does InitWithText() need to be called before
pneubeck (no reviews)
2015/02/20 14:02:50
Done.
| |
52 void Show(); | |
53 | 53 |
54 // DialogDelegateView: | 54 // DialogDelegateView: |
55 bool CanResize() const override; | 55 bool CanResize() const override; |
56 base::string16 GetWindowTitle() const override; | 56 base::string16 GetWindowTitle() const override; |
57 void DeleteDelegate() override; | |
58 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | 57 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
59 bool Cancel() override; | |
60 bool Accept() override; | |
61 views::View* GetInitiallyFocusedView() override; | 58 views::View* GetInitiallyFocusedView() override; |
62 views::View* CreateExtraView() override; | 59 views::View* CreateExtraView() override; |
63 ui::ModalType GetModalType() const override; | 60 ui::ModalType GetModalType() const override; |
64 | 61 |
65 // views::ButtonListener: | 62 // views::ButtonListener: |
66 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 63 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
67 | 64 |
68 // views::TableViewObserver: | 65 // views::TableViewObserver: |
69 void OnSelectionChanged() override; | 66 void OnSelectionChanged() override; |
70 void OnDoubleClick() override; | 67 void OnDoubleClick() override; |
71 | 68 |
69 protected: | |
70 // Initializes the dialog. |text| is shown above the list of certificates | |
71 // and is supposed to explain to the user what the implication of the | |
72 // certificate selection is. | |
73 void InitWithText(const base::string16& text); | |
74 | |
72 private: | 75 private: |
73 void CreateCertTable(); | 76 const net::CertificateList certificates_; |
77 scoped_ptr<CertificateTableModel> model_; | |
74 | 78 |
75 // Callback after unlocking certificate slot. | 79 content::WebContents* const web_contents_; |
76 void Unlocked(net::X509Certificate* cert); | |
77 | |
78 scoped_ptr<CertificateSelectorTableModel> model_; | |
79 | |
80 content::WebContents* web_contents_; | |
81 | 80 |
82 views::TableView* table_; | 81 views::TableView* table_; |
83 views::LabelButton* view_cert_button_; | 82 views::LabelButton* view_cert_button_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector); | 84 DISALLOW_COPY_AND_ASSIGN(CertificateSelector); |
86 }; | 85 }; |
87 | 86 |
88 #endif // CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_ | 87 } // namespace chrome |
88 | |
89 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ | |
OLD | NEW |