From 20cd211911527a6aa2c20486738a9870a0b40824 Mon Sep 17 00:00:00 2001 From: Dave Tapuska Date: Mon, 6 Jun 2016 14:31:02 -0400 Subject: [PATCH] Fix history page middle click action Send synthetic middle click in history page and also prevent default it as the links in history page will trigger twice if we don't prevent default it. BUG=609020 CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation Review-Url: https://codereview.chromium.org/2018943003 Cr-Commit-Position: refs/heads/master@{#397512} (cherry picked from commit a154aed1a3813cf28c6f477579ed7974a2528570) Review URL: https://codereview.chromium.org/2040813003 . Cr-Commit-Position: refs/branch-heads/2743@{#242} Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939} --- chrome/browser/resources/history/history.js | 1 + chrome/browser/resources/ntp4/new_tab.html | 2 +- chrome/browser/resources/{ntp4 => }/synthetic_middleclick.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) rename chrome/browser/resources/{ntp4 => }/synthetic_middleclick.js (84%) diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js index 64458dbeeffcd..8a59ce2a7f51a 100644 --- a/chrome/browser/resources/history/history.js +++ b/chrome/browser/resources/history/history.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html index 1aecb76b12376..0dbd981244271 100644 --- a/chrome/browser/resources/ntp4/new_tab.html +++ b/chrome/browser/resources/ntp4/new_tab.html @@ -50,7 +50,7 @@ - + diff --git a/chrome/browser/resources/ntp4/synthetic_middleclick.js b/chrome/browser/resources/synthetic_middleclick.js similarity index 84% rename from chrome/browser/resources/ntp4/synthetic_middleclick.js rename to chrome/browser/resources/synthetic_middleclick.js index 8c90c98a7f5ab..03b982e47a6bb 100644 --- a/chrome/browser/resources/ntp4/synthetic_middleclick.js +++ b/chrome/browser/resources/synthetic_middleclick.js @@ -21,4 +21,9 @@ document.addEventListener('mouseup', function(e) { middleButtonMouseDownTarget = null; }, true); +window.addEventListener('click', function(e) { + if (e.button == 1 && !e.isTrusted) + e.preventDefault(); +}); + })();