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

Unified Diff: chrome/browser/resources/pdf/open_pdf_params_parser.js

Issue 420063002: OOP PDF - Add support for "zoom" open pdf parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback 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 | chrome/browser/resources/pdf/pdf.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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']);
}
};
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698