Chromium Code Reviews| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 size.SetToMin(max_size); | 138 size.SetToMin(max_size); |
| 139 UpdateModalDialogPosition(widget, dialog_host, size); | 139 UpdateModalDialogPosition(widget, dialog_host, size); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void UpdateWidgetModalDialogPosition(views::Widget* widget, | 142 void UpdateWidgetModalDialogPosition(views::Widget* widget, |
| 143 web_modal::ModalDialogHost* dialog_host) { | 143 web_modal::ModalDialogHost* dialog_host) { |
| 144 UpdateModalDialogPosition(widget, dialog_host, | 144 UpdateModalDialogPosition(widget, dialog_host, |
| 145 widget->GetRootView()->GetPreferredSize()); | 145 widget->GetRootView()->GetPreferredSize()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 content::WebContents* GetTopLevelWebContents( | |
|
msw
2016/09/22 13:36:19
nit: maybe just skip the helper and inline calls t
wjmaclean
2016/09/22 15:36:48
Wouldn't that mean that the guestview interface wo
imcheng
2016/09/22 17:20:58
Yeah, I did it this way so I don't have to include
msw
2016/09/22 20:45:17
Ah, then this is fine, thanks.
| |
| 149 content::WebContents* initiator_web_contents) { | |
| 150 return guest_view::GuestViewBase::GetTopLevelWebContents( | |
| 151 initiator_web_contents); | |
| 152 } | |
| 153 | |
| 148 views::Widget* ShowWebModalDialogViews( | 154 views::Widget* ShowWebModalDialogViews( |
| 149 views::WidgetDelegate* dialog, | 155 views::WidgetDelegate* dialog, |
| 150 content::WebContents* initiator_web_contents) { | 156 content::WebContents* initiator_web_contents) { |
| 151 DCHECK(constrained_window_views_client); | 157 DCHECK(constrained_window_views_client); |
| 152 // For embedded WebContents, use the embedder's WebContents for constrained | 158 // For embedded WebContents, use the embedder's WebContents for constrained |
| 153 // window. | 159 // window. |
| 154 content::WebContents* web_contents = | 160 content::WebContents* web_contents = |
| 155 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 161 GetTopLevelWebContents(initiator_web_contents); |
| 156 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 162 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
| 157 ShowModalDialog(widget->GetNativeWindow(), web_contents); | 163 ShowModalDialog(widget->GetNativeWindow(), web_contents); |
| 158 return widget; | 164 return widget; |
| 159 } | 165 } |
| 160 | 166 |
| 161 #if defined(OS_MACOSX) | 167 #if defined(OS_MACOSX) |
| 162 views::Widget* ShowWebModalDialogWithOverlayViews( | 168 views::Widget* ShowWebModalDialogWithOverlayViews( |
| 163 views::WidgetDelegate* dialog, | 169 views::WidgetDelegate* dialog, |
| 164 content::WebContents* initiator_web_contents) { | 170 content::WebContents* initiator_web_contents) { |
| 165 DCHECK(constrained_window_views_client); | 171 DCHECK(constrained_window_views_client); |
| 166 // For embedded WebContents, use the embedder's WebContents for constrained | 172 // For embedded WebContents, use the embedder's WebContents for constrained |
| 167 // window. | 173 // window. |
| 168 content::WebContents* web_contents = | 174 content::WebContents* web_contents = |
| 169 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents); | 175 GetTopLevelWebContents(initiator_web_contents); |
| 170 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); | 176 views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents); |
| 171 web_modal::WebContentsModalDialogManager* manager = | 177 web_modal::WebContentsModalDialogManager* manager = |
| 172 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 178 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| 173 std::unique_ptr<web_modal::SingleWebContentsDialogManager> dialog_manager( | 179 std::unique_ptr<web_modal::SingleWebContentsDialogManager> dialog_manager( |
| 174 new NativeWebContentsModalDialogManagerViewsMac(widget->GetNativeWindow(), | 180 new NativeWebContentsModalDialogManagerViewsMac(widget->GetNativeWindow(), |
| 175 manager)); | 181 manager)); |
| 176 manager->ShowDialogWithManager(widget->GetNativeWindow(), | 182 manager->ShowDialogWithManager(widget->GetNativeWindow(), |
| 177 std::move(dialog_manager)); | 183 std::move(dialog_manager)); |
| 178 return widget; | 184 return widget; |
| 179 } | 185 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 DCHECK_EQ(parent_view, host->GetHostView()); | 225 DCHECK_EQ(parent_view, host->GetHostView()); |
| 220 ModalDialogHostObserver* dialog_host_observer = | 226 ModalDialogHostObserver* dialog_host_observer = |
| 221 new WidgetModalDialogHostObserverViews( | 227 new WidgetModalDialogHostObserverViews( |
| 222 host, widget, kWidgetModalDialogHostObserverViewsKey); | 228 host, widget, kWidgetModalDialogHostObserverViewsKey); |
| 223 dialog_host_observer->OnPositionRequiresUpdate(); | 229 dialog_host_observer->OnPositionRequiresUpdate(); |
| 224 } | 230 } |
| 225 return widget; | 231 return widget; |
| 226 } | 232 } |
| 227 | 233 |
| 228 } // namespace constrained window | 234 } // namespace constrained window |
| OLD | NEW |