1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 <include src="../../../../ui/webui/resources/js/util.js">
8 <include src="open_pdf_params_parser.js">
10 <include src="pdf_scripting_api.js">
11 <include src="viewport.js">
14 * Global PDFViewer object, accessible for testing.
20 * Entrypoint for starting the PDF viewer. This function obtains the details
21 * of the PDF 'stream' (the data that points to the PDF) and constructs a
22 * PDFViewer object with it.
25 // If the viewer is started from the browser plugin, the view ID will be
26 // passed in which identifies the instance of the plugin.
27 var params = window.location.search.substring(1).split('=');
28 if (params.length == 2 && params[0] == 'id') {
29 var viewId = params[1];
31 // Send a message to the background page to obtain the stream details. It
32 // will run the callback function passed in to initialize the viewer.
33 chrome.runtime.sendMessage(
34 'mhjfbmdgcfjbbpaeojofohoefgiehjai',
36 function(streamDetails) { viewer = new PDFViewer(streamDetails); });
40 // The viewer may be started directly by passing in the URL of the PDF to load
41 // as the query string. This is used for print preview in particular. The URL
42 // of this page will be of the form
43 // 'chrome-extension://<extension id>?<pdf url>'. We pull out the <pdf url>
45 var url = window.location.search.substring(1);
51 viewer = new PDFViewer(streamDetails);