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 #include "chrome/browser/ui/views/certificate_selector.h" | 5 #include "chrome/browser/ui/views/certificate_selector.h" |
6 | 6 |
7 #include <stddef.h> // For size_t. | 7 #include <stddef.h> // For size_t. |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/certificate_viewer.h" | 13 #include "chrome/browser/certificate_viewer.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "components/constrained_window/constrained_window_views.h" | 15 #include "components/constrained_window/constrained_window_views.h" |
16 #include "components/guest_view/browser/guest_view_base.h" | |
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
16 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/models/table_model.h" | 20 #include "ui/base/models/table_model.h" |
19 #include "ui/base/models/table_model_observer.h" | 21 #include "ui/base/models/table_model_observer.h" |
20 #include "ui/views/controls/button/label_button.h" | 22 #include "ui/views/controls/button/label_button.h" |
21 #include "ui/views/controls/table/table_view.h" | 23 #include "ui/views/controls/table/table_view.h" |
22 #include "ui/views/layout/grid_layout.h" | 24 #include "ui/views/layout/grid_layout.h" |
23 #include "ui/views/layout/layout_constants.h" | 25 #include "ui/views/layout/layout_constants.h" |
24 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
25 #include "ui/views/window/dialog_client_view.h" | 27 #include "ui/views/window/dialog_client_view.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 web_contents_(web_contents), | 82 web_contents_(web_contents), |
81 table_(nullptr), | 83 table_(nullptr), |
82 view_cert_button_(nullptr) { | 84 view_cert_button_(nullptr) { |
83 CHECK(web_contents_); | 85 CHECK(web_contents_); |
84 } | 86 } |
85 | 87 |
86 CertificateSelector::~CertificateSelector() { | 88 CertificateSelector::~CertificateSelector() { |
87 table_->SetModel(nullptr); | 89 table_->SetModel(nullptr); |
88 } | 90 } |
89 | 91 |
92 // Static. | |
davidben
2015/07/15 21:30:14
I think we usually just do:
// static
No caps or
wjmaclean
2015/07/15 23:06:24
Done.
| |
93 bool CertificateSelector::CanShow(content::WebContents* web_contents) { | |
94 // Note: in the following call, if web_contents is not a guest, then it is | |
95 // just used as the return value. | |
davidben
2015/07/15 21:30:14
Nit: This is a bit wordy. I would maybe phrase it
| |
96 content::WebContents* top_level_web_contents = | |
97 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); | |
98 return web_modal::WebContentsModalDialogManager::FromWebContents( | |
99 top_level_web_contents) != nullptr; | |
100 } | |
101 | |
90 void CertificateSelector::Show() { | 102 void CertificateSelector::Show() { |
91 constrained_window::ShowWebModalDialogViews(this, web_contents_); | 103 constrained_window::ShowWebModalDialogViews(this, web_contents_); |
92 | 104 |
93 // Select the first row automatically. This must be done after the dialog has | 105 // Select the first row automatically. This must be done after the dialog has |
94 // been created. | 106 // been created. |
95 table_->Select(0); | 107 table_->Select(0); |
96 } | 108 } |
97 | 109 |
98 void CertificateSelector::InitWithText(scoped_ptr<views::View> text_label) { | 110 void CertificateSelector::InitWithText(scoped_ptr<views::View> text_label) { |
99 views::GridLayout* const layout = views::GridLayout::CreatePanel(this); | 111 views::GridLayout* const layout = views::GridLayout::CreatePanel(this); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 void CertificateSelector::OnSelectionChanged() { | 185 void CertificateSelector::OnSelectionChanged() { |
174 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr); | 186 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr); |
175 } | 187 } |
176 | 188 |
177 void CertificateSelector::OnDoubleClick() { | 189 void CertificateSelector::OnDoubleClick() { |
178 if (GetSelectedCert()) | 190 if (GetSelectedCert()) |
179 GetDialogClientView()->AcceptWindow(); | 191 GetDialogClientView()->AcceptWindow(); |
180 } | 192 } |
181 | 193 |
182 } // namespace chrome | 194 } // namespace chrome |
OLD | NEW |