Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/views/device_chooser_content_view.h" | 13 #include "chrome/browser/ui/views/device_chooser_content_view.h" |
| 14 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | |
| 15 #include "chrome/browser/ui/views/harmony/sized_dialog_client_view.h" | |
| 14 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 16 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 17 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/views/background.h" | |
| 18 #include "ui/views/controls/link.h" | 21 #include "ui/views/controls/link.h" |
| 19 #include "ui/views/controls/styled_label.h" | 22 #include "ui/views/controls/styled_label.h" |
| 20 #include "ui/views/layout/layout_constants.h" | 23 #include "ui/views/layout/fill_layout.h" |
| 21 #include "ui/views/window/dialog_client_view.h" | 24 #include "ui/views/window/dialog_client_view.h" |
| 22 | 25 |
| 23 ChooserDialogView::ChooserDialogView( | 26 ChooserDialogView::ChooserDialogView( |
| 24 std::unique_ptr<ChooserController> chooser_controller) { | 27 std::unique_ptr<ChooserController> chooser_controller) { |
| 25 // ------------------------------------ | 28 // ------------------------------------ |
| 26 // | Chooser dialog title | | 29 // | Chooser dialog title | |
| 27 // | -------------------------------- | | 30 // | -------------------------------- | |
| 28 // | | option 0 | | | 31 // | | option 0 | | |
| 29 // | | option 1 | | | 32 // | | option 1 | | |
| 30 // | | option 2 | | | 33 // | | option 2 | | |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 | 66 |
| 64 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const { | 67 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 65 return device_chooser_content_view_->IsDialogButtonEnabled(button); | 68 return device_chooser_content_view_->IsDialogButtonEnabled(button); |
| 66 } | 69 } |
| 67 | 70 |
| 68 views::View* ChooserDialogView::CreateFootnoteView() { | 71 views::View* ChooserDialogView::CreateFootnoteView() { |
| 69 return device_chooser_content_view_->footnote_link(); | 72 return device_chooser_content_view_->footnote_link(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { | 75 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { |
| 76 const int kMinWidth = 402; | |
|
Peter Kasting
2017/02/07 00:17:15
Nit: constexpr
Elly Fong-Jones
2017/02/07 14:02:10
Done.
| |
| 77 const int kMinHeight = 320; | |
| 78 int min_width = LayoutDelegate::Get()->GetDialogPreferredWidth( | |
| 79 LayoutDelegate::DialogWidth::MEDIUM); | |
| 80 if (!min_width) | |
| 81 min_width = kMinWidth; | |
| 82 gfx::Size minimum_size(min_width, kMinHeight); | |
| 73 views::DialogClientView* client = | 83 views::DialogClientView* client = |
| 74 new views::DialogClientView(widget, GetContentsView()); | 84 new SizedDialogClientView(widget, GetContentsView(), minimum_size); |
| 75 client->set_button_row_insets(gfx::Insets()); | 85 LayoutDelegate* delegate = LayoutDelegate::Get(); |
| 86 client->set_button_row_insets(gfx::Insets( | |
| 87 delegate->GetMetric( | |
| 88 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING), | |
| 89 0, 0, 0)); | |
| 76 return client; | 90 return client; |
| 77 } | 91 } |
| 78 | 92 |
| 79 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( | 93 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( |
| 80 views::Widget* widget) { | 94 views::Widget* widget) { |
| 81 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should | 95 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should |
| 82 // always be true. | 96 // always be true. |
| 83 DCHECK(ShouldUseCustomFrame()); | 97 DCHECK(ShouldUseCustomFrame()); |
| 98 LayoutDelegate* delegate = LayoutDelegate::Get(); | |
| 84 return views::DialogDelegate::CreateDialogFrameView( | 99 return views::DialogDelegate::CreateDialogFrameView( |
| 85 widget, gfx::Insets(views::kPanelVertMargin, views::kPanelHorizMargin, | 100 widget, |
| 86 views::kPanelVertMargin, views::kPanelHorizMargin)); | 101 gfx::Insets( |
| 102 delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | |
|
Peter Kasting
2017/02/07 00:17:15
Nit: Factor to a temp
Elly Fong-Jones
2017/02/07 14:02:10
switched to the 1-arg form of gfx::Insets() instea
| |
| 103 delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN))); | |
| 87 } | 104 } |
| 88 | 105 |
| 89 bool ChooserDialogView::Accept() { | 106 bool ChooserDialogView::Accept() { |
| 90 device_chooser_content_view_->Accept(); | 107 device_chooser_content_view_->Accept(); |
| 91 return true; | 108 return true; |
| 92 } | 109 } |
| 93 | 110 |
| 94 bool ChooserDialogView::Cancel() { | 111 bool ChooserDialogView::Cancel() { |
| 95 device_chooser_content_view_->Cancel(); | 112 device_chooser_content_view_->Cancel(); |
| 96 return true; | 113 return true; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 void ChromeDevicePermissionsPrompt::ShowDialogViews() { | 155 void ChromeDevicePermissionsPrompt::ShowDialogViews() { |
| 139 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 156 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 140 | 157 |
| 141 std::unique_ptr<ChooserController> chooser_controller( | 158 std::unique_ptr<ChooserController> chooser_controller( |
| 142 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), | 159 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), |
| 143 prompt())); | 160 prompt())); |
| 144 | 161 |
| 145 constrained_window::ShowWebModalDialogViews( | 162 constrained_window::ShowWebModalDialogViews( |
| 146 new ChooserDialogView(std::move(chooser_controller)), web_contents()); | 163 new ChooserDialogView(std::move(chooser_controller)), web_contents()); |
| 147 } | 164 } |
| OLD | NEW |