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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 views::Widget* ShowWebModalDialogViews( | 136 views::Widget* ShowWebModalDialogViews( |
136 views::WidgetDelegate* dialog, | 137 views::WidgetDelegate* dialog, |
137 content::WebContents* initiator_web_contents) { | 138 content::WebContents* initiator_web_contents) { |
138 DCHECK(constrained_window_views_client); | 139 DCHECK(constrained_window_views_client); |
139 // For embedded WebContents, use the embedder's WebContents for constrained | 140 // For embedded WebContents, use the embedder's WebContents for constrained |
140 // window. | 141 // window. |
141 content::WebContents* web_contents = | 142 content::WebContents* web_contents = |
142 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 143 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
143 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 144 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
144 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 145 ShowModalDialog(widget->GetNativeWindow(), initiator_web_contents); |
145 ->ShowModalDialog(widget->GetNativeWindow()); | |
146 return widget; | 146 return widget; |
147 } | 147 } |
148 | 148 |
149 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, | 149 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, |
150 content::WebContents* web_contents) { | 150 content::WebContents* web_contents) { |
151 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); | 151 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); |
152 return views::DialogDelegate::CreateDialogWidget( | 152 return views::DialogDelegate::CreateDialogWidget( |
153 dialog, nullptr, | 153 dialog, nullptr, |
154 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 154 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) |
155 ->delegate() | 155 ->delegate() |
(...skipping 30 matching lines...) Expand all Loading... |
186 DCHECK_EQ(parent_view, host->GetHostView()); | 186 DCHECK_EQ(parent_view, host->GetHostView()); |
187 ModalDialogHostObserver* dialog_host_observer = | 187 ModalDialogHostObserver* dialog_host_observer = |
188 new WidgetModalDialogHostObserverViews( | 188 new WidgetModalDialogHostObserverViews( |
189 host, widget, kWidgetModalDialogHostObserverViewsKey); | 189 host, widget, kWidgetModalDialogHostObserverViewsKey); |
190 dialog_host_observer->OnPositionRequiresUpdate(); | 190 dialog_host_observer->OnPositionRequiresUpdate(); |
191 } | 191 } |
192 return widget; | 192 return widget; |
193 } | 193 } |
194 | 194 |
195 } // namespace constrained window | 195 } // namespace constrained window |
OLD | NEW |