Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/ui/views/certificate_selector.h

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 identities,
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
56 // Take ownership of the currently selected certificate or null if none is
Peter Kasting 2017/06/15 22:13:41 Nit: Take -> Takes (see note about imperative comm
mattm 2017/06/16 03:30:42 done
57 // selected. Must be called after |InitWithText()|.
Peter Kasting 2017/06/15 22:13:41 Nit: No need for || on function names (the () is t
mattm 2017/06/16 03:30:42 Acknowledged.
58 std::unique_ptr<net::ClientCertIdentity> TakeSelectedCert();
55 59
56 // Shows this dialog as a constrained web modal dialog and focuses the first 60 // Shows this dialog as a constrained web modal dialog and focuses the first
57 // certificate. 61 // certificate.
58 // Must be called after |InitWithText()|. 62 // Must be called after |InitWithText()|.
59 void Show(); 63 void Show();
60 64
61 // DialogDelegateView: 65 // DialogDelegateView:
62 bool CanResize() const override; 66 bool CanResize() const override;
63 base::string16 GetWindowTitle() const override; 67 base::string16 GetWindowTitle() const override;
64 bool IsDialogButtonEnabled(ui::DialogButton button) const override; 68 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
(...skipping 16 matching lines...) Expand all
81 // Initializes the dialog. |text| is shown above the list of certificates 85 // 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 86 // and is supposed to explain to the user what the implication of the
83 // certificate selection is. 87 // certificate selection is.
84 void InitWithText(std::unique_ptr<views::View> text_label); 88 void InitWithText(std::unique_ptr<views::View> text_label);
85 89
86 ui::TableModel* table_model_for_testing() const; 90 ui::TableModel* table_model_for_testing() const;
87 91
88 private: 92 private:
89 class CertificateTableModel; 93 class CertificateTableModel;
90 94
91 net::CertificateList certificates_; 95 net::ClientCertIdentityList identities_;
92 96
93 // Whether to show the provider column in the table or not. Certificates 97 // 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 98 // 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 99 // shown only if there is at least one non-empty provider, i.e. non-platform
96 // certificate. 100 // certificate.
97 bool show_provider_column_ = false; 101 bool show_provider_column_ = false;
98 std::unique_ptr<CertificateTableModel> model_; 102 std::unique_ptr<CertificateTableModel> model_;
99 103
100 content::WebContents* const web_contents_; 104 content::WebContents* const web_contents_;
101 105
102 views::TableView* table_; 106 views::TableView* table_;
103 views::LabelButton* view_cert_button_; 107 views::LabelButton* view_cert_button_;
104 108
105 DISALLOW_COPY_AND_ASSIGN(CertificateSelector); 109 DISALLOW_COPY_AND_ASSIGN(CertificateSelector);
106 }; 110 };
107 111
108 } // namespace chrome 112 } // namespace chrome
109 113
110 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_ 114 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698