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 * 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 */ | 10 */ |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 type: 'sendKeyEvent', | 153 type: 'sendKeyEvent', |
154 keyCode: keyCode | 154 keyCode: keyCode |
155 }); | 155 }); |
156 }, | 156 }, |
157 }; | 157 }; |
158 | 158 |
159 /** | 159 /** |
160 * Creates a PDF viewer with a scripting interface. This is basically 1) an | 160 * 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 | 161 * 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 | 162 * interface which provides access to various features of the viewer for use |
163 * by print preview and accessbility. | 163 * by print preview and accessibility. |
164 * @param {string} src the source URL of the PDF to load initially. | 164 * @param {string} src the source URL of the PDF to load initially. |
165 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. | 165 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. |
166 */ | 166 */ |
167 function PDFCreateOutOfProcessPlugin(src) { | 167 function PDFCreateOutOfProcessPlugin(src) { |
168 var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai'; | 168 var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai'; |
169 var iframe = window.document.createElement('iframe'); | 169 var iframe = window.document.createElement('iframe'); |
170 iframe.setAttribute('src', EXTENSION_URL + '/index.html?' + src); | 170 iframe.setAttribute('src', EXTENSION_URL + '/index.html?' + src); |
171 var client = new PDFScriptingAPI(window, EXTENSION_URL); | 171 var client = new PDFScriptingAPI(window, EXTENSION_URL); |
172 | 172 |
173 // Add the functions to the iframe so that they can be called directly. | 173 // Add the functions to the iframe so that they can be called directly. |
174 iframe.setViewportChangedCallback = | 174 iframe.setViewportChangedCallback = |
175 client.setViewportChangedCallback.bind(client); | 175 client.setViewportChangedCallback.bind(client); |
176 iframe.setLoadCallback = client.setLoadCallback.bind(client); | 176 iframe.setLoadCallback = client.setLoadCallback.bind(client); |
177 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); | 177 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); |
178 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); | 178 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); |
179 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); | 179 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); |
180 return iframe; | 180 return iframe; |
181 } | 181 } |
OLD | NEW |