| 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);
|
|
|