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

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
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/test/data/pdf/navigator_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 try { 33 try {
34 return decodeURIComponent(filename); 34 return decodeURIComponent(filename);
35 } catch (e) { 35 } catch (e) {
36 if (e instanceof URIError) 36 if (e instanceof URIError)
37 return filename; 37 return filename;
38 throw e; 38 throw e;
39 } 39 }
40 } 40 }
41 41
42 /** 42 /**
43 * Called when navigation happens in the current 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
46 * file:// URL.
47 * @param {string} url The url to be opened in the current tab.
48 */
49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) {
50 // When the PDFviewer is inside a browser tab, prefer the tabs API because
51 // it can navigate from one file:// URL to another.
52 if (chrome.tabs && isInTab && isSourceFileUrl)
53 chrome.tabs.update({url: url});
54 else
55 window.location.href = url;
56 }
57
58 /**
59 * Called when navigation happens 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.
62 */
63 function onNavigateInNewTab(url, active) {
64 // Prefer the tabs API because it guarantees we can just open a new tab.
65 // window.open doesn't have this guarantee.
66 if (chrome.tabs)
67 chrome.tabs.create({url: url, active: active});
68 else
69 window.open(url);
70 }
71
72 /**
73 * Whether keydown events should currently be ignored. Events are ignored when 43 * Whether keydown events should currently be ignored. Events are ignored when
74 * an editable element has focus, to allow for proper editing controls. 44 * an editable element has focus, to allow for proper editing controls.
75 * @param {HTMLElement} activeElement The currently selected DOM node. 45 * @param {HTMLElement} activeElement The currently selected DOM node.
76 * @return {boolean} True if keydown events should be ignored. 46 * @return {boolean} True if keydown events should be ignored.
77 */ 47 */
78 function shouldIgnoreKeyEvents(activeElement) { 48 function shouldIgnoreKeyEvents(activeElement) {
79 while (activeElement.shadowRoot != null && 49 while (activeElement.shadowRoot != null &&
80 activeElement.shadowRoot.activeElement != null) { 50 activeElement.shadowRoot.activeElement != null) {
81 activeElement = activeElement.shadowRoot.activeElement; 51 activeElement = activeElement.shadowRoot.activeElement;
82 } 52 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 this.browserApi_.addZoomEventListener( 223 this.browserApi_.addZoomEventListener(
254 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 224 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
255 225
256 // Setup the keyboard event listener. 226 // Setup the keyboard event listener.
257 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 227 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
258 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 228 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
259 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 229 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
260 230
261 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; 231 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
262 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0; 232 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0;
263 this.navigator_ = new Navigator(this.originalUrl_, 233 this.navigator_ = new Navigator(
264 this.viewport_, this.paramsParser_, 234 this.originalUrl_, this.viewport_, this.paramsParser_,
265 onNavigateInCurrentTab.bind(undefined, 235 new NavigatorDelegate(isInTab, isSourceFileUrl));
266 isInTab,
267 isSourceFileUrl),
268 onNavigateInNewTab);
269 this.viewportScroller_ = 236 this.viewportScroller_ =
270 new ViewportScroller(this.viewport_, this.plugin_, window); 237 new ViewportScroller(this.viewport_, this.plugin_, window);
271 238
272 // Request translated strings. 239 // Request translated strings.
273 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 240 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
274 } 241 }
275 242
276 PDFViewer.prototype = { 243 PDFViewer.prototype = {
277 /** 244 /**
278 * @private 245 * @private
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 * Each bookmark is an Object containing a: 855 * Each bookmark is an Object containing a:
889 * - title 856 * - title
890 * - page (optional) 857 * - page (optional)
891 * - array of children (themselves bookmarks) 858 * - array of children (themselves bookmarks)
892 * @type {Array} the top-level bookmarks of the PDF. 859 * @type {Array} the top-level bookmarks of the PDF.
893 */ 860 */
894 get bookmarks() { 861 get bookmarks() {
895 return this.bookmarks_; 862 return this.bookmarks_;
896 } 863 }
897 }; 864 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/test/data/pdf/navigator_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698