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

Side by Side Diff: chrome/browser/resources/shared/js/util.js

Issue 6269015: Add facility to fix about: and file: links from chrome:// pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more automatic Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 * The global object. 6 * The global object.
7 * @param {!Object} 7 * @param {!Object}
8 */ 8 */
9 const global = this; 9 const global = this;
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 */ 63 */
64 function parseQueryParams(location) { 64 function parseQueryParams(location) {
65 var params = {}; 65 var params = {};
66 var query = unescape(location.search.substring(1)); 66 var query = unescape(location.search.substring(1));
67 var vars = query.split("&"); 67 var vars = query.split("&");
68 for (var i=0; i < vars.length; i++) { 68 for (var i=0; i < vars.length; i++) {
69 var pair = vars[i].split("="); 69 var pair = vars[i].split("=");
70 params[pair[0]] = pair[1]; 70 params[pair[0]] = pair[1];
71 } 71 }
72 return params; 72 return params;
73 } 73 }
74
75 /*
76 * Handles a click or mouseup on a link. If the link points to a chrome: or
77 * file: url, then call into the browser to do the navigation.
78 * @return {Object} e The click or mouseup event.
79 */
80 function handleLinkClickOrMouseUp(e) {
81 var el = e.target;
82 if (el.nodeType == Node.ELEMENT_NODE &&
83 el.webkitMatchesSelector('A, A *')) {
84 while (el.tagName != 'A') {
85 el = el.parentElement;
86 }
87
88 if ((el.protocol == 'file:' || el.protocol == 'about:') &&
89 ((e.button == 0 && e.type == 'click') ||
90 (e.button == 1 && e.type == 'mouseup'))) {
91 chrome.send('navigateToUrl',
92 [el.href, String(e.button), String(e.ctrlKey), String(e.shiftKey),
93 String(e.altKey)]);
94 e.preventDefault();
95 }
96 }
97 }
98
99 document.addEventListener('click', handleLinkClickOrMouseUp, true);
100 document.addEventListener('mouseup', handleLinkClickOrMouseUp, true);
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings_exceptions_area.html ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698