| 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 dafd6553b237f3a68c0e279e159bd63c44167ed7..484393c9d9a3582c59a15b320f831670ef92194b 100644
|
| --- a/chrome/browser/resources/print_preview/data/destination_store.js
|
| +++ b/chrome/browser/resources/print_preview/data/destination_store.js
|
| @@ -280,6 +280,16 @@ cr.define('print_preview', function() {
|
| */
|
| this.waitForRegisterDestination_ = null;
|
|
|
| + /**
|
| + * Local destinations are CROS destinations on ChromeOS because they require
|
| + * extra setup.
|
| + * @type{!print_preview.Destination.Origin}
|
| + * @private
|
| + */
|
| + this.platformOrigin_ = cr.isChromeOS ?
|
| + print_preview.Destination.Origin.CROS :
|
| + print_preview.Destination.Origin.LOCAL;
|
| +
|
| this.addEventListeners_();
|
| this.reset_();
|
| };
|
| @@ -301,7 +311,9 @@ cr.define('print_preview', function() {
|
| CACHED_SELECTED_DESTINATION_INFO_READY:
|
| 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY',
|
| SELECTED_DESTINATION_CAPABILITIES_READY:
|
| - 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY'
|
| + 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY',
|
| + PRINTER_CONFIGURED:
|
| + 'print_preview.DestinationStore.PRINTER_CONFIGURED',
|
| };
|
|
|
| /**
|
| @@ -690,8 +702,8 @@ cr.define('print_preview', function() {
|
| return;
|
| }
|
|
|
| - var origin = print_preview.Destination.Origin.LOCAL;
|
| - var id = this.systemDefaultDestinationId_;
|
| + var origin = null;
|
| + var id = '';
|
| var account = '';
|
| var name = '';
|
| var capabilities = null;
|
| @@ -735,7 +747,13 @@ cr.define('print_preview', function() {
|
| }
|
| }
|
| if (foundDestination) return;
|
| +
|
| // Try the system default
|
| + id = this.systemDefaultDestinationId_;
|
| + origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ?
|
| + print_preview.Destination.Origin.LOCAL :
|
| + this.platformOrigin_;
|
| + account = '';
|
| var candidate =
|
| this.destinationMap_[this.getDestinationKey_(origin, id, account)];
|
| if (candidate != null) {
|
| @@ -776,7 +794,8 @@ cr.define('print_preview', function() {
|
| this.autoSelectMatchingDestination_ =
|
| this.createExactDestinationMatch_(origin, id);
|
|
|
| - if (origin == print_preview.Destination.Origin.LOCAL) {
|
| + if (origin == print_preview.Destination.Origin.LOCAL ||
|
| + origin == print_preview.Destination.Origin.CROS) {
|
| this.nativeLayer_.startGetLocalDestinationCapabilities(id);
|
| return true;
|
| }
|
| @@ -847,7 +866,9 @@ cr.define('print_preview', function() {
|
| this.autoSelectMatchingDestination_ = destinationMatch;
|
|
|
| if (destinationMatch.matchOrigin(
|
| - print_preview.Destination.Origin.LOCAL)) {
|
| + print_preview.Destination.Origin.LOCAL) ||
|
| + destinationMatch.matchOrigin(
|
| + print_preview.Destination.Origin.CROS)) {
|
| this.startLoadLocalDestinations();
|
| }
|
| if (destinationMatch.matchOrigin(
|
| @@ -902,6 +923,7 @@ cr.define('print_preview', function() {
|
| origins.push(print_preview.Destination.Origin.LOCAL);
|
| origins.push(print_preview.Destination.Origin.PRIVET);
|
| origins.push(print_preview.Destination.Origin.EXTENSION);
|
| + origins.push(print_preview.Destination.Origin.CROS);
|
| }
|
| if (isCloud) {
|
| origins.push(print_preview.Destination.Origin.COOKIES);
|
| @@ -947,7 +969,7 @@ cr.define('print_preview', function() {
|
| }
|
| if (this.systemDefaultDestinationId_) {
|
| return this.createExactDestinationMatch_(
|
| - print_preview.Destination.Origin.LOCAL,
|
| + this.platformOrigin_,
|
| this.systemDefaultDestinationId_);
|
| }
|
| return null;
|
| @@ -1083,6 +1105,10 @@ cr.define('print_preview', function() {
|
| }
|
| },
|
|
|
| + resolveCrosDestination: function(destination) {
|
| + this.nativeLayer_.setupPrinter(destination.id);
|
| + },
|
| +
|
| /**
|
| * Attempts to resolve a provisional destination.
|
| * @param {!print_preview.Destination} destinaion Provisional destination
|
| @@ -1119,9 +1145,9 @@ cr.define('print_preview', function() {
|
| if (this.autoSelectMatchingDestination_ &&
|
| !this.autoSelectMatchingDestination_.matchIdAndOrigin(
|
| this.systemDefaultDestinationId_,
|
| - print_preview.Destination.Origin.LOCAL)) {
|
| + this.plaformOrigin_)) {
|
| if (this.fetchPreselectedDestination_(
|
| - print_preview.Destination.Origin.LOCAL,
|
| + this.platformOrigin_,
|
| this.systemDefaultDestinationId_,
|
| '' /*account*/,
|
| '' /*name*/,
|
| @@ -1272,6 +1298,20 @@ cr.define('print_preview', function() {
|
| },
|
|
|
| /**
|
| + * Handle the result of a PRINTER_SETUP request.
|
| + * @param {!Event} evt event carrying the results.
|
| + * @private
|
| + */
|
| + handleCrosDestinationResolved_: function(evt) {
|
| + var event = new Event(
|
| + DestinationStore.EventType.PRINTER_CONFIGURED);
|
| + event.printerId = evt.printerId;
|
| + event.capabilities = evt.capabilities;
|
| + event.success = evt.success;
|
| + this.dispatchEvent(event);
|
| + },
|
| +
|
| + /**
|
| * Inserts {@code destination} to the data store and dispatches a
|
| * DESTINATIONS_INSERTED event.
|
| * @param {!print_preview.Destination} destination Print destination to
|
| @@ -1456,6 +1496,10 @@ cr.define('print_preview', function() {
|
| this.nativeLayer_,
|
| print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED,
|
| this.handleProvisionalDestinationResolved_.bind(this));
|
| + this.tracker_.add(
|
| + this.nativeLayer_,
|
| + print_preview.NativeLayer.EventType.PRINTER_SETUP,
|
| + this.handleCrosDestinationResolved_.bind(this));
|
| },
|
|
|
| /**
|
| @@ -1524,8 +1568,13 @@ cr.define('print_preview', function() {
|
| var destinationId = event.settingsInfo['printerId'];
|
| var printerName = event.settingsInfo['printerName'];
|
| var printerDescription = event.settingsInfo['printerDescription'];
|
| + // PDF is special since we don't need to query the device for
|
| + // capabilities.
|
| + var origin = destinationId ==
|
| + print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ?
|
| + print_preview.Destination.Origin.LOCAL : this.platformOrigin_;
|
| var key = this.getDestinationKey_(
|
| - print_preview.Destination.Origin.LOCAL,
|
| + origin,
|
| destinationId,
|
| '');
|
| var destination = this.destinationMap_[key];
|
|
|