| 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 "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 15 #include "components/constrained_window/constrained_window_views.h" | 15 #include "components/constrained_window/constrained_window_views.h" |
| 16 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 16 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "ui/gfx/geometry/insets.h" | 18 #include "ui/gfx/geometry/insets.h" |
| 19 #include "ui/views/background.h" | 19 #include "ui/views/background.h" |
| 20 #include "ui/views/controls/link.h" | 20 #include "ui/views/controls/link.h" |
| 21 #include "ui/views/controls/styled_label.h" | 21 #include "ui/views/controls/styled_label.h" |
| 22 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
| 23 #include "ui/views/window/dialog_client_view.h" | 23 #include "ui/views/window/dialog_client_view.h" |
| 24 | 24 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 views::View* ChooserDialogView::CreateFootnoteView() { | 70 views::View* ChooserDialogView::CreateFootnoteView() { |
| 71 return device_chooser_content_view_->footnote_link(); | 71 return device_chooser_content_view_->footnote_link(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { | 74 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { |
| 75 views::DialogClientView* client = | 75 views::DialogClientView* client = |
| 76 new views::DialogClientView(widget, GetContentsView()); | 76 new views::DialogClientView(widget, GetContentsView()); |
| 77 | 77 |
| 78 LayoutDelegate* delegate = LayoutDelegate::Get(); | 78 constexpr int kMinWidth = 402; |
| 79 constexpr int kMinHeight = 320; |
| 80 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 81 int min_width = provider->GetDialogPreferredWidth(DialogWidth::MEDIUM); |
| 82 if (!min_width) |
| 83 min_width = kMinWidth; |
| 84 client->set_minimum_size(gfx::Size(min_width, kMinHeight)); |
| 85 |
| 79 client->set_button_row_insets(gfx::Insets( | 86 client->set_button_row_insets(gfx::Insets( |
| 80 delegate->GetMetric( | 87 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL), 0, 0, |
| 81 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING), | 88 0)); |
| 82 0, 0, 0)); | |
| 83 return client; | 89 return client; |
| 84 } | 90 } |
| 85 | 91 |
| 86 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( | 92 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( |
| 87 views::Widget* widget) { | 93 views::Widget* widget) { |
| 88 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should | 94 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should |
| 89 // always be true. | 95 // always be true. |
| 90 DCHECK(ShouldUseCustomFrame()); | 96 DCHECK(ShouldUseCustomFrame()); |
| 91 return views::DialogDelegate::CreateDialogFrameView( | 97 return views::DialogDelegate::CreateDialogFrameView( |
| 92 widget, gfx::Insets(LayoutDelegate::Get()->GetMetric( | 98 widget, gfx::Insets(ChromeLayoutProvider::Get()->GetDistanceMetric( |
| 93 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN))); | 99 DISTANCE_PANEL_CONTENT_MARGIN))); |
| 94 } | 100 } |
| 95 | 101 |
| 96 bool ChooserDialogView::Accept() { | 102 bool ChooserDialogView::Accept() { |
| 97 device_chooser_content_view_->Accept(); | 103 device_chooser_content_view_->Accept(); |
| 98 return true; | 104 return true; |
| 99 } | 105 } |
| 100 | 106 |
| 101 bool ChooserDialogView::Cancel() { | 107 bool ChooserDialogView::Cancel() { |
| 102 device_chooser_content_view_->Cancel(); | 108 device_chooser_content_view_->Cancel(); |
| 103 return true; | 109 return true; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void ChromeDevicePermissionsPrompt::ShowDialogViews() { | 151 void ChromeDevicePermissionsPrompt::ShowDialogViews() { |
| 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 152 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 147 | 153 |
| 148 std::unique_ptr<ChooserController> chooser_controller( | 154 std::unique_ptr<ChooserController> chooser_controller( |
| 149 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), | 155 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), |
| 150 prompt())); | 156 prompt())); |
| 151 | 157 |
| 152 constrained_window::ShowWebModalDialogViews( | 158 constrained_window::ShowWebModalDialogViews( |
| 153 new ChooserDialogView(std::move(chooser_controller)), web_contents()); | 159 new ChooserDialogView(std::move(chooser_controller)), web_contents()); |
| 154 } | 160 } |
| OLD | NEW |