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 |
253 /** | 255 /** |
254 * Creates a PDF viewer with a scripting interface. This is basically 1) an | 256 * Creates a PDF viewer with a scripting interface. This is basically 1) an |
255 * iframe which is navigated to the PDF viewer extension and 2) a scripting | 257 * iframe which is navigated to the PDF viewer extension and 2) a scripting |
256 * interface which provides access to various features of the viewer for use | 258 * interface which provides access to various features of the viewer for use |
257 * by print preview and accessibility. | 259 * by print preview and accessibility. |
258 * @param {string} src the source URL of the PDF to load initially. | 260 * @param {string} src the source URL of the PDF to load initially. |
259 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. | 261 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. |
260 */ | 262 */ |
261 function PDFCreateOutOfProcessPlugin(src) { | 263 function PDFCreateOutOfProcessPlugin(src) { |
262 var iframe = window.document.createElement('iframe'); | 264 var iframe = window.document.createElement('iframe'); |
| 265 var isMac = cr.isMac ? IS_MAC_PARAM : ''; |
263 iframe.setAttribute( | 266 iframe.setAttribute( |
264 'src', | 267 'src', |
265 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + src); | 268 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + |
| 269 isMac + src); |
266 // Prevent the frame from being tab-focusable. | 270 // Prevent the frame from being tab-focusable. |
267 iframe.setAttribute('tabindex', '-1'); | 271 iframe.setAttribute('tabindex', '-1'); |
268 var client = new PDFScriptingAPI(window); | 272 var client = new PDFScriptingAPI(window); |
269 iframe.onload = function() { | 273 iframe.onload = function() { |
270 client.setPlugin(iframe.contentWindow); | 274 client.setPlugin(iframe.contentWindow); |
271 }; | 275 }; |
272 // Add the functions to the iframe so that they can be called directly. | 276 // Add the functions to the iframe so that they can be called directly. |
273 iframe.setViewportChangedCallback = | 277 iframe.setViewportChangedCallback = |
274 client.setViewportChangedCallback.bind(client); | 278 client.setViewportChangedCallback.bind(client); |
275 iframe.setLoadCallback = client.setLoadCallback.bind(client); | 279 iframe.setLoadCallback = client.setLoadCallback.bind(client); |
276 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); | 280 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); |
277 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); | 281 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); |
278 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); | 282 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); |
279 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); | 283 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); |
280 return iframe; | 284 return iframe; |
281 } | 285 } |
OLD | NEW |