Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/constrained_window/constrained_window_views.h" | 5 #include "components/constrained_window/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "components/constrained_window/constrained_window_views_client.h" | 11 #include "components/constrained_window/constrained_window_views_client.h" |
| 12 #include "components/constrained_window/native_web_contents_modal_dialog_manager _views.h" | |
| 12 #include "components/guest_view/browser/guest_view_base.h" | 13 #include "components/guest_view/browser/guest_view_base.h" |
| 13 #include "components/web_modal/web_contents_modal_dialog_host.h" | 14 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 14 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 16 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 16 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/widget/widget_observer.h" | 19 #include "ui/views/widget/widget_observer.h" |
| 19 #include "ui/views/window/dialog_delegate.h" | 20 #include "ui/views/window/dialog_delegate.h" |
| 20 | 21 |
| 21 using web_modal::ModalDialogHost; | 22 using web_modal::ModalDialogHost; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 size.SetToMin(max_size); | 126 size.SetToMin(max_size); |
| 126 UpdateModalDialogPosition(widget, dialog_host, size); | 127 UpdateModalDialogPosition(widget, dialog_host, size); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void UpdateWidgetModalDialogPosition(views::Widget* widget, | 130 void UpdateWidgetModalDialogPosition(views::Widget* widget, |
| 130 web_modal::ModalDialogHost* dialog_host) { | 131 web_modal::ModalDialogHost* dialog_host) { |
| 131 UpdateModalDialogPosition(widget, dialog_host, | 132 UpdateModalDialogPosition(widget, dialog_host, |
| 132 widget->GetRootView()->GetPreferredSize()); | 133 widget->GetRootView()->GetPreferredSize()); |
| 133 } | 134 } |
| 134 | 135 |
| 136 void ShowModalDialog(gfx::NativeWindow dialog, | |
| 137 content::WebContents* initiator_web_contents) { | |
| 138 web_modal::WebContentsModalDialogManager* manager = | |
| 139 web_modal::WebContentsModalDialogManager::FromWebContents( | |
| 140 initiator_web_contents); | |
| 141 std::unique_ptr<web_modal::SingleWebContentsDialogManager> dialog_manager( | |
| 142 web_modal::WebContentsModalDialogManager::CreateNativeWebModalManager( | |
|
tapted
2016/06/29 03:02:45
Can this just call NativeWebContentsModalDialogMan
Patti Lor
2016/07/13 03:09:41
I don't think so - there are 4 separate implementa
tapted
2016/07/13 04:36:19
The notreached ones shouldn't matter (I think they
Patti Lor
2016/07/19 07:39:08
Done (including deleting the other implementations
| |
| 143 dialog, manager)); | |
| 144 manager->ShowDialogWithManager(dialog, std::move(dialog_manager)); | |
| 145 } | |
| 146 | |
| 135 views::Widget* ShowWebModalDialogViews( | 147 views::Widget* ShowWebModalDialogViews( |
| 136 views::WidgetDelegate* dialog, | 148 views::WidgetDelegate* dialog, |
| 137 content::WebContents* initiator_web_contents) { | 149 content::WebContents* initiator_web_contents) { |
| 138 DCHECK(constrained_window_views_client); | 150 DCHECK(constrained_window_views_client); |
| 139 // For embedded WebContents, use the embedder's WebContents for constrained | 151 // For embedded WebContents, use the embedder's WebContents for constrained |
| 140 // window. | 152 // window. |
| 141 content::WebContents* web_contents = | 153 content::WebContents* web_contents = |
| 142 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 154 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
| 143 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 155 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
| 144 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 156 ShowModalDialog(widget->GetNativeWindow(), initiator_web_contents); |
| 145 ->ShowModalDialog(widget->GetNativeWindow()); | |
| 146 return widget; | 157 return widget; |
| 147 } | 158 } |
| 148 | 159 |
| 149 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, | 160 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, |
| 150 content::WebContents* web_contents) { | 161 content::WebContents* web_contents) { |
| 151 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); | 162 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); |
| 152 return views::DialogDelegate::CreateDialogWidget( | 163 return views::DialogDelegate::CreateDialogWidget( |
| 153 dialog, nullptr, | 164 dialog, nullptr, |
| 154 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 165 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) |
| 155 ->delegate() | 166 ->delegate() |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 186 DCHECK_EQ(parent_view, host->GetHostView()); | 197 DCHECK_EQ(parent_view, host->GetHostView()); |
| 187 ModalDialogHostObserver* dialog_host_observer = | 198 ModalDialogHostObserver* dialog_host_observer = |
| 188 new WidgetModalDialogHostObserverViews( | 199 new WidgetModalDialogHostObserverViews( |
| 189 host, widget, kWidgetModalDialogHostObserverViewsKey); | 200 host, widget, kWidgetModalDialogHostObserverViewsKey); |
| 190 dialog_host_observer->OnPositionRequiresUpdate(); | 201 dialog_host_observer->OnPositionRequiresUpdate(); |
| 191 } | 202 } |
| 192 return widget; | 203 return widget; |
| 193 } | 204 } |
| 194 | 205 |
| 195 } // namespace constrained window | 206 } // namespace constrained window |
| OLD | NEW |