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

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

Issue 169613005: Hookup print and save buttons in the out of process PDF plugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 604a13f2c43bc61c84f2fe103de153ebabe82466..f41d602ce588dedcfb3bd0fc966fbd194ca94a32 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -33,6 +33,13 @@ var viewport;
// The document dimensions.
var documentDimensions;
+// Notify the plugin to print.
+function print() {
+ plugin.postMessage({
+ type: 'print',
+ });
+}
+
// Returns true if the fit-to-page button is enabled.
function isFitToPageEnabled() {
return $('fit-to-page-button').classList.contains('polymer-selected');
@@ -108,10 +115,9 @@ function load() {
plugin.id = 'plugin';
plugin.type = 'application/x-google-chrome-pdf';
plugin.addEventListener('message', handleMessage, false);
- // The pdf location is passed in the document url in the format:
- // http://<.../pdf.html>?<pdf location>.
- var url = window.location.search.substring(1);
- plugin.setAttribute('src', url);
+ // The pdf location is passed in stream details in the background page.
+ var streamDetails = chrome.extension.getBackgroundPage().popStreamDetails();
+ plugin.setAttribute('src', streamDetails.streamURL);
document.body.appendChild(plugin);
// Setup the button event listeners.
@@ -123,6 +129,9 @@ function load() {
viewport.zoomIn.bind(viewport));
$('zoom-out-button').addEventListener('click',
viewport.zoomOut.bind(viewport));
+ $('save-button-link').href = streamDetails.originalURL;
+ $('print-button').addEventListener('click', print);
+
// Setup keyboard event listeners.
document.onkeydown = function(e) {
« chrome/browser/resources/pdf/index.html ('K') | « chrome/browser/resources/pdf/index.in.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698