Chromium Code Reviews| Index: chrome/test/data/webui/print_preview/plugin_stub.js |
| diff --git a/chrome/test/data/webui/print_preview/plugin_stub.js b/chrome/test/data/webui/print_preview/plugin_stub.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..999fbbb968ca78449ce6845e0aaeaf7ab80398f4 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/print_preview/plugin_stub.js |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('print_preview', function() { |
| + /** |
| + * Test version of the print preview PDF plugin |
| + */ |
| + class PDFPluginStub { |
| + /** |
| + * @param {!print_preview.PreviewArea} The PreviewArea that owns this |
| + * plugin. |
| + */ |
| + constructor(area) { |
| + /** |
| + * @private {?Function} The callback to run when the plugin has loaded. |
| + */ |
| + this.loadCallback_ = null; |
| + |
| + /** @private {!EventTracker} The plugin stub's event tracker. */ |
| + this.tracker_ = new EventTracker(); |
| + |
| + // Call documentLoadComplete as soon as the preview area starts the |
| + // preview. |
| + this.tracker_.add( |
| + area, |
| + print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
| + this.documentLoadComplete.bind(this)); |
| + } |
| + |
| + /** |
| + * @param {?Function} callback The callback to run when the plugin has |
|
dpapad
2017/07/06 16:42:24
Should we ever be calling setLoadCallback(null)? I
rbpotter
2017/07/06 19:47:29
Done. I was thinking maybe we would want to clear
|
| + * loaded. |
| + */ |
| + setLoadCallback(callback) { |
| + this.loadCallback_ = callback; |
| + } |
| + |
| + documentLoadComplete() { |
| + if (this.loadCallback_) |
| + this.loadCallback_(); |
| + } |
| + |
| + /** |
| + * Stubbed out since some tests result in a call. |
| + * @param {string} url The url to initialize the plugin to. |
| + * @param {boolean} color Whether the preview should be in color. |
| + * @param {!Array<number>} pages The pages to preview. |
| + * @param {boolean} modifiable Whether the source document is modifiable. |
| + */ |
| + resetPrintPreviewMode(url, color, pages, modifiable) {} |
| + } |
| + |
| + return {PDFPluginStub: PDFPluginStub}; |
| +}); |