Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / ui / views / certificate_selector.h
blobe4f52cf79149f4559861e8d0a7e53a46eff45419
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
6 #define CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "net/cert/x509_certificate.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/table/table_view_observer.h"
14 #include "ui/views/window/dialog_delegate.h"
16 namespace content {
17 class WebContents;
20 namespace views {
21 class LabelButton;
22 class TableView;
25 namespace chrome {
27 // A base class for dialogs that show a given list of certificates to the user.
28 // The user can select a single certificate and look at details of each
29 // certificate.
30 // The currently selected certificate can be obtained using |GetSelectedCert()|.
31 // The explanatory text shown to the user must be provided to |InitWithText()|.
32 class CertificateSelector : public views::DialogDelegateView,
33 public views::ButtonListener,
34 public views::TableViewObserver {
35 public:
36 class CertificateTableModel;
38 // |web_contents| must not be null.
39 CertificateSelector(const net::CertificateList& certificates,
40 content::WebContents* web_contents);
41 ~CertificateSelector() override;
43 // Returns the currently selected certificate or null if none is selected.
44 // Must be called after |InitWithText()|.
45 net::X509Certificate* GetSelectedCert() const;
47 // Shows this dialog as a constrained web modal dialog and focuses the first
48 // certificate.
49 // Must be called after |InitWithText()|.
50 void Show();
52 // DialogDelegateView:
53 bool CanResize() const override;
54 base::string16 GetWindowTitle() const override;
55 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
56 views::View* GetInitiallyFocusedView() override;
57 views::View* CreateExtraView() override;
58 ui::ModalType GetModalType() const override;
60 // views::ButtonListener:
61 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
63 // views::TableViewObserver:
64 void OnSelectionChanged() override;
65 void OnDoubleClick() override;
67 protected:
68 // Initializes the dialog. |text| is shown above the list of certificates
69 // and is supposed to explain to the user what the implication of the
70 // certificate selection is.
71 void InitWithText(const base::string16& text);
73 private:
74 const net::CertificateList certificates_;
75 scoped_ptr<CertificateTableModel> model_;
77 content::WebContents* const web_contents_;
79 views::TableView* table_;
80 views::LabelButton* view_cert_button_;
82 DISALLOW_COPY_AND_ASSIGN(CertificateSelector);
85 } // namespace chrome
87 #endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_