Chromium Code Reviews| Index: chrome/browser/resources/print_preview/data/destination_store.js |
| diff --git a/chrome/browser/resources/print_preview/data/destination_store.js b/chrome/browser/resources/print_preview/data/destination_store.js |
| index 19499638cd577b7a46a0f850f0cfd48baaa9da5c..ec25202d0bef5b337389ecbc69e9b29282229a07 100644 |
| --- a/chrome/browser/resources/print_preview/data/destination_store.js |
| +++ b/chrome/browser/resources/print_preview/data/destination_store.js |
| @@ -595,6 +595,8 @@ cr.define('print_preview', function() { |
| this.pdfPrinterEnabled_ = !isInAppKioskMode; |
| this.systemDefaultDestinationId_ = systemDefaultDestinationId; |
| this.createLocalPdfPrintDestination_(); |
| + cr.addWebUIListener('extension-printers-added', |
| + this.onExtensionPrintersAdded_.bind(this)); |
| if (!this.appState_.isSelectedDestinationValid()) { |
| var destinationMatch = this.convertToDestinationMatch_( |
| @@ -1110,7 +1112,8 @@ cr.define('print_preview', function() { |
| clearTimeout(this.extensionSearchTimeout_); |
| this.isExtensionDestinationSearchInProgress_ = true; |
| - this.nativeLayer_.startGetExtensionDestinations(); |
| + this.nativeLayer_.getExtensionPrinters().then( |
| + this.onExtensionPrintersDone_.bind(this)); |
| cr.dispatchSimpleEvent( |
| this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); |
| this.extensionSearchTimeout_ = setTimeout( |
| @@ -1381,10 +1384,6 @@ cr.define('print_preview', function() { |
| nativeLayerEventTarget, |
| print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET, |
| this.onPrivetCapabilitiesSet_.bind(this)); |
| - this.tracker_.add( |
| - nativeLayerEventTarget, |
| - print_preview.NativeLayer.EventType.EXTENSION_PRINTERS_ADDED, |
| - this.onExtensionPrintersAdded_.bind(this)); |
| this.tracker_.add( |
| nativeLayerEventTarget, |
| print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, |
| @@ -1625,18 +1624,27 @@ cr.define('print_preview', function() { |
| /** |
| * Called when an extension responds to a getExtensionDestinations |
| * request. |
| - * @param {Object} event Contains information about list of printers |
| - * reported by the extension. |
| - * {@code done} parameter is set iff this is the final list of printers |
| - * returned as part of getExtensionDestinations request. |
| + * @param {!Array<!{extensionId: string, |
| + * extensionName: string, |
| + * id: string, |
| + * name: string, |
| + * description: (string|undefined), |
| + * provisional: (boolean|undefined)}>} printers The list |
| + * containing information about printers added by an extension. |
| * @private |
| */ |
| - onExtensionPrintersAdded_: function(event) { |
| - this.insertDestinations_(event.printers.map(function(printer) { |
| - return print_preview.ExtensionDestinationParser.parse(printer); |
| - })); |
| + onExtensionPrintersAdded_: function(printers) { |
| + this.insertDestinations_( |
| + printers.map(print_preview.ExtensionDestinationParser.parse)); |
| + }, |
| - if (event.done && this.isExtensionDestinationSearchInProgress_) { |
| + /** |
| + * Called when all extensions are done adding printers. |
| + * @param {boolean} done Whether printers are done |
|
dpapad
2017/06/07 03:20:11
Nit: Maybe update this comment to
Whether searchin
rbpotter
2017/06/07 03:46:41
Removed this comment since parameter was removed p
|
| + * @private |
| + */ |
| + onExtensionPrintersDone_: function(done) { |
| + if (done && this.isExtensionDestinationSearchInProgress_) { |
|
dpapad
2017/06/07 03:20:11
This is basically same question as in the C++ hand
rbpotter
2017/06/07 03:46:41
Done.
|
| clearTimeout(this.extensionSearchTimeout_); |
| this.endExtensionPrinterSearch_(); |
| } |