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

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

Issue 838723003: Testcases for nameddests and navigate for PDF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. 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 | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/browser/resources/pdf/pdf_extension_test.cc » ('j') | 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 fb4d3ee53a3d7d19b7c918089fcc09b3de7097a1..05df167acaaaa2076de86faba19866eafb27df55 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -31,6 +31,27 @@ function getFilenameFromURL(url) {
}
/**
+ * Called when navigation happens in the current tab.
+ * @param {string} url The url to be opened in the current tab.
+ */
+function onNavigateInCurrentTab(url) {
+ window.location.href = url;
+}
+
+/**
+ * Called when navigation happens in the new tab.
+ * @param {string} url The url to be opened in the new tab.
+ */
+function onNavigateInNewTab(url) {
+ // 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);
+}
+
+/**
* The minimum number of pixels to offset the toolbar by from the bottom and
* right side of the screen.
*/
@@ -156,7 +177,8 @@ function PDFViewer(streamDetails) {
// Parse open pdf parameters.
this.paramsParser_ = new OpenPDFParamsParser();
this.navigator_ = new Navigator(this.streamDetails_.originalUrl,
- this.viewport_, this.paramsParser_);
+ this.viewport_, this.paramsParser_, onNavigateInCurrentTab,
+ onNavigateInNewTab);
}
PDFViewer.prototype = {
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/browser/resources/pdf/pdf_extension_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698