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/guest_view/browser/guest_view_base.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 size.SetToMin(max_size); | 122 size.SetToMin(max_size); |
123 UpdateModalDialogPosition(widget, dialog_host, size); | 123 UpdateModalDialogPosition(widget, dialog_host, size); |
124 } | 124 } |
125 | 125 |
126 void UpdateWidgetModalDialogPosition(views::Widget* widget, | 126 void UpdateWidgetModalDialogPosition(views::Widget* widget, |
127 web_modal::ModalDialogHost* dialog_host) { | 127 web_modal::ModalDialogHost* dialog_host) { |
128 UpdateModalDialogPosition(widget, dialog_host, | 128 UpdateModalDialogPosition(widget, dialog_host, |
129 widget->GetRootView()->GetPreferredSize()); | 129 widget->GetRootView()->GetPreferredSize()); |
130 } | 130 } |
131 | 131 |
| 132 web_modal::PopupManager* PopupManager(content::WebContents* web_contents) { |
| 133 // For embedded WebContents, use the embedder's WebContents for constrained |
| 134 // window. |
| 135 content::WebContents* top_level_web_contents = |
| 136 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); |
| 137 return web_modal::PopupManager::FromWebContents(top_level_web_contents); |
| 138 } |
| 139 |
132 views::Widget* ShowWebModalDialogViews( | 140 views::Widget* ShowWebModalDialogViews( |
133 views::WidgetDelegate* dialog, | 141 views::WidgetDelegate* dialog, |
134 content::WebContents* initiator_web_contents) { | 142 content::WebContents* initiator_web_contents) { |
135 DCHECK(constrained_window_views_client); | 143 DCHECK(constrained_window_views_client); |
136 // For embedded WebContents, use the embedder's WebContents for constrained | 144 // For embedded WebContents, use the embedder's WebContents for constrained |
137 // window. | 145 // window. |
138 content::WebContents* web_contents = | 146 content::WebContents* web_contents = |
139 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 147 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
140 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 148 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
141 web_modal::PopupManager* popup_manager = | 149 web_modal::PopupManager* popup_manager = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 DCHECK_EQ(parent_view, host->GetHostView()); | 181 DCHECK_EQ(parent_view, host->GetHostView()); |
174 ModalDialogHostObserver* dialog_host_observer = | 182 ModalDialogHostObserver* dialog_host_observer = |
175 new WidgetModalDialogHostObserverViews( | 183 new WidgetModalDialogHostObserverViews( |
176 host, widget, kWidgetModalDialogHostObserverViewsKey); | 184 host, widget, kWidgetModalDialogHostObserverViewsKey); |
177 dialog_host_observer->OnPositionRequiresUpdate(); | 185 dialog_host_observer->OnPositionRequiresUpdate(); |
178 } | 186 } |
179 return widget; | 187 return widget; |
180 } | 188 } |
181 | 189 |
182 } // namespace constrained window | 190 } // namespace constrained window |
OLD | NEW |