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..700d0d3adbe71e7c6e6d9717cc439702a0962af4 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,22 @@ cr.define('print_preview', function() { |
this.cloudPrintInterface_.isCloudDestinationSearchInProgress; |
}, |
+ /** |
+ * Starts listening for relevant WebUI events and adds the listeners to |
+ * |listenerTracker|. |listenerTracker| is responsible for removing the |
+ * listeners when necessary. |
+ * @param {!WebUIListenerTracker} listenerTracker |
+ */ |
+ 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 +1194,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 +1347,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 +1552,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 +1620,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_(); |