summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui
diff options
context:
space:
mode:
authorapacible <apacible@chromium.org>2016-03-09 22:10:36 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-10 06:12:01 +0000
commit740c4109f954a11c544c02132a89fabab767e7ab (patch)
treeac48e487732a25ea45a9ddf785a661f9b749cf9e /chrome/browser/ui/webui
parent57b0ce21651317b36f6c5cd0888a011e71f2ace8 (diff)
downloadchromium_src-740c4109f954a11c544c02132a89fabab767e7ab.zip
chromium_src-740c4109f954a11c544c02132a89fabab767e7ab.tar.gz
chromium_src-740c4109f954a11c544c02132a89fabab767e7ab.tar.bz2
[Reland] Enable AutoResize for Constrained Web Dialogs for Mac.
Currently only constrained web dialogs for views (Linux/Windows) are able to autoresize. This change implements the option to pass in minimum and maximum sizes and enabling autoresizing functionality for OSX. This change adds two static functions for options on whether to create a ConstrainedWindowsMac that autoresizes or is of fixed size. The first two patches were reverted because of flaky tests on Mac 10.9. Those patches can be found at: 1. https://codereview.chromium.org/1430023002 2. https://codereview.chromium.org/1446623003 After some investigation, we found that the failures are being caused by an occlusion notifications in cocoa, which is not expected in browser tests. This is currently mac-only. By disabling these notifications in browser tests, we see this patch passing on the swarming bots that were previously failing. See http://crbug/558585. The patch to disable occlusion notifications can be found at: https://codereview.chromium.org/1762883002/ The third patch (same as second patch) broke dialogs like print preview. This was because the change used ui::kWindowSizeDeterminedLater for the dialog window's frame for all constrained web dialogs on mac, not just autoresizable dialogs. That has been amended in this change. That patch can be found here: https://codereview.chromium.org/1699763002/ BUG=217034 Review URL: https://codereview.chromium.org/1781433002 Cr-Commit-Position: refs/heads/master@{#380352}
Diffstat (limited to 'chrome/browser/ui/webui')
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc5
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h5
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_ui.h2
-rw-r--r--chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc13
4 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
index fd60a4b..db4c547 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
@@ -113,3 +113,8 @@ gfx::Size ConstrainedWebDialogDelegateBase::GetPreferredSize() const {
NOTREACHED();
return gfx::Size();
}
+
+void ConstrainedWebDialogDelegateBase::ResizeToGivenSize(
+ const gfx::Size size) {
+ NOTREACHED();
+}
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
index fee4931..a43814a 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
@@ -24,6 +24,8 @@ class ConstrainedWebDialogDelegateBase
: public ConstrainedWebDialogDelegate,
public ui::WebDialogWebContentsDelegate {
public:
+ // |browser_context| and |delegate| must outlive |this| instance, whereas
+ // |this| will take ownership of |tab_delegate|.
ConstrainedWebDialogDelegateBase(content::BrowserContext* browser_context,
ui::WebDialogDelegate* delegate,
WebDialogWebContentsDelegate* tab_delegate);
@@ -47,6 +49,9 @@ class ConstrainedWebDialogDelegateBase
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
+ // Resize the dialog to the given size.
+ virtual void ResizeToGivenSize(const gfx::Size size);
+
private:
scoped_ptr<ui::WebDialogDelegate> web_dialog_delegate_;
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui.h b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
index 4f7159e..39cc74b 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
@@ -51,6 +51,8 @@ class ConstrainedWebDialogDelegate {
// Returns the maximum size for the dialog.
virtual gfx::Size GetMaximumSize() const = 0;
+ // Returns the preferred size for the dialog, or an empty size if
+ // the dialog has been closed.
virtual gfx::Size GetPreferredSize() const = 0;
protected:
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
index fbdf04f..c3c0f36 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
@@ -26,7 +26,6 @@ using web_modal::WebContentsModalDialogManager;
namespace {
-#if !defined(OS_MACOSX)
static const char kTestDataURL[] = "data:text/html,<!doctype html>"
"<body></body>"
"<style>"
@@ -42,7 +41,6 @@ std::string GetChangeDimensionsScript(int dimension) {
return base::StringPrintf("window.document.body.style.width = %d + 'px';"
"window.document.body.style.height = %d + 'px';", dimension, dimension);
}
-#endif
class ConstrainedWebDialogBrowserTestObserver
: public content::WebContentsObserver {
@@ -147,7 +145,6 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
EXPECT_TRUE(observer.contents_destroyed());
}
-#if !defined(OS_MACOSX)
// Tests that dialog autoresizes based on web contents when autoresizing
// is enabled.
IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
@@ -173,6 +170,13 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
gfx::Size min_size = gfx::Size(100, 100);
gfx::Size max_size = gfx::Size(200, 200);
gfx::Size initial_dialog_size;
+
+ // OSX windows must be initially created with non-empty dimensions. The
+ // autoresizeable dialog's window dimensions are determined after initial
+ // creation.
+#if defined(OS_MACOSX)
+ initial_dialog_size = gfx::Size(1, 1);
+#endif
delegate->GetDialogSize(&initial_dialog_size);
ConstrainedWebDialogDelegate* dialog_delegate =
@@ -186,7 +190,6 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
EXPECT_EQ(max_size, dialog_delegate->GetMaximumSize());
// Check for initial sizing. Dialog was created as a 400x400 dialog.
- EXPECT_EQ(gfx::Size(), web_contents->GetPreferredSize());
ASSERT_EQ(initial_dialog_size, dialog_delegate->GetPreferredSize());
observer.Wait();
@@ -250,7 +253,6 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
delegate->GetDialogSize(&initial_dialog_size);
// Check for initial sizing. Dialog was created as a 400x400 dialog.
- EXPECT_EQ(gfx::Size(), web_contents->GetPreferredSize());
ASSERT_EQ(initial_dialog_size, dialog_delegate->GetPreferredSize());
// Resize <body> to dimension smaller than dialog.
@@ -269,4 +271,3 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
initial_dialog_size,
dialog_delegate)));
}
-#endif // !OS_MACOSX