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

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
« no previous file with comments | « chrome/browser/resources/pdf/index.in.html ('k') | 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 43770ad0a7a5fea331cfdfaf26a4e548b84e4417..075a14e4df4a20c9a9f89bdd01efc70f4cb38101 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -36,6 +36,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');
@@ -120,10 +127,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.
@@ -135,6 +141,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) {
« no previous file with comments | « 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