OLD | NEW |
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 * Turn a dictionary received from postMessage into a key event. | 6 * Turn a dictionary received from postMessage into a key event. |
7 * @param {Object} dict A dictionary representing the key event. | 7 * @param {Object} dict A dictionary representing the key event. |
8 * @return {Event} A key event. | 8 * @return {Event} A key event. |
9 */ | 9 */ |
10 function DeserializeKeyEvent(dict) { | 10 function DeserializeKeyEvent(dict) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 * @param {Event} keyEvent the key event to send to the extension. | 243 * @param {Event} keyEvent the key event to send to the extension. |
244 */ | 244 */ |
245 sendKeyEvent: function(keyEvent) { | 245 sendKeyEvent: function(keyEvent) { |
246 this.sendMessage_({ | 246 this.sendMessage_({ |
247 type: 'sendKeyEvent', | 247 type: 'sendKeyEvent', |
248 keyEvent: SerializeKeyEvent(keyEvent) | 248 keyEvent: SerializeKeyEvent(keyEvent) |
249 }); | 249 }); |
250 }, | 250 }, |
251 }; | 251 }; |
252 | 252 |
253 var IS_MAC_PARAM = 'isMac&'; | |
254 | |
255 /** | 253 /** |
256 * Creates a PDF viewer with a scripting interface. This is basically 1) an | 254 * Creates a PDF viewer with a scripting interface. This is basically 1) an |
257 * iframe which is navigated to the PDF viewer extension and 2) a scripting | 255 * iframe which is navigated to the PDF viewer extension and 2) a scripting |
258 * interface which provides access to various features of the viewer for use | 256 * interface which provides access to various features of the viewer for use |
259 * by print preview and accessibility. | 257 * by print preview and accessibility. |
260 * @param {string} src the source URL of the PDF to load initially. | 258 * @param {string} src the source URL of the PDF to load initially. |
261 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. | 259 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. |
262 */ | 260 */ |
263 function PDFCreateOutOfProcessPlugin(src) { | 261 function PDFCreateOutOfProcessPlugin(src) { |
264 var iframe = window.document.createElement('iframe'); | 262 var iframe = window.document.createElement('iframe'); |
265 var isMac = cr.isMac ? IS_MAC_PARAM : ''; | |
266 iframe.setAttribute( | 263 iframe.setAttribute( |
267 'src', | 264 'src', |
268 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + | 265 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + src); |
269 isMac + src); | |
270 // Prevent the frame from being tab-focusable. | 266 // Prevent the frame from being tab-focusable. |
271 iframe.setAttribute('tabindex', '-1'); | 267 iframe.setAttribute('tabindex', '-1'); |
272 var client = new PDFScriptingAPI(window); | 268 var client = new PDFScriptingAPI(window); |
273 iframe.onload = function() { | 269 iframe.onload = function() { |
274 client.setPlugin(iframe.contentWindow); | 270 client.setPlugin(iframe.contentWindow); |
275 }; | 271 }; |
276 // Add the functions to the iframe so that they can be called directly. | 272 // Add the functions to the iframe so that they can be called directly. |
277 iframe.setViewportChangedCallback = | 273 iframe.setViewportChangedCallback = |
278 client.setViewportChangedCallback.bind(client); | 274 client.setViewportChangedCallback.bind(client); |
279 iframe.setLoadCallback = client.setLoadCallback.bind(client); | 275 iframe.setLoadCallback = client.setLoadCallback.bind(client); |
280 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); | 276 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); |
281 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); | 277 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); |
282 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); | 278 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); |
283 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); | 279 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); |
284 return iframe; | 280 return iframe; |
285 } | 281 } |
OLD | NEW |