Make popups on Chrome OS turn into foreground tabs when they
are too big
Review URL: http://codereview.chromium.org/174019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23747 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 062f9dc..5b630cd 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -73,6 +73,10 @@
#include "views/controls/scrollbar/native_scroll_bar.h"
#endif
+#if defined(OS_CHROMEOS)
+// For GdkScreen
+#include <gdk/gdk.h>
+#endif
// Cross-Site Navigations
//
// If a TabContents is told to navigate to a different web site (as determined
@@ -120,6 +124,13 @@
const int kSyncWaitDelay = 40;
+#if defined(OS_CHROMEOS)
+// If a popup window is bigger than this fraction of the screen on chrome os,
+// turn it into a tab
+const float kMaxWidthFactor = 0.5;
+const float kMaxHeightFactor = 0.6;
+#endif
+
// If another javascript message box is displayed within
// kJavascriptMessageExpectedDelay of a previous javascript message box being
// dismissed, display an option to suppress future message boxes from this
@@ -802,6 +813,20 @@
initial_pos,
creator_url.is_valid() ? creator_url.host() : std::string());
} else {
+#if defined(OS_CHROMEOS)
+ if (disposition == NEW_POPUP) {
+ // If the popup is bigger than a given factor of the screen, then
+ // turn it into a foreground tab (on chrome os only)
+ GdkScreen* screen = gdk_screen_get_default();
+ int max_width = gdk_screen_get_width(screen) * kMaxWidthFactor;
+ int max_height = gdk_screen_get_height(screen) * kMaxHeightFactor;
+ if (initial_pos.width() > max_width ||
+ initial_pos.height() > max_height) {
+ disposition = NEW_FOREGROUND_TAB;
+ }
+ }
+#endif
+
new_contents->DisassociateFromPopupCount();
delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
user_gesture);