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

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

Issue 476733003: OOP PDF - Add support for "page" open pdf parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (hasParams -> paramIndex) Created 6 years, 4 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 | pdf/out_of_process_instance.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 7c3d906bf68dc831ca37c47fc447c616c5c2fa25..70f53b7afc0068642049aacaeae66f4aae1c5929 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -265,6 +265,35 @@ PDFViewer.prototype = {
/**
* @private
+ * Handle open PDF parameters. These parameters are mentioned in the URL
+ * and specify actions to be performed when opening PDF files.
+ * See http://crbug.com/64309 for details.
+ */
+ handleOpenPDFParams_: function() {
+ var originalUrl = this.streamDetails.originalUrl;
+ var paramIndex = originalUrl.search('#');
+ if (paramIndex == -1)
+ return;
+
+ var paramTokens = originalUrl.substring(paramIndex + 1).split('&');
+ var paramsDictionary = {};
+ for (var i = 0; i < paramTokens.length; ++i) {
+ var keyValueSplit = paramTokens[i].split('=');
+ if (keyValueSplit.length != 2)
+ continue;
+ paramsDictionary[keyValueSplit[0]] = keyValueSplit[1];
+ }
+
+ // Order is important as later actions can override the effects
+ // of previous actions.
+ if ('page' in paramsDictionary) {
+ // value is 1-based.
+ this.viewport_.goToPage(paramsDictionary['page'] - 1);
+ }
+ },
+
+ /**
+ * @private
* Update the loading progress of the document in response to a progress
* message being received from the plugin.
* @param {number} progress the progress as a percentage.
@@ -282,6 +311,7 @@ PDFViewer.prototype = {
}
} else if (progress == 100) {
// Document load complete.
+ this.handleOpenPDFParams_();
this.loaded = true;
var loadEvent = new Event('pdfload');
window.dispatchEvent(loadEvent);
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698