| 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 "components/constrained_window/constrained_window_views_client.h" | 9 #include "components/constrained_window/constrained_window_views_client.h" |
| 10 #include "components/guest_view/browser/guest_view_base.h" |
| 10 #include "components/web_modal/popup_manager.h" | 11 #include "components/web_modal/popup_manager.h" |
| 11 #include "components/web_modal/web_contents_modal_dialog_host.h" | 12 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 12 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
| 13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 14 #include "ui/views/widget/widget_observer.h" | 15 #include "ui/views/widget/widget_observer.h" |
| 15 #include "ui/views/window/dialog_delegate.h" | 16 #include "ui/views/window/dialog_delegate.h" |
| 16 | 17 |
| 17 using web_modal::ModalDialogHost; | 18 using web_modal::ModalDialogHost; |
| 18 using web_modal::ModalDialogHostObserver; | 19 using web_modal::ModalDialogHostObserver; |
| 19 | 20 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 UpdateModalDialogPosition(widget, dialog_host, | 128 UpdateModalDialogPosition(widget, dialog_host, |
| 128 widget->GetRootView()->GetPreferredSize()); | 129 widget->GetRootView()->GetPreferredSize()); |
| 129 } | 130 } |
| 130 | 131 |
| 131 views::Widget* ShowWebModalDialogViews( | 132 views::Widget* ShowWebModalDialogViews( |
| 132 views::WidgetDelegate* dialog, | 133 views::WidgetDelegate* dialog, |
| 133 content::WebContents* initiator_web_contents) { | 134 content::WebContents* initiator_web_contents) { |
| 134 DCHECK(constrained_window_views_client); | 135 DCHECK(constrained_window_views_client); |
| 135 // For embedded WebContents, use the embedder's WebContents for constrained | 136 // For embedded WebContents, use the embedder's WebContents for constrained |
| 136 // window. | 137 // window. |
| 137 content::WebContents* web_contents = constrained_window_views_client-> | 138 content::WebContents* web_contents = |
| 138 GetEmbedderWebContents(initiator_web_contents); | 139 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
| 139 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 140 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
| 140 web_modal::PopupManager* popup_manager = | 141 web_modal::PopupManager* popup_manager = |
| 141 web_modal::PopupManager::FromWebContents(web_contents); | 142 web_modal::PopupManager::FromWebContents(web_contents); |
| 142 popup_manager->ShowModalDialog(widget->GetNativeWindow(), web_contents); | 143 popup_manager->ShowModalDialog(widget->GetNativeWindow(), web_contents); |
| 143 return widget; | 144 return widget; |
| 144 } | 145 } |
| 145 | 146 |
| 146 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, | 147 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, |
| 147 content::WebContents* web_contents) { | 148 content::WebContents* web_contents) { |
| 148 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); | 149 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 172 DCHECK_EQ(parent_view, host->GetHostView()); | 173 DCHECK_EQ(parent_view, host->GetHostView()); |
| 173 ModalDialogHostObserver* dialog_host_observer = | 174 ModalDialogHostObserver* dialog_host_observer = |
| 174 new WidgetModalDialogHostObserverViews( | 175 new WidgetModalDialogHostObserverViews( |
| 175 host, widget, kWidgetModalDialogHostObserverViewsKey); | 176 host, widget, kWidgetModalDialogHostObserverViewsKey); |
| 176 dialog_host_observer->OnPositionRequiresUpdate(); | 177 dialog_host_observer->OnPositionRequiresUpdate(); |
| 177 } | 178 } |
| 178 return widget; | 179 return widget; |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace constrained window | 182 } // namespace constrained window |
| OLD | NEW |