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

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 838153004: OOP PDF: Allow hyperlinks to be opened by print preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 02f18257e09f7d595e2a0de414b6e1cf552d2fb9..cb4c9ac9912d5810841fc39e690339208cc8a7f1 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -369,37 +369,41 @@ PDFViewer.prototype = {
url = originalUrl + url;
}
- var inputURL = url;
// If there's no scheme, add http.
- if (inputURL.indexOf('://') == -1 && inputURL.indexOf('mailto:') == -1)
- inputURL = 'http://' + inputURL;
-
- // Make sure inputURL starts with a valid scheme.
- if (inputURL.indexOf('http://') != 0 &&
- inputURL.indexOf('https://') != 0 &&
- inputURL.indexOf('ftp://') != 0 &&
- inputURL.indexOf('file://') != 0 &&
- inputURL.indexOf('mailto:') != 0) {
+ if (url.indexOf('://') == -1 && url.indexOf('mailto:') == -1)
+ url = 'http://' + url;
+
+ // Make sure url starts with a valid scheme.
+ if (url.indexOf('http://') != 0 &&
+ url.indexOf('https://') != 0 &&
+ url.indexOf('ftp://') != 0 &&
+ url.indexOf('file://') != 0 &&
+ url.indexOf('mailto:') != 0) {
return;
}
- // Make sure inputURL is not only a scheme.
- if (inputURL == 'http://' ||
- inputURL == 'https://' ||
- inputURL == 'ftp://' ||
- inputURL == 'file://' ||
- inputURL == 'mailto:') {
+ // Make sure url is not only a scheme.
+ if (url == 'http://' ||
+ url == 'https://' ||
+ url == 'ftp://' ||
+ url == 'file://' ||
+ url == 'mailto:') {
return;
}
if (newTab) {
- chrome.tabs.create({ url: inputURL });
+ // 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 });
+ else
+ window.open(url);
} else {
var pageNumber =
- this.paramsParser_.getViewportFromUrlParams(inputURL).page;
+ this.paramsParser_.getViewportFromUrlParams(url).page;
if (pageNumber != undefined)
this.viewport_.goToPage(pageNumber);
else
- window.location.href = inputURL;
+ window.location.href = url;
}
},
@@ -448,9 +452,11 @@ PDFViewer.prototype = {
this.updateProgress_(message.data.progress);
break;
case 'navigate':
+ // If in print preview, always open a new tab.
if (this.isPrintPreview_)
- break;
- this.navigate_(message.data.url, message.data.newTab);
+ this.navigate_(message.data.url, true);
+ else
+ this.navigate_(message.data.url, message.data.newTab);
break;
case 'setNamedDestinations':
this.paramsParser_.namedDestinations = message.data.namedDestinations;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698