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" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 views::Widget* ShowWebModalDialogViews( | 135 views::Widget* ShowWebModalDialogViews( |
136 views::WidgetDelegate* dialog, | 136 views::WidgetDelegate* dialog, |
137 content::WebContents* initiator_web_contents) { | 137 content::WebContents* initiator_web_contents) { |
138 DCHECK(constrained_window_views_client); | 138 DCHECK(constrained_window_views_client); |
139 // For embedded WebContents, use the embedder's WebContents for constrained | 139 // For embedded WebContents, use the embedder's WebContents for constrained |
140 // window. | 140 // window. |
141 content::WebContents* web_contents = | 141 content::WebContents* web_contents = |
142 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 142 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
143 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 143 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
144 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 144 web_modal::WebContentsModalDialogManager* manager = |
145 ->ShowModalDialog(widget->GetNativeWindow()); | 145 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| 146 manager->ShowModalDialog(widget->GetNativeWindow()); |
146 return widget; | 147 return widget; |
147 } | 148 } |
148 | 149 |
| 150 #if defined(OS_MACOSX) |
| 151 views::Widget* ShowWebModalDialogWithOverlayViews( |
| 152 views::WidgetDelegate* dialog, |
| 153 content::WebContents* initiator_web_contents) { |
| 154 DCHECK(constrained_window_views_client); |
| 155 // For embedded WebContents, use the embedder's WebContents for constrained |
| 156 // window. |
| 157 content::WebContents* web_contents = |
| 158 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); |
| 159 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
| 160 web_modal::WebContentsModalDialogManager* manager = |
| 161 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| 162 manager->ShowModalDialogWithOverlay(widget->GetNativeWindow()); |
| 163 return widget; |
| 164 } |
| 165 #endif |
| 166 |
149 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, | 167 views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog, |
150 content::WebContents* web_contents) { | 168 content::WebContents* web_contents) { |
151 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); | 169 DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); |
152 return views::DialogDelegate::CreateDialogWidget( | 170 return views::DialogDelegate::CreateDialogWidget( |
153 dialog, nullptr, | 171 dialog, nullptr, |
154 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) | 172 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents) |
155 ->delegate() | 173 ->delegate() |
156 ->GetWebContentsModalDialogHost() | 174 ->GetWebContentsModalDialogHost() |
157 ->GetHostView()); | 175 ->GetHostView()); |
158 } | 176 } |
(...skipping 27 matching lines...) Expand all Loading... |
186 DCHECK_EQ(parent_view, host->GetHostView()); | 204 DCHECK_EQ(parent_view, host->GetHostView()); |
187 ModalDialogHostObserver* dialog_host_observer = | 205 ModalDialogHostObserver* dialog_host_observer = |
188 new WidgetModalDialogHostObserverViews( | 206 new WidgetModalDialogHostObserverViews( |
189 host, widget, kWidgetModalDialogHostObserverViewsKey); | 207 host, widget, kWidgetModalDialogHostObserverViewsKey); |
190 dialog_host_observer->OnPositionRequiresUpdate(); | 208 dialog_host_observer->OnPositionRequiresUpdate(); |
191 } | 209 } |
192 return widget; | 210 return widget; |
193 } | 211 } |
194 | 212 |
195 } // namespace constrained window | 213 } // namespace constrained window |
OLD | NEW |