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 f2faf3fe8affb1ea5cb881212b80a6b91d639024..23f8215250aa4585abc8ba332aa525d687253bd3 100644 |
--- a/chrome/browser/resources/print_preview/data/destination_store.js |
+++ b/chrome/browser/resources/print_preview/data/destination_store.js |
@@ -177,7 +177,6 @@ cr.define('print_preview', function() { |
this.useSystemDefaultAsDefault_ = |
loadTimeData.getBoolean('useSystemDefaultPrinter'); |
- this.addEventListeners_(); |
this.reset_(); |
} |
@@ -545,6 +544,23 @@ cr.define('print_preview', function() { |
this.cloudPrintInterface_.isCloudDestinationSearchInProgress; |
}, |
+ /** |
+ * Registers the destination store for the WebUI events it responds to and |
dpapad
2017/07/07 21:12:41
Nit: Slightly confused by the syntax in this comme
rbpotter
2017/07/07 23:58:39
Done.
|
+ * adds the listeners to |listenerTracker| so that they can be |
+ * automatically removed by this tracker later. |
+ * @param {!WebUIListenerTracker} listenerTracker The tracker to add the |
+ * listeners to. |
+ */ |
+ addWebUIEventListeners: function(listenerTracker) { |
+ listenerTracker.add( |
+ 'privet-printer-added', this.onPrivetPrinterAdded_.bind(this)); |
+ listenerTracker.add( |
+ 'extension-printers-added', |
+ this.onExtensionPrintersAdded_.bind(this)); |
+ listenerTracker.add( |
+ 'reload-printer-list', this.onDestinationsReload.bind(this)); |
+ }, |
+ |
/** |
* Initializes the destination store. Sets the initially selected |
* destination. If any inserted destinations match this ID, that destination |
@@ -1179,8 +1195,8 @@ cr.define('print_preview', function() { |
* @param {?print_preview.Destination} destination Information about the |
* destination if it was resolved successfully. |
*/ |
- dispatchProvisionalDestinationResolvedEvent_: function(provisionalId, |
- destination) { |
+ dispatchProvisionalDestinationResolvedEvent_: function( |
+ provisionalId, destination) { |
var event = new Event( |
DestinationStore.EventType.PROVISIONAL_DESTINATION_RESOLVED); |
event.provisionalId = provisionalId; |
@@ -1332,18 +1348,6 @@ cr.define('print_preview', function() { |
} |
}, |
- /** |
- * Binds handlers to events. |
- * @private |
- */ |
- addEventListeners_: function() { |
- var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); |
- this.tracker_.add( |
- nativeLayerEventTarget, |
- print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, |
- this.onDestinationsReload_.bind(this)); |
- }, |
- |
/** |
* Creates a local PDF print destination. |
* @private |
@@ -1549,7 +1553,7 @@ cr.define('print_preview', function() { |
if (printer.serviceName == this.waitForRegisterDestination_ && |
!printer.isUnregistered) { |
this.waitForRegisterDestination_ = null; |
- this.onDestinationsReload_(); |
+ this.onDestinationsReload(); |
} else { |
this.insertDestinations_( |
print_preview.PrivetDestinationParser.parse(printer)); |
@@ -1617,11 +1621,10 @@ cr.define('print_preview', function() { |
}, |
/** |
- * Called from native layer after the user was requested to sign in, and did |
- * so successfully. |
- * @private |
+ * Called from print preview after the user was requested to sign in, and |
+ * did so successfully. |
*/ |
- onDestinationsReload_: function() { |
+ onDestinationsReload: function() { |
this.reset_(); |
this.autoSelectMatchingDestination_ = |
this.convertPreselectedToDestinationMatch_(); |