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

Side by Side Diff: chrome/browser/resources/pdf/pdf.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: Links in PDF should be opened in new background tabs when ctrl + left clicked. 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 tab. 59 * Called when navigation happens in the new background 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 background tab.
61 */ 61 */
62 function onNavigateInNewTab(url) { 62 function onNavigateInNewBackgroundTab(url) {
63 // Prefer the tabs API because it guarantees we can just open a new tab. 63 // Prefer the tabs API because it guarantees we can just open a new tab.
64 // window.open doesn't have this guarantee. 64 // window.open doesn't have this guarantee.
65 if (chrome.tabs) 65 if (chrome.tabs)
66 chrome.tabs.create({url: url}); 66 chrome.tabs.create({url: url, active: false});
67 else 67 else
68 window.open(url); 68 window.open(url);
69 } 69 }
70 70
71 /** 71 /**
72 * Whether keydown events should currently be ignored. Events are ignored when 72 * Whether keydown events should currently be ignored. Events are ignored when
73 * an editable element has focus, to allow for proper editing controls. 73 * an editable element has focus, to allow for proper editing controls.
74 * @param {HTMLElement} activeElement The currently selected DOM node. 74 * @param {HTMLElement} activeElement The currently selected DOM node.
75 * @return {boolean} True if keydown events should be ignored. 75 * @return {boolean} True if keydown events should be ignored.
76 */ 76 */
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 257 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
258 258
259 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; 259 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
260 var isSourceFileUrl = 260 var isSourceFileUrl =
261 this.originalUrl_.indexOf('file://') == 0; 261 this.originalUrl_.indexOf('file://') == 0;
262 this.navigator_ = new Navigator(this.originalUrl_, 262 this.navigator_ = new Navigator(this.originalUrl_,
263 this.viewport_, this.paramsParser_, 263 this.viewport_, this.paramsParser_,
264 onNavigateInCurrentTab.bind(undefined, 264 onNavigateInCurrentTab.bind(undefined,
265 isInTab, 265 isInTab,
266 isSourceFileUrl), 266 isSourceFileUrl),
267 onNavigateInNewTab); 267 onNavigateInNewBackgroundTab);
268 this.viewportScroller_ = 268 this.viewportScroller_ =
269 new ViewportScroller(this.viewport_, this.plugin_, window); 269 new ViewportScroller(this.viewport_, this.plugin_, window);
270 270
271 // Request translated strings. 271 // Request translated strings.
272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
273 } 273 }
274 274
275 PDFViewer.prototype = { 275 PDFViewer.prototype = {
276 /** 276 /**
277 * @private 277 * @private
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 * Each bookmark is an Object containing a: 878 * Each bookmark is an Object containing a:
879 * - title 879 * - title
880 * - page (optional) 880 * - page (optional)
881 * - array of children (themselves bookmarks) 881 * - array of children (themselves bookmarks)
882 * @type {Array} the top-level bookmarks of the PDF. 882 * @type {Array} the top-level bookmarks of the PDF.
883 */ 883 */
884 get bookmarks() { 884 get bookmarks() {
885 return this.bookmarks_; 885 return this.bookmarks_;
886 } 886 }
887 }; 887 };
OLDNEW
« chrome/browser/pdf/pdf_extension_test.cc ('K') | « chrome/browser/resources/pdf/navigator.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698