| 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_delegate.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 constexpr int kMinWidth = 402; | 78 constexpr int kMinWidth = 402; |
| 79 constexpr int kMinHeight = 320; | 79 constexpr int kMinHeight = 320; |
| 80 int min_width = LayoutDelegate::Get()->GetDialogPreferredWidth( | 80 ChromeLayoutDelegate* delegate = ChromeLayoutDelegate::Get(); |
| 81 LayoutDelegate::DialogWidth::MEDIUM); | 81 int min_width = delegate->GetDialogPreferredWidth(DialogWidth::MEDIUM); |
| 82 if (!min_width) | 82 if (!min_width) |
| 83 min_width = kMinWidth; | 83 min_width = kMinWidth; |
| 84 client->set_minimum_size(gfx::Size(min_width, kMinHeight)); | 84 client->set_minimum_size(gfx::Size(min_width, kMinHeight)); |
| 85 | 85 |
| 86 LayoutDelegate* delegate = LayoutDelegate::Get(); | 86 client->set_button_row_insets( |
| 87 client->set_button_row_insets(gfx::Insets( | 87 gfx::Insets(delegate->GetDistanceMetric( |
| 88 delegate->GetMetric( | 88 ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL), |
| 89 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING), | 89 0, 0, 0)); |
| 90 0, 0, 0)); | |
| 91 return client; | 90 return client; |
| 92 } | 91 } |
| 93 | 92 |
| 94 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( | 93 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( |
| 95 views::Widget* widget) { | 94 views::Widget* widget) { |
| 96 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should | 95 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should |
| 97 // always be true. | 96 // always be true. |
| 98 DCHECK(ShouldUseCustomFrame()); | 97 DCHECK(ShouldUseCustomFrame()); |
| 99 return views::DialogDelegate::CreateDialogFrameView( | 98 return views::DialogDelegate::CreateDialogFrameView( |
| 100 widget, gfx::Insets(LayoutDelegate::Get()->GetMetric( | 99 widget, gfx::Insets(ChromeLayoutDelegate::Get()->GetDistanceMetric( |
| 101 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN))); | 100 ChromeDistanceMetric::PANEL_CONTENT_MARGIN))); |
| 102 } | 101 } |
| 103 | 102 |
| 104 bool ChooserDialogView::Accept() { | 103 bool ChooserDialogView::Accept() { |
| 105 device_chooser_content_view_->Accept(); | 104 device_chooser_content_view_->Accept(); |
| 106 return true; | 105 return true; |
| 107 } | 106 } |
| 108 | 107 |
| 109 bool ChooserDialogView::Cancel() { | 108 bool ChooserDialogView::Cancel() { |
| 110 device_chooser_content_view_->Cancel(); | 109 device_chooser_content_view_->Cancel(); |
| 111 return true; | 110 return true; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void ChromeDevicePermissionsPrompt::ShowDialogViews() { | 152 void ChromeDevicePermissionsPrompt::ShowDialogViews() { |
| 154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 153 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 155 | 154 |
| 156 std::unique_ptr<ChooserController> chooser_controller( | 155 std::unique_ptr<ChooserController> chooser_controller( |
| 157 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), | 156 new DevicePermissionsDialogController(web_contents()->GetMainFrame(), |
| 158 prompt())); | 157 prompt())); |
| 159 | 158 |
| 160 constrained_window::ShowWebModalDialogViews( | 159 constrained_window::ShowWebModalDialogViews( |
| 161 new ChooserDialogView(std::move(chooser_controller)), web_contents()); | 160 new ChooserDialogView(std::move(chooser_controller)), web_contents()); |
| 162 } | 161 } |
| OLD | NEW |