| OLD | NEW |
| 1 // Copyright 2015 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_CERTIFICATE_SELECTOR_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "net/cert/x509_certificate.h" | 12 #include "net/ssl/client_cert_identity.h" |
| 13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/table/table_view_observer.h" | 14 #include "ui/views/controls/table/table_view_observer.h" |
| 15 #include "ui/views/window/dialog_delegate.h" | 15 #include "ui/views/window/dialog_delegate.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class WebContents; | 18 class WebContents; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 class LabelButton; | 22 class LabelButton; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 class CertificateSelector : public views::DialogDelegateView, | 38 class CertificateSelector : public views::DialogDelegateView, |
| 39 public views::ButtonListener, | 39 public views::ButtonListener, |
| 40 public views::TableViewObserver { | 40 public views::TableViewObserver { |
| 41 public: | 41 public: |
| 42 // Indicates if the dialog can be successfully shown. | 42 // Indicates if the dialog can be successfully shown. |
| 43 // TODO(davidben): Remove this when the certificate selector prompt is moved | 43 // TODO(davidben): Remove this when the certificate selector prompt is moved |
| 44 // to the WebContentsDelegate. https://crbug.com/456255. | 44 // to the WebContentsDelegate. https://crbug.com/456255. |
| 45 static bool CanShow(content::WebContents* web_contents); | 45 static bool CanShow(content::WebContents* web_contents); |
| 46 | 46 |
| 47 // |web_contents| must not be null. | 47 // |web_contents| must not be null. |
| 48 CertificateSelector(const net::CertificateList& certificates, | 48 CertificateSelector(net::ClientCertIdentityList certificates, |
| 49 content::WebContents* web_contents); | 49 content::WebContents* web_contents); |
| 50 ~CertificateSelector() override; | 50 ~CertificateSelector() override; |
| 51 | 51 |
| 52 // Returns the currently selected certificate or null if none is selected. | 52 // Returns the currently selected certificate or null if none is selected. |
| 53 // Must be called after |InitWithText()|. | 53 // Must be called after |InitWithText()|. |
| 54 net::X509Certificate* GetSelectedCert() const; | 54 net::ClientCertIdentity* GetSelectedCert() const; |
| 55 | 55 |
| 56 // Shows this dialog as a constrained web modal dialog and focuses the first | 56 // Shows this dialog as a constrained web modal dialog and focuses the first |
| 57 // certificate. | 57 // certificate. |
| 58 // Must be called after |InitWithText()|. | 58 // Must be called after |InitWithText()|. |
| 59 void Show(); | 59 void Show(); |
| 60 | 60 |
| 61 // DialogDelegateView: | 61 // DialogDelegateView: |
| 62 bool CanResize() const override; | 62 bool CanResize() const override; |
| 63 base::string16 GetWindowTitle() const override; | 63 base::string16 GetWindowTitle() const override; |
| 64 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | 64 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 // Initializes the dialog. |text| is shown above the list of certificates | 81 // Initializes the dialog. |text| is shown above the list of certificates |
| 82 // and is supposed to explain to the user what the implication of the | 82 // and is supposed to explain to the user what the implication of the |
| 83 // certificate selection is. | 83 // certificate selection is. |
| 84 void InitWithText(std::unique_ptr<views::View> text_label); | 84 void InitWithText(std::unique_ptr<views::View> text_label); |
| 85 | 85 |
| 86 ui::TableModel* table_model_for_testing() const; | 86 ui::TableModel* table_model_for_testing() const; |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 class CertificateTableModel; | 89 class CertificateTableModel; |
| 90 | 90 |
| 91 net::CertificateList certificates_; | 91 net::ClientCertIdentityList certificates_; |
| 92 | 92 |
| 93 // Whether to show the provider column in the table or not. Certificates | 93 // Whether to show the provider column in the table or not. Certificates |
| 94 // provided by the platform show the empty string as provider. That column is | 94 // provided by the platform show the empty string as provider. That column is |
| 95 // shown only if there is at least one non-empty provider, i.e. non-platform | 95 // shown only if there is at least one non-empty provider, i.e. non-platform |
| 96 // certificate. | 96 // certificate. |
| 97 bool show_provider_column_ = false; | 97 bool show_provider_column_ = false; |
| 98 std::unique_ptr<CertificateTableModel> model_; | 98 std::unique_ptr<CertificateTableModel> model_; |
| 99 | 99 |
| 100 content::WebContents* const web_contents_; | 100 content::WebContents* const web_contents_; |
| 101 | 101 |
| 102 views::TableView* table_; | 102 views::TableView* table_; |
| 103 views::LabelButton* view_cert_button_; | 103 views::LabelButton* view_cert_button_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(CertificateSelector); | 105 DISALLOW_COPY_AND_ASSIGN(CertificateSelector); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace chrome | 108 } // namespace chrome |
| 109 | 109 |
| 110 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ | 110 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ |
| OLD | NEW |