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

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2163893003: Start sending auxclick instead of click for non-primary buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another rebase Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Assertion support. 6 * @fileoverview Assertion support.
7 */ 7 */
8 8
9 /** 9 /**
10 * Verify |condition| is truthy and return |condition| if so. 10 * Verify |condition| is truthy and return |condition| if so.
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 * @return {!HTMLElement} the Element. 1353 * @return {!HTMLElement} the Element.
1354 */ 1354 */
1355 function queryRequiredElement(selectors, opt_context) { 1355 function queryRequiredElement(selectors, opt_context) {
1356 var element = (opt_context || document).querySelector(selectors); 1356 var element = (opt_context || document).querySelector(selectors);
1357 return assertInstanceof(element, HTMLElement, 1357 return assertInstanceof(element, HTMLElement,
1358 'Missing required element: ' + selectors); 1358 'Missing required element: ' + selectors);
1359 } 1359 }
1360 1360
1361 // Handle click on a link. If the link points to a chrome: or file: url, then 1361 // Handle click on a link. If the link points to a chrome: or file: url, then
1362 // call into the browser to do the navigation. 1362 // call into the browser to do the navigation.
1363 document.addEventListener('click', function(e) { 1363 ['click', 'auxclick'].forEach(function(eventName) {
1364 if (e.defaultPrevented) 1364 document.addEventListener(eventName, function(e) {
1365 return; 1365 if (e.defaultPrevented)
1366 return;
1366 1367
1367 var el = e.target; 1368 var el = e.target;
1368 if (el.nodeType == Node.ELEMENT_NODE && 1369 if (el.nodeType == Node.ELEMENT_NODE &&
1369 el.webkitMatchesSelector('A, A *')) { 1370 el.webkitMatchesSelector('A, A *')) {
1370 while (el.tagName != 'A') { 1371 while (el.tagName != 'A') {
1371 el = el.parentElement; 1372 el = el.parentElement;
1373 }
1374
1375 if ((el.protocol == 'file:' || el.protocol == 'about:') &&
1376 (e.button == 0 || e.button == 1)) {
1377 chrome.send('navigateToUrl', [
1378 el.href,
1379 el.target,
1380 e.button,
1381 e.altKey,
1382 e.ctrlKey,
1383 e.metaKey,
1384 e.shiftKey
1385 ]);
1386 e.preventDefault();
1387 }
1372 } 1388 }
1373 1389 });
1374 if ((el.protocol == 'file:' || el.protocol == 'about:') &&
1375 (e.button == 0 || e.button == 1)) {
1376 chrome.send('navigateToUrl', [
1377 el.href,
1378 el.target,
1379 e.button,
1380 e.altKey,
1381 e.ctrlKey,
1382 e.metaKey,
1383 e.shiftKey
1384 ]);
1385 e.preventDefault();
1386 }
1387 }
1388 }); 1390 });
1389 1391
1390 /** 1392 /**
1391 * Creates a new URL which is the old URL with a GET param of key=value. 1393 * Creates a new URL which is the old URL with a GET param of key=value.
1392 * @param {string} url The base URL. There is not sanity checking on the URL so 1394 * @param {string} url The base URL. There is not sanity checking on the URL so
1393 * it must be passed in a proper format. 1395 * it must be passed in a proper format.
1394 * @param {string} key The key of the param. 1396 * @param {string} key The key of the param.
1395 * @param {string} value The value of the param. 1397 * @param {string} value The value of the param.
1396 * @return {string} The new URL. 1398 * @return {string} The new URL.
1397 */ 1399 */
(...skipping 10512 matching lines...) Expand 10 before | Expand all | Expand 10 after
11910 Manager.updateItem = function(index, data) { 11912 Manager.updateItem = function(index, data) {
11911 Manager.get().updateItem_(index, data); 11913 Manager.get().updateItem_(index, data);
11912 }; 11914 };
11913 11915
11914 return {Manager: Manager}; 11916 return {Manager: Manager};
11915 }); 11917 });
11916 // Copyright 2015 The Chromium Authors. All rights reserved. 11918 // Copyright 2015 The Chromium Authors. All rights reserved.
11917 // Use of this source code is governed by a BSD-style license that can be 11919 // Use of this source code is governed by a BSD-style license that can be
11918 // found in the LICENSE file. 11920 // found in the LICENSE file.
11919 11921
11920 window.addEventListener('load', downloads.Manager.onLoad); 11922 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/other_devices.js ('k') | chrome/browser/resources/ntp4/apps_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698