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

Unified Diff: chrome/browser/resources/print_preview/search/destination_search.js

Issue 2606043004: Perform printer setup on Chrome OS before selecting printer. (Closed)
Patch Set: fix nits Created 3 years, 11 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/search/destination_search.js
diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js
index ff1957341397ba17d089d6208d31120eac64daab..cc59b37ebf07538fe18838f8b5858be29346c12e 100644
--- a/chrome/browser/resources/print_preview/search/destination_search.js
+++ b/chrome/browser/resources/print_preview/search/destination_search.js
@@ -583,6 +583,35 @@ cr.define('print_preview', function() {
* @private
*/
handleOnDestinationSelect_: function(destination) {
+ if (destination.origin == print_preview.Destination.Origin.CROS &&
+ !destination.capabilities) {
+ // local printers on CrOS require setup.
+ assert(!this.printerConfigurer_);
+ this.printerConfigurer_ = new print_preview.CrosDestinationResolver(
+ this.destinationStore_, destination);
+ this.addChild(this.printerConfigurer_);
+ this.printerConfigurer_.run(this.getElement()).
+ then(
+ /**
+ * @param {!print_preview.PrinterSetupResponse} result
+ * An object containing the printerId and capabilities.
+ */
+ function(result) {
+ assert(result.printerId == destination.id);
+ destination.capabilities = result.capabilities;
+ this.handleOnDestinationSelect_(destination);
+ }.bind(this),
+ function() {
+ console.warn(
+ 'Failed to setup destination: ' + destination.id);
+ }).
+ then(function() {
+ this.removeChild(this.printerConfigurer_);
+ this.printerConfigurer_ = null;
+ }.bind(this));
+ return;
+ }
+
if (destination.isProvisional) {
assert(!this.provisionalDestinationResolver_,
'Provisional destination resolver already exists.');
@@ -594,8 +623,8 @@ cr.define('print_preview', function() {
var lastFocusedElement = document.activeElement;
this.addChild(this.provisionalDestinationResolver_);
- this.provisionalDestinationResolver_.run(this.getElement())
- .then(
+ this.provisionalDestinationResolver_.run(this.getElement()).
+ then(
/**
* @param {!print_preview.Destination} resolvedDestination
* Destination to which the provisional destination was
@@ -603,13 +632,13 @@ cr.define('print_preview', function() {
*/
function(resolvedDestination) {
this.handleOnDestinationSelect_(resolvedDestination);
- }.bind(this))
- .catch(
+ }.bind(this)).
+ catch(
function() {
console.log('Failed to resolve provisional destination: ' +
destination.id);
- })
- .then(
+ }).
+ then(
function() {
this.removeChild(this.provisionalDestinationResolver_);
this.provisionalDestinationResolver_ = null;

Powered by Google App Engine
This is Rietveld 408576698