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..82d10a0c45fde07ae10ffa8d3e8a7cf0ab0cd56c 100644 |
--- a/chrome/browser/resources/print_preview/data/destination_store.js |
+++ b/chrome/browser/resources/print_preview/data/destination_store.js |
@@ -1110,7 +1110,11 @@ cr.define('print_preview', function() { |
clearTimeout(this.extensionSearchTimeout_); |
this.isExtensionDestinationSearchInProgress_ = true; |
- this.nativeLayer_.startGetExtensionDestinations(); |
+ |
+ cr.addWebUIListener('extension-printers-added', |
+ this.onExtensionPrintersAdded_.bind(this)); |
+ this.nativeLayer_.getExtensionPrinters().then( |
+ this.onExtensionPrintersDone_.bind(this)); |
cr.dispatchSimpleEvent( |
this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); |
this.extensionSearchTimeout_ = setTimeout( |
@@ -1381,10 +1385,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 +1625,28 @@ 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, |
dpapad
2017/06/03 01:00:00
!Array
It does not seem that the function expects
rbpotter
2017/06/03 01:52:39
Done.
|
+ * 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) { |
+ onExtensionPrintersAdded_: function(printers) { |
+ this.insertDestinations_(printers.map(function(printer) { |
dpapad
2017/06/03 01:00:00
Nit: I think this is equivalent to the shorter
th
rbpotter
2017/06/03 01:52:40
Done.
|
return print_preview.ExtensionDestinationParser.parse(printer); |
})); |
+ }, |
- if (event.done && this.isExtensionDestinationSearchInProgress_) { |
+ /** |
+ * Called when all extensions are done adding printers. |
+ * @param {boolean} done Whether printers are done |
+ * @private |
+ */ |
+ onExtensionPrintersDone_: function(done) { |
+ if (done && this.isExtensionDestinationSearchInProgress_) { |
clearTimeout(this.extensionSearchTimeout_); |
this.endExtensionPrinterSearch_(); |
} |