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

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

Issue 2166193002: Handle ctrl + shift + left click on links in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle ctrl + shift + left click on links in PDF. 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 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) { 49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) {
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 background tab. 59 * Called when navigation happens in the new tab.
60 * @param {string} url The url to be opened in the new background 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 */ 62 */
62 function onNavigateInNewBackgroundTab(url) { 63 function onNavigateInNewTab(url, active) {
63 // 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.
64 // window.open doesn't have this guarantee. 65 // window.open doesn't have this guarantee.
65 if (chrome.tabs) 66 if (chrome.tabs)
66 chrome.tabs.create({url: url, active: false}); 67 chrome.tabs.create({url: url, active: active});
67 else 68 else
68 window.open(url); 69 window.open(url);
69 } 70 }
70 71
71 /** 72 /**
72 * Whether keydown events should currently be ignored. Events are ignored when 73 * Whether keydown events should currently be ignored. Events are ignored when
73 * an editable element has focus, to allow for proper editing controls. 74 * an editable element has focus, to allow for proper editing controls.
74 * @param {HTMLElement} activeElement The currently selected DOM node. 75 * @param {HTMLElement} activeElement The currently selected DOM node.
75 * @return {boolean} True if keydown events should be ignored. 76 * @return {boolean} True if keydown events should be ignored.
76 */ 77 */
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 232
232 this.toolbar_.docTitle = 233 this.toolbar_.docTitle =
233 getFilenameFromURL(this.originalUrl_); 234 getFilenameFromURL(this.originalUrl_);
234 } 235 }
235 236
236 document.body.addEventListener('change-page', function(e) { 237 document.body.addEventListener('change-page', function(e) {
237 this.viewport_.goToPage(e.detail.page); 238 this.viewport_.goToPage(e.detail.page);
238 }.bind(this)); 239 }.bind(this));
239 240
240 document.body.addEventListener('navigate', function(e) { 241 document.body.addEventListener('navigate', function(e) {
241 this.navigator_.navigate(e.detail.uri, e.detail.newtab); 242 var disposition =
243 e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB :
244 Navigator.WindowOpenDisposition.CURRENT_TAB;
245 this.navigator_.navigate(e.detail.uri, disposition);
242 }.bind(this)); 246 }.bind(this));
243 247
244 this.toolbarManager_ = 248 this.toolbarManager_ =
245 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_); 249 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_);
246 250
247 // Set up the ZoomManager. 251 // Set up the ZoomManager.
248 this.zoomManager_ = new ZoomManager( 252 this.zoomManager_ = new ZoomManager(
249 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_), 253 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_),
250 this.browserApi_.getInitialZoom()); 254 this.browserApi_.getInitialZoom());
251 this.browserApi_.addZoomEventListener( 255 this.browserApi_.addZoomEventListener(
252 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 256 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
253 257
254 // Setup the keyboard event listener. 258 // Setup the keyboard event listener.
255 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 259 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
256 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 260 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
257 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 261 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
258 262
259 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; 263 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
260 var isSourceFileUrl = 264 var isSourceFileUrl =
261 this.originalUrl_.indexOf('file://') == 0; 265 this.originalUrl_.indexOf('file://') == 0;
262 this.navigator_ = new Navigator(this.originalUrl_, 266 this.navigator_ = new Navigator(this.originalUrl_,
263 this.viewport_, this.paramsParser_, 267 this.viewport_, this.paramsParser_,
264 onNavigateInCurrentTab.bind(undefined, 268 onNavigateInCurrentTab.bind(undefined,
265 isInTab, 269 isInTab,
266 isSourceFileUrl), 270 isSourceFileUrl),
267 onNavigateInNewBackgroundTab); 271 onNavigateInNewTab);
268 this.viewportScroller_ = 272 this.viewportScroller_ =
269 new ViewportScroller(this.viewport_, this.plugin_, window); 273 new ViewportScroller(this.viewport_, this.plugin_, window);
270 274
271 // Request translated strings. 275 // Request translated strings.
272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 276 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
273 } 277 }
274 278
275 PDFViewer.prototype = { 279 PDFViewer.prototype = {
276 /** 280 /**
277 * @private 281 * @private
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 this.sendScriptingMessage_(message.data); 624 this.sendScriptingMessage_(message.data);
621 break; 625 break;
622 case 'goToPage': 626 case 'goToPage':
623 this.viewport_.goToPage(message.data.page); 627 this.viewport_.goToPage(message.data.page);
624 break; 628 break;
625 case 'loadProgress': 629 case 'loadProgress':
626 this.updateProgress_(message.data.progress); 630 this.updateProgress_(message.data.progress);
627 break; 631 break;
628 case 'navigate': 632 case 'navigate':
629 // If in print preview, always open a new tab. 633 // If in print preview, always open a new tab.
630 if (this.isPrintPreview_) 634 if (this.isPrintPreview_) {
631 this.navigator_.navigate(message.data.url, true); 635 this.navigator_.navigate(
632 else 636 message.data.url,
633 this.navigator_.navigate(message.data.url, message.data.newTab); 637 Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB);
638 } else {
639 this.navigator_.navigate(message.data.url, message.data.disposition);
640 }
634 break; 641 break;
635 case 'setScrollPosition': 642 case 'setScrollPosition':
636 var position = this.viewport_.position; 643 var position = this.viewport_.position;
637 if (message.data.x !== undefined) 644 if (message.data.x !== undefined)
638 position.x = message.data.x; 645 position.x = message.data.x;
639 if (message.data.y !== undefined) 646 if (message.data.y !== undefined)
640 position.y = message.data.y; 647 position.y = message.data.y;
641 this.viewport_.position = position; 648 this.viewport_.position = position;
642 break; 649 break;
643 case 'cancelStreamUrl': 650 case 'cancelStreamUrl':
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 * Each bookmark is an Object containing a: 885 * Each bookmark is an Object containing a:
879 * - title 886 * - title
880 * - page (optional) 887 * - page (optional)
881 * - array of children (themselves bookmarks) 888 * - array of children (themselves bookmarks)
882 * @type {Array} the top-level bookmarks of the PDF. 889 * @type {Array} the top-level bookmarks of the PDF.
883 */ 890 */
884 get bookmarks() { 891 get bookmarks() {
885 return this.bookmarks_; 892 return this.bookmarks_;
886 } 893 }
887 }; 894 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698