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

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

Issue 2172363002: Created min size for print preview dialog and modified to allow the Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to CrOS only. Created 4 years, 4 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
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..1de78cffe2ec418367859781fde2513a2383cfe4 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,23 @@
#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)
+ 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 +148,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 independent_bounds)
: 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),
+ independent_bounds_(independent_bounds) {
SetWebContents(GetWebContents());
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
if (!max_size_.IsEmpty())
@@ -238,9 +245,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 (GetIndependentBounds()) {
+ web_modal::WebContentsModalDialogManager::FromWebContents(
+ initiator_observer_.web_contents())
+ ->ShowNonClippedModalDialog(GetWidget()->GetNativeWindow());
+ } else {
+ web_modal::WebContentsModalDialogManager::FromWebContents(
+ initiator_observer_.web_contents())
+ ->ShowModalDialog(GetWidget()->GetNativeWindow());
+ }
}
}
@@ -251,6 +264,8 @@ class ConstrainedWebDialogDelegateViewViews
render_view_host->EnableAutoResize(min_size_, max_size_);
}
+ bool GetIndependentBounds() { return independent_bounds_; }
+
InitiatorWebContentsObserver initiator_observer_;
std::unique_ptr<ConstrainedWebDialogDelegateViews> impl_;
@@ -259,6 +274,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
+ bool independent_bounds_;
+
DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewViews);
};
@@ -269,13 +288,32 @@ 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* ShowTopLevelConstrainedWebDialog(
+ content::BrowserContext* browser_context,
+ ui::WebDialogDelegate* delegate,
+ content::WebContents* web_contents) {
+// This doesn't work on Linux desktop or windows classic themes and is not
+// needed on MAC since Mac uses sheets.
+// Eventually, should try to enable this for other Windows.
Mike Wittman 2016/08/12 22:51:34 ... other *platforms*?
rbpotter 2016/08/15 18:03:45 Done.
+#if !defined(OS_CHROMEOS)
rbpotter 2016/08/10 00:42:31 When testing on Windows, dialogs still get cut off
+ return ShowConstrainedWebDialog(browser_context, delegate, web_contents);
+#endif
+
+ 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 +324,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;
}

Powered by Google App Engine
This is Rietveld 408576698