Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: chrome/browser/resources/print_preview/data/destination_store.js

Issue 2969383003: Print Preview: Finish removing global Javascript functions. (Closed)
Patch Set: Fix test Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/native_layer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_();
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/native_layer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698