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

Side by Side Diff: chrome/browser/ui/views/extensions/chooser_dialog_view.cc

Issue 2932243002: Refactor ChooserDialogView to use borders instead of content margins. (Closed)
Patch Set: nits 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/extensions/chooser_dialog_view.h" 5 #include "chrome/browser/ui/views/extensions/chooser_dialog_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "chrome/browser/chooser_controller/chooser_controller.h" 9 #include "chrome/browser/chooser_controller/chooser_controller.h"
10 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" 10 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
11 #include "chrome/browser/extensions/chrome_extension_chooser_dialog.h" 11 #include "chrome/browser/extensions/chrome_extension_chooser_dialog.h"
12 #include "chrome/browser/extensions/device_permissions_dialog_controller.h" 12 #include "chrome/browser/extensions/device_permissions_dialog_controller.h"
13 #include "chrome/browser/ui/browser_dialogs.h" 13 #include "chrome/browser/ui/browser_dialogs.h"
14 #include "chrome/browser/ui/views/device_chooser_content_view.h" 14 #include "chrome/browser/ui/views/device_chooser_content_view.h"
15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" 15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
16 #include "components/constrained_window/constrained_window_views.h" 16 #include "components/constrained_window/constrained_window_views.h"
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" 17 #include "components/web_modal/web_contents_modal_dialog_manager.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "ui/gfx/geometry/insets.h" 19 #include "ui/gfx/geometry/insets.h"
20 #include "ui/views/background.h" 20 #include "ui/views/background.h"
21 #include "ui/views/border.h"
21 #include "ui/views/controls/link.h" 22 #include "ui/views/controls/link.h"
22 #include "ui/views/controls/styled_label.h" 23 #include "ui/views/controls/styled_label.h"
23 #include "ui/views/layout/fill_layout.h" 24 #include "ui/views/layout/fill_layout.h"
24 #include "ui/views/window/dialog_client_view.h" 25 #include "ui/views/window/dialog_client_view.h"
25 26
26 ChooserDialogView::ChooserDialogView( 27 ChooserDialogView::ChooserDialogView(
27 std::unique_ptr<ChooserController> chooser_controller) { 28 std::unique_ptr<ChooserController> chooser_controller) {
28 // ------------------------------------ 29 // ------------------------------------
29 // | Chooser dialog title | 30 // | Chooser dialog title |
30 // | -------------------------------- | 31 // | -------------------------------- |
31 // | | option 0 | | 32 // | | option 0 | |
32 // | | option 1 | | 33 // | | option 1 | |
33 // | | option 2 | | 34 // | | option 2 | |
34 // | | | | 35 // | | | |
35 // | | | | 36 // | | | |
36 // | | | | 37 // | | | |
37 // | -------------------------------- | 38 // | -------------------------------- |
38 // | [ Connect ] [ Cancel ] | 39 // | [ Connect ] [ Cancel ] |
39 // |----------------------------------| 40 // |----------------------------------|
40 // | Get help | 41 // | Get help |
41 // ------------------------------------ 42 // ------------------------------------
42 43
43 DCHECK(chooser_controller); 44 DCHECK(chooser_controller);
44 device_chooser_content_view_ = 45 device_chooser_content_view_ =
45 new DeviceChooserContentView(this, std::move(chooser_controller)); 46 new DeviceChooserContentView(this, std::move(chooser_controller));
47 device_chooser_content_view_->SetBorder(
48 views::CreateEmptyBorder(ChromeLayoutProvider::Get()->GetInsetsMetric(
49 views::INSETS_DIALOG_CONTENTS)));
46 chrome::RecordDialogCreation(chrome::DialogIdentifier::CHOOSER); 50 chrome::RecordDialogCreation(chrome::DialogIdentifier::CHOOSER);
47 } 51 }
48 52
49 ChooserDialogView::~ChooserDialogView() {} 53 ChooserDialogView::~ChooserDialogView() {}
50 54
51 base::string16 ChooserDialogView::GetWindowTitle() const { 55 base::string16 ChooserDialogView::GetWindowTitle() const {
52 return device_chooser_content_view_->GetWindowTitle(); 56 return device_chooser_content_view_->GetWindowTitle();
53 } 57 }
54 58
55 bool ChooserDialogView::ShouldShowCloseButton() const { 59 bool ChooserDialogView::ShouldShowCloseButton() const {
56 return false; 60 return false;
57 } 61 }
58 62
59 ui::ModalType ChooserDialogView::GetModalType() const { 63 ui::ModalType ChooserDialogView::GetModalType() const {
60 return ui::MODAL_TYPE_CHILD; 64 return ui::MODAL_TYPE_CHILD;
61 } 65 }
62 66
63 base::string16 ChooserDialogView::GetDialogButtonLabel( 67 base::string16 ChooserDialogView::GetDialogButtonLabel(
64 ui::DialogButton button) const { 68 ui::DialogButton button) const {
65 return device_chooser_content_view_->GetDialogButtonLabel(button); 69 return device_chooser_content_view_->GetDialogButtonLabel(button);
66 } 70 }
67 71
68 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const { 72 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const {
69 return device_chooser_content_view_->IsDialogButtonEnabled(button); 73 return device_chooser_content_view_->IsDialogButtonEnabled(button);
70 } 74 }
71 75
72 views::View* ChooserDialogView::CreateFootnoteView() { 76 views::View* ChooserDialogView::CreateFootnoteView() {
73 return device_chooser_content_view_->footnote_link(); 77 views::View* footnote_link = device_chooser_content_view_->footnote_link();
74 } 78 if (footnote_link) {
75 79 footnote_link->SetBorder(
76 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { 80 views::CreateEmptyBorder(ChromeLayoutProvider::Get()->GetInsetsMetric(
77 views::DialogClientView* client = 81 views::INSETS_DIALOG_CONTENTS)));
78 new views::DialogClientView(widget, GetContentsView()); 82 }
79 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); 83 return footnote_link;
80 client->SetButtonRowInsets(gfx::Insets(
81 provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL),
82 0, 0, 0));
83 return client;
84 }
85
86 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView(
87 views::Widget* widget) {
88 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should
89 // always be true.
90 DCHECK(ShouldUseCustomFrame());
91 return views::DialogDelegate::CreateDialogFrameView(
92 widget, ChromeLayoutProvider::Get()->GetInsetsMetric(
93 views::INSETS_BUBBLE_CONTENTS));
94 } 84 }
95 85
96 bool ChooserDialogView::Accept() { 86 bool ChooserDialogView::Accept() {
97 device_chooser_content_view_->Accept(); 87 device_chooser_content_view_->Accept();
98 return true; 88 return true;
99 } 89 }
100 90
101 bool ChooserDialogView::Cancel() { 91 bool ChooserDialogView::Cancel() {
102 device_chooser_content_view_->Cancel(); 92 device_chooser_content_view_->Cancel();
103 return true; 93 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 void ChromeDevicePermissionsPrompt::ShowDialogViews() { 135 void ChromeDevicePermissionsPrompt::ShowDialogViews() {
146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 136 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
147 137
148 std::unique_ptr<ChooserController> chooser_controller( 138 std::unique_ptr<ChooserController> chooser_controller(
149 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), 139 new DevicePermissionsDialogController(web_contents()->GetMainFrame(),
150 prompt())); 140 prompt()));
151 141
152 constrained_window::ShowWebModalDialogViews( 142 constrained_window::ShowWebModalDialogViews(
153 new ChooserDialogView(std::move(chooser_controller)), web_contents()); 143 new ChooserDialogView(std::move(chooser_controller)), web_contents());
154 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698