Chromium Code Reviews| 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> |
| 10 | 9 |
| 11 #include "base/basictypes.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | |
| 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 "chrome/browser/ssl/ssl_client_certificate_selector.h" | |
| 15 #include "ui/views/controls/button/button.h" | 14 #include "ui/views/controls/button/button.h" |
| 16 #include "ui/views/controls/table/table_view_observer.h" | 15 #include "ui/views/controls/table/table_view_observer.h" |
| 17 #include "ui/views/window/dialog_delegate.h" | 16 #include "ui/views/window/dialog_delegate.h" |
| 18 | 17 |
| 19 // This header file exists only for testing. Chrome should access the | 18 namespace content { |
| 20 // certificate selector only through the cross-platform interface | 19 class WebContents; |
| 21 // chrome/browser/ssl_client_certificate_selector.h. | 20 } |
| 22 | 21 |
| 23 namespace net { | 22 namespace net { |
| 24 class SSLCertRequestInfo; | |
| 25 class X509Certificate; | 23 class X509Certificate; |
| 24 typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; | |
|
msw
2015/02/19 19:53:53
nit: avoid the X509Certificate forward decl and du
pneubeck (no reviews)
2015/02/19 20:43:49
Done.
| |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace views { | 27 namespace views { |
| 29 class LabelButton; | 28 class LabelButton; |
| 30 class TableView; | 29 class TableView; |
| 31 class Widget; | |
| 32 } | 30 } |
| 33 | 31 |
| 34 class CertificateSelectorTableModel; | 32 namespace chrome { |
| 35 | 33 |
| 36 class SSLClientCertificateSelector : public SSLClientAuthObserver, | 34 // A dialog that shows a given list of certificates to the user. The user can |
| 37 public views::DialogDelegateView, | 35 // select a single certificate and look at details of each certificate. |
| 38 public views::ButtonListener, | 36 // Sub-classes can get the current certificate using |GetSelectedCert()|. The |
|
bartfab (slow)
2015/02/19 17:53:07
Why can only subclasses get the certificate? GetSe
pneubeck (no reviews)
2015/02/19 19:43:51
Done.
| |
| 39 public views::TableViewObserver { | 37 // explnatory text shown to the user must be provided to |Init()|. |
|
bartfab (slow)
2015/02/19 17:53:07
Nit: s/explnatory/explanatory/
pneubeck (no reviews)
2015/02/19 19:43:51
Done.
| |
| 38 class CertificateSelector : public views::DialogDelegateView, | |
| 39 public views::ButtonListener, | |
| 40 public views::TableViewObserver { | |
| 40 public: | 41 public: |
| 41 SSLClientCertificateSelector( | 42 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 | 43 |
| 47 void Init(); | 44 // |web_contents| must not be null. |
| 45 CertificateSelector(const net::CertificateList& certificates, | |
| 46 content::WebContents* web_contents); | |
| 47 ~CertificateSelector() override; | |
| 48 | 48 |
| 49 // Initializes the dialog and shows it as a constrained web modal dialog. | |
| 50 // |text| is shown above the list of certificates and is supposed to explain | |
| 51 // the user what the implication of the certificate selection is. | |
|
bartfab (slow)
2015/02/19 17:53:07
Nit: s/the/to the/
pneubeck (no reviews)
2015/02/19 19:43:51
Done.
| |
| 52 void Init(const base::string16& text); | |
| 53 | |
| 54 // Returns the currently selected certificate or null if none is selected. | |
| 49 net::X509Certificate* GetSelectedCert() const; | 55 net::X509Certificate* GetSelectedCert() const; |
| 50 | 56 |
| 51 // SSLClientAuthObserver implementation: | |
| 52 void OnCertSelectedByNotification() override; | |
| 53 | |
| 54 // DialogDelegateView: | 57 // DialogDelegateView: |
| 55 bool CanResize() const override; | 58 bool CanResize() const override; |
| 56 base::string16 GetWindowTitle() const override; | 59 base::string16 GetWindowTitle() const override; |
| 57 void DeleteDelegate() override; | 60 void DeleteDelegate() override; |
| 58 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | 61 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
| 59 bool Cancel() override; | |
| 60 bool Accept() override; | |
| 61 views::View* GetInitiallyFocusedView() override; | 62 views::View* GetInitiallyFocusedView() override; |
| 62 views::View* CreateExtraView() override; | 63 views::View* CreateExtraView() override; |
| 63 ui::ModalType GetModalType() const override; | 64 ui::ModalType GetModalType() const override; |
| 64 | 65 |
| 65 // views::ButtonListener: | 66 // views::ButtonListener: |
| 66 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 67 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 67 | 68 |
| 68 // views::TableViewObserver: | 69 // views::TableViewObserver: |
| 69 void OnSelectionChanged() override; | 70 void OnSelectionChanged() override; |
| 70 void OnDoubleClick() override; | 71 void OnDoubleClick() override; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 void CreateCertTable(); | 74 views::TableView* CreateCertTable(); |
|
bartfab (slow)
2015/02/19 17:53:07
Nit: Return a scoped_ptr.
pneubeck (no reviews)
2015/02/19 19:43:51
Done.
| |
| 74 | 75 |
| 75 // Callback after unlocking certificate slot. | 76 const net::CertificateList certificates_; |
| 76 void Unlocked(net::X509Certificate* cert); | 77 scoped_ptr<CertificateTableModel> model_; |
| 77 | 78 |
| 78 scoped_ptr<CertificateSelectorTableModel> model_; | 79 content::WebContents* const web_contents_; |
| 79 | 80 |
| 80 content::WebContents* web_contents_; | 81 views::TableView* table_ = nullptr; |
|
msw
2015/02/19 19:53:53
Do not assign default values here, use the constru
pneubeck (no reviews)
2015/02/19 20:43:49
I wonder why, considering that this doesn't requir
| |
| 82 views::LabelButton* view_cert_button_ = nullptr; | |
| 81 | 83 |
| 82 views::TableView* table_; | 84 DISALLOW_COPY_AND_ASSIGN(CertificateSelector); |
| 83 views::LabelButton* view_cert_button_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector); | |
| 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 |