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