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

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

Issue 2300243004: Links in PDF should open in a new window when shift + left clicked. (Closed)
Patch Set: Links in PDF should open in a new window when shift + left clicked. Created 4 years, 3 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 {Object} navigateCallback The object with callback functions that
13 * gets called when navigation happens in the current tab. 13 * get called when navigation happens in the current tab, a new tab,
14 * @param {Function} navigateInNewTabCallback The Callback function 14 * and a new window.
15 * that gets called when navigation happens in the new tab.
16 */ 15 */
17 function Navigator(originalUrl, 16 function Navigator(originalUrl, viewport, paramsParser, navigateCallback) {
raymes 2016/09/06 04:36:07 I think it would be better to call it something li
jaepark 2016/09/06 20:32:46 Done.
18 viewport,
19 paramsParser,
20 navigateInCurrentTabCallback,
21 navigateInNewTabCallback) {
22 this.originalUrl_ = originalUrl; 17 this.originalUrl_ = originalUrl;
23 this.viewport_ = viewport; 18 this.viewport_ = viewport;
24 this.paramsParser_ = paramsParser; 19 this.paramsParser_ = paramsParser;
25 this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback; 20 this.navigateInCurrentTabCallback_ = navigateCallback.currentTabCallback;
raymes 2016/09/06 04:36:07 this.navigatorDelegate_ = navigatorDelegate;
jaepark 2016/09/06 20:32:47 Done.
26 this.navigateInNewTabCallback_ = navigateInNewTabCallback; 21 this.navigateInNewTabCallback_ = navigateCallback.newTabCallback;
22 this.navigateInNewWindowCallback_ = navigateCallback.newWindowCallback;
27 } 23 }
28 24
29 /** 25 /**
30 * Represents options when navigating to a new url. C++ counterpart of 26 * Represents options when navigating to a new url. C++ counterpart of
31 * the enum is in ui/base/window_open_disposition.h. This enum represents 27 * the enum is in ui/base/window_open_disposition.h. This enum represents
32 * the only values that are passed from Plugin. 28 * the only values that are passed from Plugin.
33 * @enum {number} 29 * @enum {number}
34 */ 30 */
35 Navigator.WindowOpenDisposition = { 31 Navigator.WindowOpenDisposition = {
36 CURRENT_TAB: 1, 32 CURRENT_TAB: 1,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 67
72 if (!this.isValidUrl_(url)) 68 if (!this.isValidUrl_(url))
73 return; 69 return;
74 70
75 switch (disposition) { 71 switch (disposition) {
76 case Navigator.WindowOpenDisposition.CURRENT_TAB: 72 case Navigator.WindowOpenDisposition.CURRENT_TAB:
77 this.paramsParser_.getViewportFromUrlParams( 73 this.paramsParser_.getViewportFromUrlParams(
78 url, this.onViewportReceived_.bind(this)); 74 url, this.onViewportReceived_.bind(this));
79 break; 75 break;
80 case Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB: 76 case Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB:
81 this.navigateInNewTabCallback_(url, false); 77 this.navigateInNewTabCallback_(url, false);
raymes 2016/09/06 04:36:07 this.navigatorDelegate_.navigateInNewTab(...);
jaepark 2016/09/06 20:32:47 Done.
82 break; 78 break;
83 case Navigator.WindowOpenDisposition.NEW_FOREGROUND_TAB: 79 case Navigator.WindowOpenDisposition.NEW_FOREGROUND_TAB:
84 this.navigateInNewTabCallback_(url, true); 80 this.navigateInNewTabCallback_(url, true);
raymes 2016/09/06 04:36:07 this.navigatorDelegate_.navigateInNewTab(...);
jaepark 2016/09/06 20:32:47 Done.
85 break; 81 break;
86 case Navigator.WindowOpenDisposition.NEW_WINDOW: 82 case Navigator.WindowOpenDisposition.NEW_WINDOW:
87 // TODO(jaepark): Shift + left clicking a link in PDF should open the 83 this.navigateInNewWindowCallback_(url);
raymes 2016/09/06 04:36:07 this.navigatorDelegate_.navigateInNewWindow(...);
jaepark 2016/09/06 20:32:47 Done.
88 // link in a new window. See http://crbug.com/628057.
89 this.paramsParser_.getViewportFromUrlParams(
90 url, this.onViewportReceived_.bind(this));
91 break; 84 break;
92 case Navigator.WindowOpenDisposition.SAVE_TO_DISK: 85 case Navigator.WindowOpenDisposition.SAVE_TO_DISK:
93 // TODO(jaepark): Alt + left clicking a link in PDF should 86 // TODO(jaepark): Alt + left clicking a link in PDF should
94 // download the link. 87 // download the link.
95 this.paramsParser_.getViewportFromUrlParams( 88 this.paramsParser_.getViewportFromUrlParams(
96 url, this.onViewportReceived_.bind(this)); 89 url, this.onViewportReceived_.bind(this));
97 break; 90 break;
98 default: 91 default:
99 break; 92 break;
100 } 93 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (isRelative) { 195 if (isRelative) {
203 var slashIndex = this.originalUrl_.lastIndexOf('/'); 196 var slashIndex = this.originalUrl_.lastIndexOf('/');
204 var path = slashIndex != -1 ? 197 var path = slashIndex != -1 ?
205 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_; 198 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_;
206 return path + '/' + url; 199 return path + '/' + url;
207 } 200 }
208 201
209 return 'http://' + url; 202 return 'http://' + url;
210 } 203 }
211 }; 204 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698