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

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

Issue 275333004: Pass response headers to the PDF plugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 1e6938f374b5699ba2ae158649902e5addbe85db..5a24a6b384380b89bb0df1d33bb5a30298ec173a 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -70,39 +70,46 @@ function PDFViewer() {
// background page and stream details object with the details of the request.
// Otherwise, we take the query string of the URL to indicate the URL of the
// PDF to load. This is used for print preview in particular.
- var streamDetails;
if (chrome.extension.getBackgroundPage &&
chrome.extension.getBackgroundPage()) {
- streamDetails = chrome.extension.getBackgroundPage().popStreamDetails();
+ this.streamDetails =
+ chrome.extension.getBackgroundPage().popStreamDetails();
}
- if (!streamDetails) {
+ if (!this.streamDetails) {
// The URL of this page will be of the form
// "chrome-extension://<extension id>?<pdf url>". We pull out the <pdf url>
// part here.
var url = window.location.search.substring(1);
- streamDetails = {
+ this.streamDetails = {
streamUrl: url,
- originalUrl: url
+ originalUrl: url,
+ responseHeaders: ''
};
}
- this.plugin_.setAttribute('src', streamDetails.streamUrl);
+ this.plugin_.setAttribute('src', this.streamDetails.originalUrl);
+ this.plugin_.setAttribute('stream-url', this.streamDetails.streamUrl);
+ var headers = '';
+ for (var header in this.streamDetails.responseHeaders) {
+ headers += header + ': ' +
Lei Zhang 2014/05/22 00:13:20 Are we likely to run into any parsing problems wit
+ this.streamDetails.responseHeaders[header] + '\n';
+ }
+ this.plugin_.setAttribute('headers', headers);
+
if (window.top == window)
this.plugin_.setAttribute('full-frame', '');
document.body.appendChild(this.plugin_);
- this.setupEventListeners_(streamDetails);
+ this.setupEventListeners_();
}
PDFViewer.prototype = {
/**
* @private
* Sets up event listeners for key shortcuts and also the UI buttons.
- * @param {Object} streamDetails the details of the original HTTP request for
- * the PDF.
*/
- setupEventListeners_: function(streamDetails) {
+ setupEventListeners_: function() {
// Setup the button event listeners.
$('fit-to-width-button').addEventListener('click',
this.viewport_.fitToWidth.bind(this.viewport_));
@@ -112,7 +119,7 @@ PDFViewer.prototype = {
this.viewport_.zoomIn.bind(this.viewport_));
$('zoom-out-button').addEventListener('click',
this.viewport_.zoomOut.bind(this.viewport_));
- $('save-button-link').href = streamDetails.originalUrl;
+ $('save-button-link').href = this.streamDetails.originalUrl;
$('print-button').addEventListener('click', this.print_.bind(this));
// Setup keyboard event listeners.
@@ -287,6 +294,9 @@ PDFViewer.prototype = {
this.progressBar_.text = message.data.loadingString;
this.errorScreen_.text = message.data.loadFailedString;
break;
+ case 'cancelStreamUrl':
+ chrome.streamsPrivate.abort(this.streamDetails.streamUrl);
+ break;
}
},
« 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