Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc

Issue 2357243003: [UI] Make auto-resizable constrained web dialog work even when initiated (Closed)
Patch Set: Addressed comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/constrained_window/constrained_window_views.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4393ced2643006354ac1e173f10c69878ae993fa 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,17 @@ class WebDialogWebContentsDelegateViews
// Sets WebView's preferred size based on auto-resized contents.
web_view_->SetPreferredSize(preferred_size);
- constrained_window::UpdateWebContentsModalDialogPosition(
- web_view_->GetWidget(),
- web_modal::WebContentsModalDialogManager::FromWebContents(
- initiator_observer_->web_contents())->delegate()->
- GetWebContentsModalDialogHost());
+ content::WebContents* top_level_web_contents =
+ constrained_window::GetTopLevelWebContents(
+ initiator_observer_->web_contents());
+ if (top_level_web_contents) {
+ constrained_window::UpdateWebContentsModalDialogPosition(
+ web_view_->GetWidget(),
+ web_modal::WebContentsModalDialogManager::FromWebContents(
+ top_level_web_contents)
+ ->delegate()
+ ->GetWebContentsModalDialogHost());
+ }
}
private:
@@ -238,8 +244,13 @@ class ConstrainedWebDialogDelegateViewViews
}
void DocumentOnLoadCompletedInMainFrame() override {
if (!max_size_.IsEmpty() && initiator_observer_.web_contents()) {
- constrained_window::ShowModalDialog(GetWidget()->GetNativeWindow(),
- initiator_observer_.web_contents());
+ content::WebContents* top_level_web_contents =
+ constrained_window::GetTopLevelWebContents(
+ initiator_observer_.web_contents());
+ if (top_level_web_contents) {
+ constrained_window::ShowModalDialog(GetWidget()->GetNativeWindow(),
+ top_level_web_contents);
+ }
}
}
@@ -287,6 +298,12 @@ 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);
+ DCHECK(top_level_web_contents);
+ constrained_window::CreateWebModalDialogViews(dialog, top_level_web_contents);
return dialog;
}
« no previous file with comments | « no previous file | components/constrained_window/constrained_window_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698