OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('print_preview', function() { |
| 6 /** |
| 7 * Test version of the print preview PDF plugin |
| 8 */ |
| 9 class PDFPluginStub { |
| 10 /** |
| 11 * @param {!print_preview.PreviewArea} The PreviewArea that owns this |
| 12 * plugin. |
| 13 */ |
| 14 constructor(area) { |
| 15 /** |
| 16 * @private {?Function} The callback to run when the plugin has loaded. |
| 17 */ |
| 18 this.loadCallback_ = null; |
| 19 |
| 20 /** @private {!EventTracker} The plugin stub's event tracker. */ |
| 21 this.tracker_ = new EventTracker(); |
| 22 |
| 23 // Call documentLoadComplete as soon as the preview area starts the |
| 24 // preview. |
| 25 this.tracker_.add( |
| 26 area, |
| 27 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
| 28 this.documentLoadComplete.bind(this)); |
| 29 } |
| 30 |
| 31 /** |
| 32 * @param {!Function} callback The callback to run when the plugin has |
| 33 * loaded. |
| 34 */ |
| 35 setLoadCallback(callback) { |
| 36 this.loadCallback_ = callback; |
| 37 } |
| 38 |
| 39 documentLoadComplete() { |
| 40 if (this.loadCallback_) |
| 41 this.loadCallback_(); |
| 42 } |
| 43 |
| 44 /** |
| 45 * Stubbed out since some tests result in a call. |
| 46 * @param {string} url The url to initialize the plugin to. |
| 47 * @param {boolean} color Whether the preview should be in color. |
| 48 * @param {!Array<number>} pages The pages to preview. |
| 49 * @param {boolean} modifiable Whether the source document is modifiable. |
| 50 */ |
| 51 resetPrintPreviewMode(url, color, pages, modifiable) {} |
| 52 } |
| 53 |
| 54 return {PDFPluginStub: PDFPluginStub}; |
| 55 }); |
OLD | NEW |