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

Unified Diff: chrome/browser/resources/pdf/pdf.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: OOP PDF Changes 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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']);
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698