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

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

Issue 595153003: Compile print_preview, part 5: reduce down to 104 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_4
Patch Set: Created 6 years, 2 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 /** 5 /**
6 * Create a new PDFScriptingAPI. This provides a scripting interface to 6 * Create a new PDFScriptingAPI. This provides a scripting interface to
7 * the PDF viewer so that it can be customized by things like print preview. 7 * the PDF viewer so that it can be customized by things like print preview.
8 * @param {Window} window the window of the page containing the pdf viewer. 8 * @param {Window} window the window of the page containing the pdf viewer.
9 * @param {string} extensionUrl the url of the PDF extension. 9 * @param {string} extensionUrl the url of the PDF extension.
10 * @constructor
10 */ 11 */
11 function PDFScriptingAPI(window, extensionUrl) { 12 function PDFScriptingAPI(window, extensionUrl) {
12 this.extensionUrl_ = extensionUrl; 13 this.extensionUrl_ = extensionUrl;
13 this.messageQueue_ = []; 14 this.messageQueue_ = [];
14 window.addEventListener('message', function(event) { 15 window.addEventListener('message', function(event) {
15 if (event.origin != this.extensionUrl_) { 16 if (event.origin != this.extensionUrl_) {
16 console.error('Received message that was not from the extension: ' + 17 console.error('Received message that was not from the extension: ' +
17 event); 18 event);
18 return; 19 return;
19 } 20 }
20 switch (event.data.type) { 21 switch (event.data.type) {
21 case 'readyToReceive': 22 case 'readyToReceive':
22 this.setDestinationWindow(event.source); 23 this.setDestinationWindow(event.source);
23 break; 24 break;
24 case 'viewport': 25 case 'viewport':
26 event.data = /**
27 * @type {{pageX: number, pageY: number,
28 * pageWidth: number, viewportWidth: number,
29 * viewportHeight: number}}
Aleksey Shlyapnikov 2014/09/24 17:54:43 I think every field should be on its own line (jus
Vitaly Pavlenko 2014/09/24 20:39:49 Done.
30 */(event.data);
25 if (this.viewportChangedCallback_) 31 if (this.viewportChangedCallback_)
26 this.viewportChangedCallback_(event.data.pageX, 32 this.viewportChangedCallback_(event.data.pageX,
27 event.data.pageY, 33 event.data.pageY,
28 event.data.pageWidth, 34 event.data.pageWidth,
29 event.data.viewportWidth, 35 event.data.viewportWidth,
30 event.data.viewportHeight); 36 event.data.viewportHeight);
31 break; 37 break;
32 case 'documentLoaded': 38 case 'documentLoaded':
33 if (this.loadCallback_) 39 if (this.loadCallback_)
34 this.loadCallback_(); 40 this.loadCallback_();
35 break; 41 break;
36 case 'getAccessibilityJSONReply': 42 case 'getAccessibilityJSONReply':
37 if (this.accessibilityCallback_) { 43 if (this.accessibilityCallback_) {
44 event.data = /** @type {{json: string}} */(event.data);
38 this.accessibilityCallback_(event.data.json); 45 this.accessibilityCallback_(event.data.json);
39 this.accessibilityCallback_ = null; 46 this.accessibilityCallback_ = null;
40 } 47 }
41 break; 48 break;
42 } 49 }
43 }.bind(this), false); 50 }.bind(this), false);
44 } 51 }
45 52
46 PDFScriptingAPI.prototype = { 53 PDFScriptingAPI.prototype = {
47 /** 54 /**
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 /** 166 /**
160 * Creates a PDF viewer with a scripting interface. This is basically 1) an 167 * Creates a PDF viewer with a scripting interface. This is basically 1) an
161 * iframe which is navigated to the PDF viewer extension and 2) a scripting 168 * iframe which is navigated to the PDF viewer extension and 2) a scripting
162 * interface which provides access to various features of the viewer for use 169 * interface which provides access to various features of the viewer for use
163 * by print preview and accessbility. 170 * by print preview and accessbility.
164 * @param {string} src the source URL of the PDF to load initially. 171 * @param {string} src the source URL of the PDF to load initially.
165 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. 172 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer.
166 */ 173 */
167 function PDFCreateOutOfProcessPlugin(src) { 174 function PDFCreateOutOfProcessPlugin(src) {
168 var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai'; 175 var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai';
169 var iframe = window.document.createElement('iframe'); 176 var iframe = assertInstanceof(window.document.createElement('iframe'),
177 HTMLIFrameElement);
170 iframe.setAttribute('src', EXTENSION_URL + '/index.html?' + src); 178 iframe.setAttribute('src', EXTENSION_URL + '/index.html?' + src);
171 var client = new PDFScriptingAPI(window, EXTENSION_URL); 179 var client = new PDFScriptingAPI(window, EXTENSION_URL);
172 180
173 // Add the functions to the iframe so that they can be called directly. 181 // Add the functions to the iframe so that they can be called directly.
174 iframe.setViewportChangedCallback = 182 iframe.setViewportChangedCallback =
175 client.setViewportChangedCallback.bind(client); 183 client.setViewportChangedCallback.bind(client);
176 iframe.setLoadCallback = client.setLoadCallback.bind(client); 184 iframe.setLoadCallback = client.setLoadCallback.bind(client);
177 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); 185 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client);
178 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); 186 iframe.loadPreviewPage = client.loadPreviewPage.bind(client);
179 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); 187 iframe.sendKeyEvent = client.sendKeyEvent.bind(client);
180 return iframe; 188 return iframe;
181 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698