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

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 (removed new message for openPDFParams) 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..8938b1ee73f5fcb0f1f8bb72e7cf8e9f2d040184 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -265,6 +265,33 @@ PDFViewer.prototype = {
/**
* @private
+ * Handle open PDF parameters.
raymes 2014/08/18 00:39:34 nit: Maybe we can elaborate on the comment saying
Nikhil 2014/08/18 04:53:32 Done.
+ */
+ handleOpenPDFParams_: function() {
+ var originalUrl = this.streamDetails.originalUrl;
+ var hasParams = originalUrl.search('#');
+ if (hasParams == -1)
+ return;
+
+ var paramTokens = originalUrl.substring(hasParams + 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 +309,7 @@ PDFViewer.prototype = {
}
} else if (progress == 100) {
// Document load complete.
+ this.handleOpenPDFParams_();
Nikhil 2014/08/16 10:24:01 Is there a way to check whether we are in PrintPre
Nikhil 2014/08/17 16:53:45 Maybe I can introduce isPrintPreview() here? Simil
raymes 2014/08/18 00:39:34 I think it should be ok not to do any check here.
Nikhil 2014/08/18 04:53:32 Acknowledged.
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