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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index c7b172078d7778472af64c4fe851a35bca15b73e..822461cb5b3c65508029d725c80677b8194d92e0 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -40,36 +40,6 @@ function getFilenameFromURL(url) {
}
/**
- * Called when navigation happens in the current tab.
- * @param {boolean} isInTab Indicates if the PDF viewer is displayed in a tab.
- * @param {boolean} isSourceFileUrl Indicates if the navigation source is a
- * file:// URL.
- * @param {string} url The url to be opened in the current tab.
- */
-function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) {
- // When the PDFviewer is inside a browser tab, prefer the tabs API because
- // it can navigate from one file:// URL to another.
- if (chrome.tabs && isInTab && isSourceFileUrl)
- chrome.tabs.update({url: url});
- else
- window.location.href = url;
-}
-
-/**
- * Called when navigation happens in the new tab.
- * @param {string} url The url to be opened in the new tab.
- * @param {boolean} active Indicates if the new tab should be the active tab.
- */
-function onNavigateInNewTab(url, active) {
- // Prefer the tabs API because it guarantees we can just open a new tab.
- // window.open doesn't have this guarantee.
- if (chrome.tabs)
- chrome.tabs.create({url: url, active: active});
- else
- window.open(url);
-}
-
-/**
* Whether keydown events should currently be ignored. Events are ignored when
* an editable element has focus, to allow for proper editing controls.
* @param {HTMLElement} activeElement The currently selected DOM node.
@@ -260,12 +230,9 @@ function PDFViewer(browserApi) {
var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0;
- this.navigator_ = new Navigator(this.originalUrl_,
- this.viewport_, this.paramsParser_,
- onNavigateInCurrentTab.bind(undefined,
- isInTab,
- isSourceFileUrl),
- onNavigateInNewTab);
+ this.navigator_ = new Navigator(
+ this.originalUrl_, this.viewport_, this.paramsParser_,
+ new NavigatorDelegate(isInTab, isSourceFileUrl));
this.viewportScroller_ =
new ViewportScroller(this.viewport_, this.plugin_, window);

Powered by Google App Engine
This is Rietveld 408576698