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

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

Issue 932553002: Refactor SSLClientCertificateSelector for reuse with platformKeys API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_perms
Patch Set: Addressed Mike's comment. Created 5 years, 10 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 (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 "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 dialog that shows a given list of certificates to the user. The user can
37 public views::DialogDelegateView, 31 // select a single certificate and look at details of each certificate.
38 public views::ButtonListener, 32 // The currently selected certificate can be obtained using |GetSelectedCert()|.
39 public views::TableViewObserver { 33 // The explanatory text shown to the user must be provided to |Init()|.
34 class CertificateSelector : public views::DialogDelegateView,
35 public views::ButtonListener,
36 public views::TableViewObserver {
40 public: 37 public:
41 SSLClientCertificateSelector( 38 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 39
47 void Init(); 40 // |web_contents| must not be null.
41 CertificateSelector(const net::CertificateList& certificates,
42 content::WebContents* web_contents);
43 ~CertificateSelector() override;
48 44
45 // Initializes the dialog and shows it as a constrained web modal dialog.
46 // |text| is shown above the list of certificates and is supposed to explain
47 // to the user what the implication of the certificate selection is.
48 void Init(const base::string16& text);
49
50 // Returns the currently selected certificate or null if none is selected.
51 // Must be called after Init().
49 net::X509Certificate* GetSelectedCert() const; 52 net::X509Certificate* GetSelectedCert() const;
50 53
51 // SSLClientAuthObserver implementation:
52 void OnCertSelectedByNotification() override;
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
72 private: 69 private:
73 void CreateCertTable(); 70 const net::CertificateList certificates_;
71 scoped_ptr<CertificateTableModel> model_;
74 72
75 // Callback after unlocking certificate slot. 73 content::WebContents* const web_contents_;
76 void Unlocked(net::X509Certificate* cert);
77
78 scoped_ptr<CertificateSelectorTableModel> model_;
79
80 content::WebContents* web_contents_;
81 74
82 views::TableView* table_; 75 views::TableView* table_;
83 views::LabelButton* view_cert_button_; 76 views::LabelButton* view_cert_button_;
84 77
85 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector); 78 DISALLOW_COPY_AND_ASSIGN(CertificateSelector);
86 }; 79 };
87 80
88 #endif // CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_ 81 } // namespace chrome
82
83 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698