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

Side by Side Diff: chrome/browser/resources/pdf/main.js

Issue 823813002: Modify pdf_scripting_api.js to support postMessage using BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Global PDFViewer object, accessible for testing. 8 * Global PDFViewer object, accessible for testing.
9 * @type Object 9 * @type Object
10 */ 10 */
11 var viewer; 11 var viewer;
12 12
13 /** 13 /**
14 * Entrypoint for starting the PDF viewer. This function obtains the details 14 * Entrypoint for starting the PDF viewer. This function obtains the details
15 * of the PDF 'stream' (the data that points to the PDF) and constructs a 15 * of the PDF 'stream' (the data that points to the PDF) and constructs a
16 * PDFViewer object with it. 16 * PDFViewer object with it.
17 */ 17 */
18 (function main() { 18 (function main() {
19 viewer = new PDFViewer();
20
19 // If the viewer is started from the browser plugin, the view ID will be 21 // If the viewer is started from the browser plugin, the view ID will be
20 // passed in which identifies the instance of the plugin. 22 // passed in which identifies the instance of the plugin.
21 var params = window.location.search.substring(1).split('='); 23 var params = window.location.search.substring(1).split('=');
22 if (params.length == 2 && params[0] == 'id') { 24 if (params.length == 2 && params[0] == 'id') {
23 var viewId = params[1]; 25 var viewId = params[1];
24 26
25 // Send a message to the background page to obtain the stream details. It 27 // Send a message to the background page to obtain the stream details. It
26 // will run the callback function passed in to initialize the viewer. 28 // will run the callback function passed in to initialize the viewer.
27 chrome.runtime.sendMessage( 29 chrome.runtime.sendMessage(
28 'mhjfbmdgcfjbbpaeojofohoefgiehjai', 30 'mhjfbmdgcfjbbpaeojofohoefgiehjai',
29 {viewId: viewId}, 31 {viewId: viewId},
30 function(streamDetails) { viewer = new PDFViewer(streamDetails); }); 32 function(streamDetails) { viewer.init(streamDetails); });
31 return; 33 return;
32 } 34 }
33 35
34 // The viewer may be started directly by passing in the URL of the PDF to load 36 // The viewer may be started directly by passing in the URL of the PDF to load
35 // as the query string. This is used for print preview in particular. The URL 37 // as the query string. This is used for print preview in particular. The URL
36 // of this page will be of the form 38 // of this page will be of the form
37 // 'chrome-extension://<extension id>?<pdf url>'. We pull out the <pdf url> 39 // 'chrome-extension://<extension id>?<pdf url>'. We pull out the <pdf url>
38 // part here. 40 // part here.
39 var url = window.location.search.substring(1); 41 var url = window.location.search.substring(1);
40 var streamDetails = { 42 var streamDetails = {
41 streamUrl: url, 43 streamUrl: url,
42 originalUrl: url, 44 originalUrl: url,
43 responseHeaders: '', 45 responseHeaders: '',
44 embedded: window.parent != window, 46 embedded: window.parent != window,
45 tabId: -1 47 tabId: -1
46 }; 48 };
47 if (!chrome.tabs) { 49 if (!chrome.tabs) {
48 viewer = new PDFViewer(streamDetails); 50 viewer.init(streamDetails);
49 return; 51 return;
50 } 52 }
51 chrome.tabs.getCurrent(function(tab) { 53 chrome.tabs.getCurrent(function(tab) {
52 if (tab && tab.id != undefined) 54 if (tab && tab.id != undefined)
53 streamDetails.tabId = tab.id; 55 streamDetails.tabId = tab.id;
54 viewer = new PDFViewer(streamDetails); 56 viewer.init(streamDetails);
55 }); 57 });
56 })(); 58 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698