Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1443)

Unified Diff: Source/web/FrameLoaderClientImpl.cpp

Issue 720283002: Revert of Revert "Only allow background tabs if the underlying input event allows it" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/FrameLoaderClientImpl.cpp
diff --git a/Source/web/FrameLoaderClientImpl.cpp b/Source/web/FrameLoaderClientImpl.cpp
index 4939407368f217e85a77e0ae07ad5b45808b3472..dedcf9efa9bea890f4d67a590f1648860a18bd92 100644
--- a/Source/web/FrameLoaderClientImpl.cpp
+++ b/Source/web/FrameLoaderClientImpl.cpp
@@ -466,10 +466,47 @@
m_webFrame->client()->didChangeThemeColor();
}
+static bool allowCreatingBackgroundTabs()
+{
+ const WebInputEvent* inputEvent = WebViewImpl::currentInputEvent();
+ if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp)
+ return false;
+
+ const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
+
+ unsigned short buttonNumber;
+ switch (mouseEvent->button) {
+ case WebMouseEvent::ButtonLeft:
+ buttonNumber = 0;
+ break;
+ case WebMouseEvent::ButtonMiddle:
+ buttonNumber = 1;
+ break;
+ case WebMouseEvent::ButtonRight:
+ buttonNumber = 2;
+ break;
+ default:
+ return false;
+ }
+ bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
+ bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
+ bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
+ bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
+
+ NavigationPolicy userPolicy;
+ if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPolicy))
+ return false;
+ return userPolicy == NavigationPolicyNewBackgroundTab;
+}
+
NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const ResourceRequest& request, DocumentLoader* loader, NavigationPolicy policy, bool isTransitionNavigation)
{
if (!m_webFrame->client())
return NavigationPolicyIgnore;
+
+ if (policy == NavigationPolicyNewBackgroundTab && !allowCreatingBackgroundTabs())
+ policy = NavigationPolicyNewForegroundTab;
+
WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader);
WrappedResourceRequest wrappedResourceRequest(request);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698