| 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 "chrome/browser/chooser_controller/chooser_controller.h" | 8 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 9 #include "chrome/browser/extensions/chrome_extension_chooser_dialog.h" | 9 #include "chrome/browser/extensions/chrome_extension_chooser_dialog.h" |
| 10 #include "chrome/browser/ui/views/chooser_content_view.h" | 10 #include "chrome/browser/ui/views/chooser_content_view.h" |
| 11 #include "components/constrained_window/constrained_window_views.h" | 11 #include "components/constrained_window/constrained_window_views.h" |
| 12 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 12 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ui/gfx/geometry/insets.h" |
| 14 #include "ui/views/controls/link.h" | 15 #include "ui/views/controls/link.h" |
| 15 #include "ui/views/controls/styled_label.h" | 16 #include "ui/views/controls/styled_label.h" |
| 17 #include "ui/views/layout/layout_constants.h" |
| 16 #include "ui/views/window/dialog_client_view.h" | 18 #include "ui/views/window/dialog_client_view.h" |
| 17 | 19 |
| 18 ChooserDialogView::ChooserDialogView( | 20 ChooserDialogView::ChooserDialogView( |
| 19 std::unique_ptr<ChooserController> chooser_controller) { | 21 std::unique_ptr<ChooserController> chooser_controller) { |
| 20 // ------------------------------------ | 22 // ------------------------------------ |
| 21 // | Chooser dialog title | | 23 // | Chooser dialog title | |
| 22 // | -------------------------------- | | 24 // | -------------------------------- | |
| 23 // | | option 0 | | | 25 // | | option 0 | | |
| 24 // | | option 1 | | | 26 // | | option 1 | | |
| 25 // | | option 2 | | | 27 // | | option 2 | | |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 base::string16 ChooserDialogView::GetDialogButtonLabel( | 56 base::string16 ChooserDialogView::GetDialogButtonLabel( |
| 55 ui::DialogButton button) const { | 57 ui::DialogButton button) const { |
| 56 return chooser_content_view_->GetDialogButtonLabel(button); | 58 return chooser_content_view_->GetDialogButtonLabel(button); |
| 57 } | 59 } |
| 58 | 60 |
| 59 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const { | 61 bool ChooserDialogView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 60 return chooser_content_view_->IsDialogButtonEnabled(button); | 62 return chooser_content_view_->IsDialogButtonEnabled(button); |
| 61 } | 63 } |
| 62 | 64 |
| 63 views::View* ChooserDialogView::CreateFootnoteView() { | 65 views::View* ChooserDialogView::CreateFootnoteView() { |
| 64 return chooser_content_view_->CreateFootnoteView(); | 66 return chooser_content_view_->footnote_link(); |
| 67 } |
| 68 |
| 69 views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) { |
| 70 views::DialogClientView* client = |
| 71 new views::DialogClientView(widget, GetContentsView()); |
| 72 client->set_button_row_insets(gfx::Insets()); |
| 73 return client; |
| 74 } |
| 75 |
| 76 views::NonClientFrameView* ChooserDialogView::CreateNonClientFrameView( |
| 77 views::Widget* widget) { |
| 78 // ChooserDialogView always has a parent, so ShouldUseCustomFrame() should |
| 79 // always be true. |
| 80 DCHECK(ShouldUseCustomFrame()); |
| 81 return views::DialogDelegate::CreateDialogFrameView( |
| 82 widget, gfx::Insets(views::kPanelVertMargin, views::kPanelHorizMargin, |
| 83 views::kPanelVertMargin, views::kPanelHorizMargin)); |
| 65 } | 84 } |
| 66 | 85 |
| 67 bool ChooserDialogView::Accept() { | 86 bool ChooserDialogView::Accept() { |
| 68 chooser_content_view_->Accept(); | 87 chooser_content_view_->Accept(); |
| 69 return true; | 88 return true; |
| 70 } | 89 } |
| 71 | 90 |
| 72 bool ChooserDialogView::Cancel() { | 91 bool ChooserDialogView::Cancel() { |
| 73 chooser_content_view_->Cancel(); | 92 chooser_content_view_->Cancel(); |
| 74 return true; | 93 return true; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 105 DCHECK(chooser_controller); | 124 DCHECK(chooser_controller); |
| 106 | 125 |
| 107 web_modal::WebContentsModalDialogManager* manager = | 126 web_modal::WebContentsModalDialogManager* manager = |
| 108 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_); | 127 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_); |
| 109 if (manager) { | 128 if (manager) { |
| 110 constrained_window::ShowWebModalDialogViews( | 129 constrained_window::ShowWebModalDialogViews( |
| 111 new ChooserDialogView(std::move(chooser_controller)), web_contents_); | 130 new ChooserDialogView(std::move(chooser_controller)), web_contents_); |
| 112 } | 131 } |
| 113 } | 132 } |
| OLD | NEW |