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

Side by Side Diff: chrome/browser/resources/pdf/pdf.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 } 40 }
41 41
42 /** 42 /**
43 * Called when navigation happens in the current tab. 43 * Called when navigation happens in the current tab.
44 * @param {boolean} isInTab Indicates if the PDF viewer is displayed in a tab. 44 * @param {boolean} isInTab Indicates if the PDF viewer is displayed in a tab.
45 * @param {boolean} isSourceFileUrl Indicates if the navigation source is a 45 * @param {boolean} isSourceFileUrl Indicates if the navigation source is a
46 * file:// URL. 46 * file:// URL.
47 * @param {string} url The url to be opened in the current tab. 47 * @param {string} url The url to be opened in the current tab.
48 */ 48 */
49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) { 49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) {
raymes 2016/09/06 04:36:07 Why not define these 3 functions inside a Navigato
jaepark 2016/09/06 20:32:47 Done.
50 // When the PDFviewer is inside a browser tab, prefer the tabs API because 50 // When the PDFviewer is inside a browser tab, prefer the tabs API because
51 // it can navigate from one file:// URL to another. 51 // it can navigate from one file:// URL to another.
52 if (chrome.tabs && isInTab && isSourceFileUrl) 52 if (chrome.tabs && isInTab && isSourceFileUrl)
53 chrome.tabs.update({url: url}); 53 chrome.tabs.update({url: url});
54 else 54 else
55 window.location.href = url; 55 window.location.href = url;
56 } 56 }
57 57
58 /** 58 /**
59 * Called when navigation happens in the new tab. 59 * Called when navigation happens in the new tab.
60 * @param {string} url The url to be opened in the new tab. 60 * @param {string} url The url to be opened in the new tab.
61 * @param {boolean} active Indicates if the new tab should be the active tab. 61 * @param {boolean} active Indicates if the new tab should be the active tab.
62 */ 62 */
63 function onNavigateInNewTab(url, active) { 63 function onNavigateInNewTab(url, active) {
64 // Prefer the tabs API because it guarantees we can just open a new tab. 64 // Prefer the tabs API because it guarantees we can just open a new tab.
65 // window.open doesn't have this guarantee. 65 // window.open doesn't have this guarantee.
66 if (chrome.tabs) 66 if (chrome.tabs)
67 chrome.tabs.create({url: url, active: active}); 67 chrome.tabs.create({url: url, active: active});
68 else 68 else
69 window.open(url); 69 window.open(url);
70 } 70 }
71 71
72 /** 72 /**
73 * Called when navigation happens in the new window.
74 * @param {string} url The url to be opened in the new window.
75 */
76 function onNavigateInNewWindow(url) {
77 // Prefer the windows API because it guarantees we can just open a new window.
78 // window.open with '_blank' argument doesn't have this guarantee.
79 if (chrome.windows)
80 chrome.windows.create({url: url});
81 else
82 window.open(url, '_blank');
83 }
84
85 /**
73 * Whether keydown events should currently be ignored. Events are ignored when 86 * Whether keydown events should currently be ignored. Events are ignored when
74 * an editable element has focus, to allow for proper editing controls. 87 * an editable element has focus, to allow for proper editing controls.
75 * @param {HTMLElement} activeElement The currently selected DOM node. 88 * @param {HTMLElement} activeElement The currently selected DOM node.
76 * @return {boolean} True if keydown events should be ignored. 89 * @return {boolean} True if keydown events should be ignored.
77 */ 90 */
78 function shouldIgnoreKeyEvents(activeElement) { 91 function shouldIgnoreKeyEvents(activeElement) {
79 while (activeElement.shadowRoot != null && 92 while (activeElement.shadowRoot != null &&
80 activeElement.shadowRoot.activeElement != null) { 93 activeElement.shadowRoot.activeElement != null) {
81 activeElement = activeElement.shadowRoot.activeElement; 94 activeElement = activeElement.shadowRoot.activeElement;
82 } 95 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 this.browserApi_.addZoomEventListener( 266 this.browserApi_.addZoomEventListener(
254 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 267 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
255 268
256 // Setup the keyboard event listener. 269 // Setup the keyboard event listener.
257 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 270 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
258 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 271 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
259 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 272 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
260 273
261 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; 274 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
262 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0; 275 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0;
263 this.navigator_ = new Navigator(this.originalUrl_, 276 var onNavigateCallback = {
264 this.viewport_, this.paramsParser_, 277 currentTabCallback: onNavigateInCurrentTab.bind(undefined, isInTab,
265 onNavigateInCurrentTab.bind(undefined, 278 isSourceFileUrl),
266 isInTab, 279 newTabCallback: onNavigateInNewTab,
267 isSourceFileUrl), 280 newWindowCallback: onNavigateInNewWindow
268 onNavigateInNewTab); 281 };
282 this.navigator_ = new Navigator(this.originalUrl_, this.viewport_,
283 this.paramsParser_, onNavigateCallback);
raymes 2016/09/06 04:36:07 Then we could just pass in a new NavigatorDelegate
jaepark 2016/09/06 20:32:47 Done.
269 this.viewportScroller_ = 284 this.viewportScroller_ =
270 new ViewportScroller(this.viewport_, this.plugin_, window); 285 new ViewportScroller(this.viewport_, this.plugin_, window);
271 286
272 // Request translated strings. 287 // Request translated strings.
273 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 288 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
274 } 289 }
275 290
276 PDFViewer.prototype = { 291 PDFViewer.prototype = {
277 /** 292 /**
278 * @private 293 * @private
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 * Each bookmark is an Object containing a: 895 * Each bookmark is an Object containing a:
881 * - title 896 * - title
882 * - page (optional) 897 * - page (optional)
883 * - array of children (themselves bookmarks) 898 * - array of children (themselves bookmarks)
884 * @type {Array} the top-level bookmarks of the PDF. 899 * @type {Array} the top-level bookmarks of the PDF.
885 */ 900 */
886 get bookmarks() { 901 get bookmarks() {
887 return this.bookmarks_; 902 return this.bookmarks_;
888 } 903 }
889 }; 904 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698