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

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

Issue 582583002: Change the OOP PDF plugin to use BrowserPlugin mime type handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/manifest.json ('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 0aa437aef03c7e1747929fe50925367d29164878..cbdacca30e92bf4b9b966da0fdc70a341862d3a6 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -4,11 +4,6 @@
'use strict';
-<include src="../../../../ui/webui/resources/js/util.js">
-<include src="open_pdf_params_parser.js">
-<include src="pdf_scripting_api.js">
-<include src="viewport.js">
-
/**
* @return {number} Width of a scrollbar in pixels
*/
@@ -34,8 +29,11 @@ PDFViewer.MIN_TOOLBAR_OFFSET = 15;
/**
* Creates a new PDFViewer. There should only be one of these objects per
* document.
+ * @param {Object} streamDetails The stream object which points to the data
+ * contained in the PDF.
*/
-function PDFViewer() {
+function PDFViewer(streamDetails) {
+ this.streamDetails = streamDetails;
this.loaded = false;
// The sizer element is placed behind the plugin element to cause scrollbars
@@ -77,28 +75,6 @@ function PDFViewer() {
false);
this.sendScriptingMessage_({type: 'readyToReceive'});
- // If the viewer is started from a MIME type request, there will be a
- // 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.
- if (chrome.extension.getBackgroundPage &&
- chrome.extension.getBackgroundPage()) {
- this.streamDetails =
- chrome.extension.getBackgroundPage().popStreamDetails();
- }
-
- 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);
- this.streamDetails = {
- streamUrl: url,
- originalUrl: url,
- responseHeaders: ''
- };
- }
-
this.plugin_.setAttribute('src', this.streamDetails.originalUrl);
this.plugin_.setAttribute('stream-url', this.streamDetails.streamUrl);
var headers = '';
@@ -182,7 +158,7 @@ PDFViewer.prototype = {
position.y -= this.viewport.size.height;
this.viewport.position = position;
}
- };
+ }.bind(this);
var pageDownHandler = function() {
// Go to the next page if we are fit-to-page.
if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
@@ -193,7 +169,7 @@ PDFViewer.prototype = {
position.y += this.viewport.size.height;
this.viewport.position = position;
}
- };
+ }.bind(this);
switch (e.keyCode) {
case 32: // Space key.
@@ -573,5 +549,3 @@ PDFViewer.prototype = {
return this.viewport_;
}
};
-
-var viewer = new PDFViewer();
« no previous file with comments | « chrome/browser/resources/pdf/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698