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 10124417a84b9d2e9776bc87b3ef70b557f8da28..0a9cf280c0e96735ef5d01b35054528c963c21de 100644 |
--- a/chrome/browser/resources/print_preview/data/destination_store.js |
+++ b/chrome/browser/resources/print_preview/data/destination_store.js |
@@ -364,6 +364,10 @@ cr.define('print_preview', function() { |
this.cloudPrintInterface_, |
cloudprint.CloudPrintInterface.EventType.PRINTER_FAILED, |
this.onCloudPrintPrinterFailed_.bind(this)); |
+ this.tracker_.add( |
+ this.cloudPrintInterface_, |
+ cloudprint.CloudPrintInterface.EventType.PROCESS_INVITE_DONE, |
+ this.onCloudPrintProcessInviteDone_.bind(this)); |
}, |
/** |
@@ -511,6 +515,13 @@ cr.define('print_preview', function() { |
} |
}, |
+ /** Initiates loading of all known destination types. */ |
+ startLoadAllDestinations: function() { |
+ this.startLoadCloudDestinations(); |
+ this.startLoadLocalDestinations(); |
+ this.startLoadPrivetDestinations(); |
+ }, |
+ |
/** |
* Wait for a privet device to be registered. |
*/ |
@@ -836,6 +847,20 @@ cr.define('print_preview', function() { |
}, |
/** |
+ * Called when printer sharing invitation was processed successfully. |
+ * @param {Event} event Contains detailed information about the invite and |
+ * newly accepted destination (if known). |
+ * @private |
+ */ |
+ onCloudPrintProcessInviteDone_: function(event) { |
+ if (event.accept && event.printer) { |
+ // Hint the destination list to promote this new destination. |
+ event.printer.isRecent = true; |
Vitaly Buka (NO REVIEWS)
2014/09/22 01:25:15
Please add metricts somewhere to count accepts and
|
+ this.insertDestination_(event.printer); |
+ } |
+ }, |
+ |
+ /** |
* Called when a Privet printer is added to the local network. |
* @param {object} event Contains information about the added printer. |
* @private |
@@ -875,9 +900,7 @@ cr.define('print_preview', function() { |
this.reset_(); |
this.isInAutoSelectMode_ = true; |
this.createLocalPdfPrintDestination_(); |
- this.startLoadLocalDestinations(); |
- this.startLoadCloudDestinations(); |
- this.startLoadPrivetDestinations(); |
+ this.startLoadAllDestinations(); |
}, |
// TODO(vitalybuka): Remove three next functions replacing Destination.id |