Chromium Code Reviews| 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 de8ef012e172b6ff4c8387c266011bfab0f08ab4..b5e6b997cb1e09582491baef546a9137364ac126 100644 |
| --- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| +++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| @@ -23,19 +23,22 @@ |
| #include "ui/web_dialogs/web_dialog_delegate.h" |
| #include "ui/web_dialogs/web_dialog_ui.h" |
| +#if defined(OS_WIN) |
| +#include "ui/base/win/shell.h" |
| +#endif |
| + |
| namespace { |
| // WebContentsObserver that tracks the lifetime of the WebContents to avoid |
| // potential use after destruction. |
| class InitiatorWebContentsObserver |
| : public content::WebContentsObserver { |
| - public: |
| - explicit InitiatorWebContentsObserver(content::WebContents* web_contents) |
| - : content::WebContentsObserver(web_contents) { |
| - } |
| + public: |
| + explicit InitiatorWebContentsObserver(content::WebContents* web_contents) |
| + : content::WebContentsObserver(web_contents) {} |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(InitiatorWebContentsObserver); |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(InitiatorWebContentsObserver); |
| }; |
| class WebDialogWebContentsDelegateViews |
| @@ -144,14 +147,17 @@ class ConstrainedWebDialogDelegateViewViews |
| ui::WebDialogDelegate* delegate, |
| content::WebContents* web_contents, |
| const gfx::Size& min_size, |
| - const gfx::Size& max_size) |
| + const gfx::Size& max_size, |
| + bool is_nonclipped) |
| : views::WebView(browser_context), |
| initiator_observer_(web_contents), |
| - impl_(new ConstrainedWebDialogDelegateViews(browser_context, delegate, |
| + impl_(new ConstrainedWebDialogDelegateViews(browser_context, |
| + delegate, |
| &initiator_observer_, |
| this)), |
| min_size_(min_size), |
| - max_size_(max_size) { |
| + max_size_(max_size), |
| + is_nonclipped_(is_nonclipped) { |
| SetWebContents(GetWebContents()); |
| AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| if (!max_size_.IsEmpty()) |
| @@ -238,9 +244,15 @@ class ConstrainedWebDialogDelegateViewViews |
| } |
| void DocumentOnLoadCompletedInMainFrame() override { |
| if (!max_size_.IsEmpty() && initiator_observer_.web_contents()) { |
| - web_modal::WebContentsModalDialogManager::FromWebContents( |
| - initiator_observer_.web_contents()) |
| - ->ShowModalDialog(GetWidget()->GetNativeWindow()); |
| + if (is_nonclipped_) { |
| + web_modal::WebContentsModalDialogManager::FromWebContents( |
|
Lei Zhang
2016/08/18 20:30:57
Combine the same code in the if and else branch fo
rbpotter
2016/08/19 01:59:09
Non applicable at this point, this code was refact
|
| + initiator_observer_.web_contents()) |
| + ->ShowNonClippedModalDialog(GetWidget()->GetNativeWindow()); |
| + } else { |
| + web_modal::WebContentsModalDialogManager::FromWebContents( |
| + initiator_observer_.web_contents()) |
| + ->ShowModalDialog(GetWidget()->GetNativeWindow()); |
| + } |
| } |
| } |
| @@ -259,6 +271,10 @@ class ConstrainedWebDialogDelegateViewViews |
| const gfx::Size min_size_; |
| const gfx::Size max_size_; |
| + // If true, dialog has bounds that are not constrained by the parent window's |
| + // bounds, so can extend outside of the parent window when resized |
|
Lei Zhang
2016/08/18 20:30:57
s/so/so it/
rbpotter
2016/08/19 01:59:09
Done.
|
| + const bool is_nonclipped_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewViews); |
| }; |
| @@ -269,13 +285,25 @@ ConstrainedWebDialogDelegate* ShowConstrainedWebDialog( |
| ui::WebDialogDelegate* delegate, |
| content::WebContents* web_contents) { |
| ConstrainedWebDialogDelegateViewViews* dialog = |
| - new ConstrainedWebDialogDelegateViewViews( |
| - browser_context, delegate, web_contents, |
| - gfx::Size(), gfx::Size()); |
| + new ConstrainedWebDialogDelegateViewViews(browser_context, delegate, |
| + web_contents, gfx::Size(), |
| + gfx::Size(), false); |
| constrained_window::ShowWebModalDialogViews(dialog, web_contents); |
| return dialog; |
| } |
| +ConstrainedWebDialogDelegate* ShowNonClippedConstrainedWebDialog( |
| + content::BrowserContext* browser_context, |
| + ui::WebDialogDelegate* delegate, |
| + content::WebContents* web_contents) { |
| + ConstrainedWebDialogDelegateViewViews* dialog = |
| + new ConstrainedWebDialogDelegateViewViews(browser_context, delegate, |
| + web_contents, gfx::Size(), |
| + gfx::Size(), true); |
| + constrained_window::ShowNonClippedWebModalDialogViews(dialog, web_contents); |
| + return dialog; |
| +} |
| + |
| ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize( |
| content::BrowserContext* browser_context, |
| ui::WebDialogDelegate* delegate, |
| @@ -286,8 +314,7 @@ ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize( |
| DCHECK(!max_size.IsEmpty()); |
| ConstrainedWebDialogDelegateViewViews* dialog = |
| new ConstrainedWebDialogDelegateViewViews( |
| - browser_context, delegate, web_contents, |
| - min_size, max_size); |
| + browser_context, delegate, web_contents, min_size, max_size, false); |
| constrained_window::CreateWebModalDialogViews(dialog, web_contents); |
| return dialog; |
| } |