Index: chrome/browser/resources/pdf/open_pdf_params_parser.js |
diff --git a/chrome/browser/resources/pdf/open_pdf_params_parser.js b/chrome/browser/resources/pdf/open_pdf_params_parser.js |
index 7f55db0434d065c42e41d5ae4f0dccd11e76a862..f4fe8e7354a1617a6c5929c23e72379af59b9465 100644 |
--- a/chrome/browser/resources/pdf/open_pdf_params_parser.js |
+++ b/chrome/browser/resources/pdf/open_pdf_params_parser.js |
@@ -18,6 +18,36 @@ function OpenPDFParamsParser(url) { |
OpenPDFParamsParser.prototype = { |
/** |
* @private |
+ * Parse zoom parameter of open PDF parameters. If this |
+ * parameter is passed while opening PDF then PDF should be opened |
+ * at the specified zoom level. |
+ * @param {number} zoom value. |
+ */ |
+ parseZoomParam_: function(paramValue) { |
+ var paramValueSplit = paramValue.split(','); |
+ if ((paramValueSplit.length != 1) && (paramValueSplit.length != 3)) |
+ return; |
+ |
+ // User scale of 100 means zoom value of 100% i.e. zoom factor of 1.0. |
+ var zoomFactor = parseFloat(paramValueSplit[0]) / 100; |
+ if (isNaN(zoomFactor)) |
+ return; |
+ |
+ // Handle #zoom=scale. |
+ if (paramValueSplit.length == 1) { |
+ this.urlParams['zoom'] = zoomFactor; |
+ return; |
+ } |
+ |
+ // Handle #zoom=scale,left,top. |
+ var position = {x: parseFloat(paramValueSplit[1]), |
+ y: parseFloat(paramValueSplit[2])}; |
+ this.urlParams['position'] = position; |
+ this.urlParams['zoom'] = zoomFactor; |
+ }, |
+ |
+ /** |
+ * @private |
* Parse open PDF parameters. These parameters are mentioned in the url |
* and specify actions to be performed when opening pdf files. |
* See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/ |
@@ -44,5 +74,8 @@ OpenPDFParamsParser.prototype = { |
if (!isNaN(pageNumber)) |
this.urlParams['page'] = pageNumber - 1; |
} |
+ |
+ if ('zoom' in paramsDictionary) |
+ this.parseZoomParam_(paramsDictionary['zoom']); |
} |
}; |