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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/util.js
diff --git a/chrome/browser/resources/shared/js/util.js b/chrome/browser/resources/shared/js/util.js
index baa88afd1fa73b4b8a1ec9e6220041c2b2e080d5..6afcbbafa0f4740e3eca9306f00d425afb75778e 100644
--- a/chrome/browser/resources/shared/js/util.js
+++ b/chrome/browser/resources/shared/js/util.js
@@ -70,4 +70,31 @@ function parseQueryParams(location) {
params[pair[0]] = pair[1];
}
return params;
- }
+}
+
+/*
+ * Handles a click or mouseup on a link. If the link points to a chrome: or
+ * file: url, then call into the browser to do the navigation.
+ * @return {Object} e The click or mouseup event.
+ */
+function handleLinkClickOrMouseUp(e) {
+ var el = e.target;
+ if (el.nodeType == Node.ELEMENT_NODE &&
+ el.webkitMatchesSelector('A, A *')) {
+ while (el.tagName != 'A') {
+ el = el.parentElement;
+ }
+
+ if ((el.protocol == 'file:' || el.protocol == 'about:') &&
+ ((e.button == 0 && e.type == 'click') ||
+ (e.button == 1 && e.type == 'mouseup'))) {
+ chrome.send('navigateToUrl',
+ [el.href, String(e.button), String(e.ctrlKey), String(e.shiftKey),
+ String(e.altKey)]);
+ e.preventDefault();
+ }
+ }
+}
+
+document.addEventListener('click', handleLinkClickOrMouseUp, true);
+document.addEventListener('mouseup', handleLinkClickOrMouseUp, true);
« 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