summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 21:28:09 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 21:28:09 +0000
commit304f87929b95140904babafff6105e5a409500d5 (patch)
treeaa41b03b8dc9f3eee9515f777fb677f8626144d3 /chrome/browser/tab_contents
parent93c4d6b500ae28d826b034a914e23bb5676358f9 (diff)
downloadchromium_src-304f87929b95140904babafff6105e5a409500d5.zip
chromium_src-304f87929b95140904babafff6105e5a409500d5.tar.gz
chromium_src-304f87929b95140904babafff6105e5a409500d5.tar.bz2
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
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc25
1 files changed, 25 insertions, 0 deletions
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 kQueryStateDelay = 5000;
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 @@ void TabContents::AddNewContents(TabContents* new_contents,
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);