Index: chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
diff --git a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
index 1f6302730572dbd5ca30c14391fd545ce5d555f0..2c61272b2b9405475dae2c2f84854c95f9d26158 100644 |
--- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
+++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
@@ -80,11 +80,15 @@ class WebDialogWebContentsDelegateViews |
// Sets WebView's preferred size based on auto-resized contents. |
web_view_->SetPreferredSize(preferred_size); |
+ content::WebContents* top_level_web_contents = |
msw
2016/09/22 03:27:35
It seems odd to present a dialog from an embedded
imcheng
2016/09/22 04:32:23
Indeed, we currently allow embedded <webview> to c
msw
2016/09/22 13:36:19
Thanks for the info, this probably doesn't need se
imcheng
2016/09/22 17:20:58
Acknowledged.
|
+ constrained_window::GetTopLevelWebContents( |
+ initiator_observer_->web_contents()); |
constrained_window::UpdateWebContentsModalDialogPosition( |
web_view_->GetWidget(), |
web_modal::WebContentsModalDialogManager::FromWebContents( |
- initiator_observer_->web_contents())->delegate()-> |
- GetWebContentsModalDialogHost()); |
+ top_level_web_contents) |
msw
2016/09/22 13:36:19
Check for null before using |top_level_web_content
wjmaclean
2016/09/22 15:36:48
Definitely check for null ... there's no guarantee
imcheng
2016/09/22 17:20:57
Done. Although I did notice that constrained_windo
|
+ ->delegate() |
+ ->GetWebContentsModalDialogHost()); |
} |
private: |
@@ -238,8 +242,10 @@ class ConstrainedWebDialogDelegateViewViews |
} |
void DocumentOnLoadCompletedInMainFrame() override { |
if (!max_size_.IsEmpty() && initiator_observer_.web_contents()) { |
- constrained_window::ShowModalDialog(GetWidget()->GetNativeWindow(), |
- initiator_observer_.web_contents()); |
+ constrained_window::ShowModalDialog( |
+ GetWidget()->GetNativeWindow(), |
+ constrained_window::GetTopLevelWebContents( |
msw
2016/09/22 13:36:19
Ditto, check for null first?
imcheng
2016/09/22 17:20:57
Done.
|
+ initiator_observer_.web_contents())); |
} |
} |
@@ -287,6 +293,10 @@ ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize( |
new ConstrainedWebDialogDelegateViewViews( |
browser_context, delegate, web_contents, |
min_size, max_size); |
- constrained_window::CreateWebModalDialogViews(dialog, web_contents); |
+ // For embedded WebContents, use the embedder's WebContents for constrained |
+ // window. |
+ content::WebContents* top_level_web_contents = |
+ constrained_window::GetTopLevelWebContents(web_contents); |
+ constrained_window::CreateWebModalDialogViews(dialog, top_level_web_contents); |
msw
2016/09/22 13:36:19
nit: maybe DCHECK that |top_level_web_contents| is
imcheng
2016/09/22 17:20:57
Done.
|
return dialog; |
} |