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

Unified Diff: chrome/browser/resources/pdf/main.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/index.html ('k') | chrome/browser/resources/pdf/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/main.js
diff --git a/chrome/browser/resources/pdf/main.js b/chrome/browser/resources/pdf/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..92171567eab52358dbedf3a1e90e91b77991e7d0
--- /dev/null
+++ b/chrome/browser/resources/pdf/main.js
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+<include src="../../../../ui/webui/resources/js/util.js">
+<include src="open_pdf_params_parser.js">
+<include src="pdf.js">
+<include src="pdf_scripting_api.js">
+<include src="viewport.js">
+
+/**
+ * Global PDFViewer object, accessible for testing.
+ * @type Object
+ */
+var viewer;
+
+/**
+ * Entrypoint for starting the PDF viewer. This function obtains the details
+ * of the PDF 'stream' (the data that points to the PDF) and constructs a
+ * PDFViewer object with it.
+ */
+(function main() {
+ // If the viewer is started from the browser plugin, the view ID will be
+ // passed in which identifies the instance of the plugin.
+ var params = window.location.search.substring(1).split('=');
+ if (params.length == 2 && params[0] == 'id') {
+ var viewId = params[1];
+
+ // Send a message to the background page to obtain the stream details. It
+ // will run the callback function passed in to initialize the viewer.
+ chrome.runtime.sendMessage(
+ 'mhjfbmdgcfjbbpaeojofohoefgiehjai',
+ {viewId: viewId},
+ function(streamDetails) { viewer = new PDFViewer(streamDetails); });
+ return;
+ }
+
+ // The viewer may be started directly by passing in the URL of the PDF to load
+ // as the query string. This is used for print preview in particular. 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);
+ var streamDetails = {
+ streamUrl: url,
+ originalUrl: url,
+ responseHeaders: ''
+ };
+ viewer = new PDFViewer(streamDetails);
+})();
« no previous file with comments | « chrome/browser/resources/pdf/index.html ('k') | chrome/browser/resources/pdf/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698