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

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..8cb012aac9e48dbcdb594a64267c344fb5848585 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -70,6 +70,19 @@ function onNavigateInNewTab(url, active) {
}
/**
+ * Called when navigation happens in the new window.
+ * @param {string} url The url to be opened in the new window.
+ */
+function onNavigateInNewWindow(url) {
+ // Prefer the windows API because it guarantees we can just open a new window.
+ // window.open with '_blank' argument doesn't have this guarantee.
+ if (chrome.windows)
+ chrome.windows.create({url: url});
+ else
+ window.open(url, '_blank');
+}
+
+/**
* 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.
@@ -265,7 +278,7 @@ function PDFViewer(browserApi) {
onNavigateInCurrentTab.bind(undefined,
isInTab,
isSourceFileUrl),
- onNavigateInNewTab);
+ onNavigateInNewTab, onNavigateInNewWindow);
this.viewportScroller_ =
new ViewportScroller(this.viewport_, this.plugin_, window);

Powered by Google App Engine
This is Rietveld 408576698