Chromium Code Reviews| 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..9a42de3f5a8804bbeef191eb3271b25d8883d9b0 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 hasParams = originalUrl.search('#'); |
|
Lei Zhang
2014/08/18 23:53:32
hasParams -> paramIndex?
Nikhil
2014/08/19 05:28:08
Done.
|
| + 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); |
|
Lei Zhang
2014/08/18 23:53:32
The current instance.cc code skips this if the pag
Nikhil
2014/08/19 05:28:08
Please let me know how do you think this should be
|
| + } |
| + }, |
| + |
| + /** |
| + * @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); |