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

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: 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') | pdf/out_of_process_instance.cc » ('J')
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..a2ef12eaa1908f1d92199032c3e403b0b93ed4a7 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -295,6 +295,50 @@ PDFViewer.prototype = {
/**
* @private
+ * Handle page param of open PDF parameters.
+ * @param {number} page value.
+ */
+ handlePageParam_: function(value) {
+ if (value > 0) {
+ // value is 1-based.
+ this.viewport_.goToPage(value - 1);
+ }
+ },
raymes 2014/08/15 01:07:18 I would suggest just inlining this function. viewp
Nikhil 2014/08/16 10:24:01 Done.
+
+ /**
+ * @private
+ * Handle open PDF parameters.
+ */
+ handleOpenPDFParams_: function() {
+ var originalUrl = this.streamDetails.originalUrl;
+ var hasParams = originalUrl.search('#');
+ if (hasParams == -1)
+ return;
+
+ var paramTokens = originalUrl.substring(hasParams + 1).split('&');
+ // Handle the case of http://foo.com/bar#NAMEDDEST. This is not explicitly
+ // mentioned except by example in the Adobe "PDF Open Parameters" document.
+ if ((paramTokens.length == 1) && (paramTokens[0].search('=') == -1)) {
+ // FIXME: Send message for GetNamedDestinationPage();
raymes 2014/08/15 01:07:18 Are you going to add support for this soon? If not
Nikhil 2014/08/16 10:24:01 Yes, I'm planning to add support for this soon in
raymes 2014/08/18 00:39:34 I had a look at the API that pdfium exposes and it
Nikhil 2014/08/18 04:53:32 I'll check it further.
+ return;
+ }
+
+ 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)
+ this.handlePageParam_(paramsDictionary['page']);
+ },
+
+ /**
+ * @private
* An event handler for handling password-submitted events. These are fired
* when an event is entered into the password screen.
* @param {Object} event a password-submitted event.
@@ -372,6 +416,9 @@ PDFViewer.prototype = {
case 'cancelStreamUrl':
chrome.streamsPrivate.abort(this.streamDetails.streamUrl);
break;
+ case 'openPDFParams':
+ this.handleOpenPDFParams_();
raymes 2014/08/15 01:07:17 Rather than calling this here, we can get rid of t
Nikhil 2014/08/16 10:24:01 Done.
+ break;
}
},
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | pdf/out_of_process_instance.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698