Commit 58b349bc authored by oshima@chromium.org's avatar oshima@chromium.org

Use the same factor as on non aura chromeos to decide if popup should be opened as tab.

This fixes ExtensionApiTest.WindowOpenPopupLarge on aura/chromeos
I simply copied factor from chromeos frame as this value will have to be adjusted for new desktop and chromeos frame code will go away.

BUG=103490
TEST=ExtensionApiTest.WindowOpenPopupLarge passes on aura/chromeos


Review URL: http://codereview.chromium.org/8631004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111285 0039d316-1c4b-4281-b951-d872f2087c98
parent 81b2b0ac
......@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/memory/scoped_vector.h"
#include "base/stringprintf.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/ui/browser.h"
......@@ -11,6 +12,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/test/base/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "net/base/mock_host_resolver.h"
// Disabled, http://crbug.com/64899.
......@@ -28,6 +30,9 @@ void WaitForTabsAndPopups(Browser* browser,
int num_tabs,
int num_popups,
int num_panels) {
SCOPED_TRACE(
StringPrintf("WaitForTabsAndPopups tabs:%d, popups:%d, panels:%d",
num_tabs, num_popups, num_panels));
// We start with one tab and one browser already open.
++num_tabs;
size_t num_browsers = static_cast<size_t>(num_popups + num_panels) + 1;
......@@ -39,7 +44,7 @@ void WaitForTabsAndPopups(Browser* browser,
browser->tab_count() == num_tabs)
break;
MessageLoopForUI::current()->RunAllPending();
ui_test_utils::RunAllPendingInMessageLoop();
}
EXPECT_EQ(num_browsers, BrowserList::GetBrowserCount(browser->profile()));
......
......@@ -142,30 +142,39 @@ using base::TimeDelta;
using views::ColumnSet;
using views::GridLayout;
namespace {
// The height of the status bubble.
static const int kStatusBubbleHeight = 20;
const int kStatusBubbleHeight = 20;
// The name of a key to store on the window handle so that other code can
// locate this object using just the handle.
static const char* const kBrowserViewKey = "__BROWSER_VIEW__";
const char* const kBrowserViewKey = "__BROWSER_VIEW__";
// How frequently we check for hung plugin windows.
static const int kDefaultHungPluginDetectFrequency = 2000;
const int kDefaultHungPluginDetectFrequency = 2000;
// Minimal height of devtools pane or content pane when devtools are docked
// to the browser window.
const int kMinDevToolsHeight = 50;
const int kMinContentsHeight = 50;
#if defined(USE_AURA) && defined(OS_CHROMEOS)
// If a popup window is larger than this fraction of the screen, create a tab.
const float kPopupMaxWidthFactor = 0.5;
const float kPopupMaxHeightFactor = 0.6;
#endif
// How long do we wait before we consider a window hung (in ms).
static const int kDefaultPluginMessageResponseTimeout = 30000;
const int kDefaultPluginMessageResponseTimeout = 30000;
// The number of milliseconds between loading animation frames.
static const int kLoadingAnimationFrameTimeMs = 30;
const int kLoadingAnimationFrameTimeMs = 30;
// The amount of space we expect the window border to take up.
static const int kWindowBorderWidth = 5;
const int kWindowBorderWidth = 5;
// How round the 'new tab' style bookmarks bar is.
static const int kNewtabBarRoundness = 5;
const int kNewtabBarRoundness = 5;
// ------------
} // namespace
// Returned from BrowserView::GetClassName.
const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView";
......@@ -1313,9 +1322,12 @@ WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
// indicate a tab sized popup window.
gfx::Size size = gfx::Screen::GetMonitorAreaNearestWindow(
GetWidget()->GetNativeView()).size();
if (bounds.width() > size.width() ||
int max_width = size.width() * kPopupMaxWidthFactor;
int max_height = size.height() * kPopupMaxHeightFactor;
if (bounds.width() > max_width ||
bounds.width() == 0 ||
bounds.height() > size.height() ||
bounds.height() > max_height ||
bounds.height() == 0) {
return NEW_FOREGROUND_TAB;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment