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

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

Issue 10450022: Print Preview Print Destination Search Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reduces size of search image. Created 8 years, 7 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
Index: chrome/browser/resources/print_preview/data/print_ticket_store.js
diff --git a/chrome/browser/resources/print_preview/data/print_ticket_store.js b/chrome/browser/resources/print_preview/data/print_ticket_store.js
index e2007984514961e5b5f1d6827e253ce8b936f37b..c1c95276c5f1fd02a00257392c5586bace96a83b 100644
--- a/chrome/browser/resources/print_preview/data/print_ticket_store.js
+++ b/chrome/browser/resources/print_preview/data/print_ticket_store.js
@@ -69,7 +69,7 @@ cr.define('print_preview', function() {
* @private
*/
this.collate_ =
- new print_preview.ticket_items.Collate(this.capabilitiesHolder_);
+ new print_preview.ticket_items.Collate(this.capabilitiesHolder_);
/**
* Color ticket item.
@@ -142,6 +142,15 @@ cr.define('print_preview', function() {
*/
this.fitToPage_ = new print_preview.ticket_items.FitToPage(
this.documentInfo_, this.destinationStore_);
+
+ /**
+ * Keeps track of event listeners for the print ticket store.
+ * @type {!EventTracker}
+ * @private
+ */
+ this.tracker_ = new EventTracker();
+
+ this.addEventListeners_();
};
/**
@@ -276,28 +285,6 @@ cr.define('print_preview', function() {
}
},
- /**
- * Updates the capabilities of the destination the print ticket is for.
- * Dispatches a CAPABILITIES_CHANGE event.
- * @param {!print_preview.ChromiumCapabilities} caps New capabilities.
- */
- updateDestinationCapabilities: function(caps) {
- var isFirstUpdate = this.capabilitiesHolder_.get() == null;
- this.capabilitiesHolder_.set(caps);
- if (isFirstUpdate) {
- cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE);
- } else {
- this.customMargins_.updateValue(null);
- if (this.marginsType_.getValue() ==
- print_preview.ticket_items.MarginsType.Value.CUSTOM) {
- this.marginsType_.updateValue(
- print_preview.ticket_items.MarginsType.Value.DEFAULT);
- }
- cr.dispatchSimpleEvent(
- this, PrintTicketStore.EventType.CAPABILITIES_CHANGE);
- }
- },
-
/** @return {boolean} Whether the ticket store has the copies capability. */
hasCopiesCapability: function() {
return this.copies_.isCapabilityAvailable();
@@ -619,6 +606,40 @@ cr.define('print_preview', function() {
this.getMarginsType() !=
print_preview.ticket_items.MarginsType.Value.CUSTOM ||
this.isCustomMarginsValid());
+ },
+
+ /**
+ * Adds event listeners for the print ticket store.
+ * @private
+ */
+ addEventListeners_: function() {
+ this.tracker_.add(
+ this.destinationStore_,
+ print_preview.DestinationStore.EventType.
+ SELECTED_DESTINATION_CAPABILITIES_READY,
+ this.onSelectedDestinationCapabilitiesReady_.bind(this));
+ },
+
+ /**
+ * Called when the capabilities of the selected destination are ready.
+ * @private
+ */
+ onSelectedDestinationCapabilitiesReady_: function() {
+ var caps = this.destinationStore_.selectedDestination.capabilities;
+ var isFirstUpdate = this.capabilitiesHolder_.get() == null;
+ this.capabilitiesHolder_.set(caps);
+ if (isFirstUpdate) {
+ cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE);
+ } else {
+ this.customMargins_.updateValue(null);
+ if (this.marginsType_.getValue() ==
+ print_preview.ticket_items.MarginsType.Value.CUSTOM) {
+ this.marginsType_.updateValue(
+ print_preview.ticket_items.MarginsType.Value.DEFAULT);
+ }
+ cr.dispatchSimpleEvent(
+ this, PrintTicketStore.EventType.CAPABILITIES_CHANGE);
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698