Index: chrome/browser/resources/pdf/pdf.js |
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js |
index 70f53b7afc0068642049aacaeae66f4aae1c5929..59005e590bc2a1af607d66ea292684a0580f56e7 100644 |
--- a/chrome/browser/resources/pdf/pdf.js |
+++ b/chrome/browser/resources/pdf/pdf.js |
@@ -264,6 +264,33 @@ PDFViewer.prototype = { |
}, |
/** |
+ * Handle 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. |
+ */ |
+ handleZoomParam_: 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; |
+ |
+ // Handle #zoom=scale. |
+ if (paramValueSplit.length == 1) { |
+ this.viewport_.setZoom(zoomFactor); |
Nikhil
2014/08/19 15:09:42
setZoom() isn't working as intended. Is this not t
raymes
2014/08/20 00:14:21
This looks correct. What is it that isn't working?
Nikhil
2014/08/20 04:46:55
It didn't work as intended since zoom didn't chang
Nikhil
2014/08/21 11:36:50
It wasn't working because chrome.tabs.onZoomChange
|
+ return; |
+ } |
+ |
+ // Handle #zoom=scale,left,top. |
+ var position = {x: parseFloat(paramValueSplit[1]), |
Lei Zhang
2014/08/20 00:37:07
The Adobe open parameters document is rather vague
Nikhil
2014/08/20 04:46:54
Yep, it's a bit vague on units. Unlike page which
|
+ y: parseFloat(paramValueSplit[2])}; |
+ this.viewport_.position = position; |
+ this.viewport_.setZoom(zoomFactor); |
+ }, |
+ |
+ /** |
* @private |
* Handle open PDF parameters. These parameters are mentioned in the URL |
* and specify actions to be performed when opening PDF files. |
@@ -290,6 +317,8 @@ PDFViewer.prototype = { |
// value is 1-based. |
this.viewport_.goToPage(paramsDictionary['page'] - 1); |
} |
+ if ('zoom' in paramsDictionary) |
Lei Zhang
2014/08/20 00:37:07
I think order might also matter between page and z
Nikhil
2014/08/20 04:46:55
As I understand, page should always be handled bef
|
+ this.handleZoomParam_(paramsDictionary['zoom']); |
}, |
/** |