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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 ->delegate() | 194 ->delegate() |
195 ->GetWebContentsModalDialogHost() | 195 ->GetWebContentsModalDialogHost() |
196 ->GetHostView()); | 196 ->GetHostView()); |
197 } | 197 } |
198 | 198 |
199 views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog, | 199 views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog, |
200 gfx::NativeWindow parent) { | 200 gfx::NativeWindow parent) { |
201 DCHECK_NE(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); | 201 DCHECK_NE(ui::MODAL_TYPE_CHILD, dialog->GetModalType()); |
202 DCHECK_NE(ui::MODAL_TYPE_NONE, dialog->GetModalType()); | 202 DCHECK_NE(ui::MODAL_TYPE_NONE, dialog->GetModalType()); |
203 | 203 |
204 DCHECK(constrained_window_views_client); | 204 if (parent) |
205 DCHECK(constrained_window_views_client); | |
msw
2016/10/27 21:46:45
Double checking that this works okay (ie. DCHECK r
Evan Stade
2016/10/28 17:31:55
yes, it works. If it didn't, wouldn't the release
| |
205 gfx::NativeView parent_view = | 206 gfx::NativeView parent_view = |
206 parent ? constrained_window_views_client->GetDialogHostView(parent) | 207 parent ? constrained_window_views_client->GetDialogHostView(parent) |
207 : nullptr; | 208 : nullptr; |
208 views::Widget* widget = | 209 views::Widget* widget = |
209 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent_view); | 210 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent_view); |
210 | 211 |
211 bool requires_positioning = dialog->ShouldUseCustomFrame(); | 212 bool requires_positioning = dialog->ShouldUseCustomFrame(); |
212 | 213 |
213 #if defined(OS_MACOSX) | 214 #if defined(OS_MACOSX) |
214 // On Mac, window modal dialogs are displayed as sheets, so their position is | 215 // On Mac, window modal dialogs are displayed as sheets, so their position is |
215 // managed by the parent window. | 216 // managed by the parent window. |
216 requires_positioning = false; | 217 requires_positioning = false; |
217 #endif | 218 #endif |
218 | 219 |
219 if (!requires_positioning) | 220 if (!requires_positioning) |
220 return widget; | 221 return widget; |
221 | 222 |
222 ModalDialogHost* host = constrained_window_views_client-> | 223 ModalDialogHost* host = |
223 GetModalDialogHost(parent); | 224 parent ? constrained_window_views_client->GetModalDialogHost(parent) |
225 : nullptr; | |
224 if (host) { | 226 if (host) { |
225 DCHECK_EQ(parent_view, host->GetHostView()); | 227 DCHECK_EQ(parent_view, host->GetHostView()); |
226 ModalDialogHostObserver* dialog_host_observer = | 228 ModalDialogHostObserver* dialog_host_observer = |
227 new WidgetModalDialogHostObserverViews( | 229 new WidgetModalDialogHostObserverViews( |
228 host, widget, kWidgetModalDialogHostObserverViewsKey); | 230 host, widget, kWidgetModalDialogHostObserverViewsKey); |
229 dialog_host_observer->OnPositionRequiresUpdate(); | 231 dialog_host_observer->OnPositionRequiresUpdate(); |
230 } | 232 } |
231 return widget; | 233 return widget; |
232 } | 234 } |
233 | 235 |
234 } // namespace constrained window | 236 } // namespace constrained window |
OLD | NEW |