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

Side by Side Diff: chrome/browser/resources/pdf/navigator.js

Issue 2149153003: Links in PDF should be opened in new background tabs when ctrl + left clicked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Creates a new Navigator for navigating to links inside or outside the PDF. 8 * Creates a new Navigator for navigating to links inside or outside the PDF.
9 * @param {string} originalUrl The original page URL. 9 * @param {string} originalUrl The original page URL.
10 * @param {Object} viewport The viewport info of the page. 10 * @param {Object} viewport The viewport info of the page.
11 * @param {Object} paramsParser The object for URL parsing. 11 * @param {Object} paramsParser The object for URL parsing.
12 * @param {Function} navigateInCurrentTabCallback The Callback function that 12 * @param {Function} navigateInCurrentTabCallback The Callback function that
13 * gets called when navigation happens in the current tab. 13 * gets called when navigation happens in the current tab.
14 * @param {Function} navigateInNewTabCallback The Callback function that gets 14 * @param {Function} navigateInNewBackgroundTabCallback The Callback function
15 * called when navigation happens in the new tab. 15 * that gets called when navigation happens in the new background tab.
16 */ 16 */
17 function Navigator(originalUrl, 17 function Navigator(originalUrl,
18 viewport, 18 viewport,
19 paramsParser, 19 paramsParser,
20 navigateInCurrentTabCallback, 20 navigateInCurrentTabCallback,
21 navigateInNewTabCallback) { 21 navigateInNewBackgroundTabCallback) {
22 this.originalUrl_ = originalUrl; 22 this.originalUrl_ = originalUrl;
23 this.viewport_ = viewport; 23 this.viewport_ = viewport;
24 this.paramsParser_ = paramsParser; 24 this.paramsParser_ = paramsParser;
25 this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback; 25 this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback;
26 this.navigateInNewTabCallback_ = navigateInNewTabCallback; 26 this.navigateInNewBackgroundTabCallback_ = navigateInNewBackgroundTabCallback;
27 } 27 }
28 28
29 Navigator.prototype = { 29 Navigator.prototype = {
30 /** 30 /**
31 * @private 31 * @private
32 * Function to navigate to the given URL. This might involve navigating 32 * Function to navigate to the given URL. This might involve navigating
33 * within the PDF page or opening a new url (in the same tab or a new tab). 33 * within the PDF page or opening a new url (in the same tab or a new tab).
34 * @param {string} url The URL to navigate to. 34 * @param {string} url The URL to navigate to.
35 * @param {boolean} newTab Whether to perform the navigation in a new tab or 35 * @param {boolean} newTab Whether to perform the navigation in a new tab or
36 * in the current tab. 36 * in the current tab.
(...skipping 15 matching lines...) Expand all
52 } 52 }
53 53
54 // If there's no scheme, then take a guess at the scheme. 54 // If there's no scheme, then take a guess at the scheme.
55 if (url.indexOf('://') == -1 && url.indexOf('mailto:') == -1) 55 if (url.indexOf('://') == -1 && url.indexOf('mailto:') == -1)
56 url = this.guessUrlWithoutScheme_(url); 56 url = this.guessUrlWithoutScheme_(url);
57 57
58 if (!this.isValidUrl_(url)) 58 if (!this.isValidUrl_(url))
59 return; 59 return;
60 60
61 if (newTab) { 61 if (newTab) {
62 this.navigateInNewTabCallback_(url); 62 this.navigateInNewBackgroundTabCallback_(url);
63 } else { 63 } else {
64 this.paramsParser_.getViewportFromUrlParams( 64 this.paramsParser_.getViewportFromUrlParams(
65 url, this.onViewportReceived_.bind(this)); 65 url, this.onViewportReceived_.bind(this));
66 } 66 }
67 }, 67 },
68 68
69 /** 69 /**
70 * @private 70 * @private
71 * Called when the viewport position is received. 71 * Called when the viewport position is received.
72 * @param {Object} viewportPosition Dictionary containing the viewport 72 * @param {Object} viewportPosition Dictionary containing the viewport
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (isRelative) { 168 if (isRelative) {
169 var slashIndex = this.originalUrl_.lastIndexOf('/'); 169 var slashIndex = this.originalUrl_.lastIndexOf('/');
170 var path = slashIndex != -1 ? 170 var path = slashIndex != -1 ?
171 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_; 171 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_;
172 return path + '/' + url; 172 return path + '/' + url;
173 } 173 }
174 174
175 return 'http://' + url; 175 return 'http://' + url;
176 } 176 }
177 }; 177 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698