summaryrefslogtreecommitdiffstats
path: root/webkit/glue/chrome_client_impl.cc
diff options
context:
space:
mode:
authorericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 21:32:47 +0000
committerericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 21:32:47 +0000
commit0d2772ecb10500d6bf4be0c3033ab4021dfbf4a3 (patch)
treecc47266ff06c35dbab8dc413772889fae9b16be8 /webkit/glue/chrome_client_impl.cc
parentfdbdc954056fd81d6291ccaffae45e849596dd18 (diff)
downloadchromium_src-0d2772ecb10500d6bf4be0c3033ab4021dfbf4a3.zip
chromium_src-0d2772ecb10500d6bf4be0c3033ab4021dfbf4a3.tar.gz
chromium_src-0d2772ecb10500d6bf4be0c3033ab4021dfbf4a3.tar.bz2
yMake ctrl-clicks in GMail open in background tabs rather than foreground tabs.
This piggybacks on eseidel's fix last July that made middle-clicks work. BUG=2566 TEST=Manual testing on Vista with GMail and non-GMail links, with ctrl+click, middle-click, click, and ctrl+shift+click. Review URL: http://codereview.chromium.org/246040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/chrome_client_impl.cc')
-rw-r--r--webkit/glue/chrome_client_impl.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index d635fb4..f96889c 100644
--- a/webkit/glue/chrome_client_impl.cc
+++ b/webkit/glue/chrome_client_impl.cc
@@ -236,7 +236,32 @@ static inline bool CurrentEventShouldCauseBackgroundTab(
const WebMouseEvent* mouse_event =
static_cast<const WebMouseEvent*>(input_event);
- return (mouse_event->button == WebMouseEvent::ButtonMiddle);
+
+ WebNavigationPolicy policy;
+ unsigned short button_number;
+ switch (mouse_event->button) {
+ case WebMouseEvent::ButtonLeft:
+ button_number = 0;
+ break;
+ case WebMouseEvent::ButtonMiddle:
+ button_number = 1;
+ break;
+ case WebMouseEvent::ButtonRight:
+ button_number = 2;
+ break;
+ default:
+ return false;
+ }
+ bool ctrl = mouse_event->modifiers & WebMouseEvent::ControlKey;
+ bool shift = mouse_event->modifiers & WebMouseEvent::ShiftKey;
+ bool alt = mouse_event->modifiers & WebMouseEvent::AltKey;
+ bool meta = mouse_event->modifiers & WebMouseEvent::MetaKey;
+
+ if (!WebViewImpl::NavigationPolicyFromMouseEvent(button_number, ctrl,
+ shift, alt, meta, &policy))
+ return false;
+
+ return policy == WebKit::WebNavigationPolicyNewBackgroundTab;
}
void ChromeClientImpl::show() {
@@ -257,7 +282,8 @@ void ChromeClientImpl::show() {
WebNavigationPolicy policy = WebKit::WebNavigationPolicyNewForegroundTab;
if (as_popup)
policy = WebKit::WebNavigationPolicyNewPopup;
- if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event()))
+ if (CurrentEventShouldCauseBackgroundTab(
+ WebViewImpl::current_input_event()))
policy = WebKit::WebNavigationPolicyNewBackgroundTab;
delegate->show(policy);