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

Side by Side Diff: chrome/browser/resources/print_preview/search/destination_search.js

Issue 2862203002: Print Preview: Fix data/ errors (Closed)
Patch Set: Fix destination resolver Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Component used for searching for a print destination. 9 * Component used for searching for a print destination.
10 * This is a modal dialog that allows the user to search and select a 10 * This is a modal dialog that allows the user to search and select a
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 var cloudDestinations = []; 360 var cloudDestinations = [];
361 var unregisteredCloudDestinations = []; 361 var unregisteredCloudDestinations = [];
362 362
363 var destinations = 363 var destinations =
364 this.destinationStore_.destinations(this.userInfo_.activeUser); 364 this.destinationStore_.destinations(this.userInfo_.activeUser);
365 destinations.forEach(function(destination) { 365 destinations.forEach(function(destination) {
366 if (destination.isRecent) { 366 if (destination.isRecent) {
367 recentDestinations.push(destination); 367 recentDestinations.push(destination);
368 } 368 }
369 if (destination.isLocal || 369 if (destination.isLocal ||
370 destination.origin == print_preview.Destination.Origin.DEVICE) { 370 destination.origin == print_preview.DestinationOrigin.DEVICE) {
371 localDestinations.push(destination); 371 localDestinations.push(destination);
372 } else { 372 } else {
373 if (destination.connectionStatus == 373 if (destination.connectionStatus ==
374 print_preview.Destination.ConnectionStatus.UNREGISTERED) { 374 print_preview.DestinationConnectionStatus.UNREGISTERED) {
375 unregisteredCloudDestinations.push(destination); 375 unregisteredCloudDestinations.push(destination);
376 } else { 376 } else {
377 cloudDestinations.push(destination); 377 cloudDestinations.push(destination);
378 } 378 }
379 } 379 }
380 }); 380 });
381 381
382 if (unregisteredCloudDestinations.length != 0 && 382 if (unregisteredCloudDestinations.length != 0 &&
383 !this.registerPromoShownMetricRecorded_) { 383 !this.registerPromoShownMetricRecorded_) {
384 this.metrics_.record( 384 this.metrics_.record(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 * @param {!CustomEvent} event Contains the destination needs to be setup. 583 * @param {!CustomEvent} event Contains the destination needs to be setup.
584 * @private 584 * @private
585 */ 585 */
586 onDestinationConfigureRequest_: function(event) { 586 onDestinationConfigureRequest_: function(event) {
587 var destination = event.detail.destination; 587 var destination = event.detail.destination;
588 // Cloud Print Device printers are stored in the local list 588 // Cloud Print Device printers are stored in the local list
589 // crbug.com/713831. 589 // crbug.com/713831.
590 // TODO(crbug.com/416701): Upon resolution, update this. 590 // TODO(crbug.com/416701): Upon resolution, update this.
591 var destinationItem = 591 var destinationItem =
592 (destination.isLocal || 592 (destination.isLocal ||
593 destination.origin == print_preview.Destination.Origin.DEVICE) ? 593 destination.origin == print_preview.DestinationOrigin.DEVICE) ?
594 this.localList_.getDestinationItem(destination.id) : 594 this.localList_.getDestinationItem(destination.id) :
595 this.cloudList_.getDestinationItem(destination.id); 595 this.cloudList_.getDestinationItem(destination.id);
596 assert(destinationItem != null, 596 assert(destinationItem != null,
597 'User does not select a valid destination item.'); 597 'User does not select a valid destination item.');
598 598
599 // Another printer setup is in process or the printer doesn't need to be 599 // Another printer setup is in process or the printer doesn't need to be
600 // set up. Reject the setup request directly. 600 // set up. Reject the setup request directly.
601 if (this.destinationInConfiguring_ != null || 601 if (this.destinationInConfiguring_ != null ||
602 destination.origin != print_preview.Destination.Origin.CROS || 602 destination.origin != print_preview.DestinationOrigin.CROS ||
603 destination.capabilities != null) { 603 destination.capabilities != null) {
604 destinationItem.onConfigureRequestRejected( 604 destinationItem.onConfigureRequestRejected(
605 this.destinationInConfiguring_ != null); 605 this.destinationInConfiguring_ != null);
606 } else { 606 } else {
607 destinationItem.onConfigureRequestAccepted(); 607 destinationItem.onConfigureRequestAccepted();
608 this.handleConfigureDestination_(destination); 608 this.handleConfigureDestination_(destination);
609 } 609 }
610 }, 610 },
611 611
612 /** 612 /**
613 * Called When a destination needs to be setup. 613 * Called When a destination needs to be setup.
614 * @param {!print_preview.Destination} destination The destination needs to 614 * @param {!print_preview.Destination} destination The destination needs to
615 * be setup. 615 * be setup.
616 * @private 616 * @private
617 */ 617 */
618 handleConfigureDestination_: function(destination) { 618 handleConfigureDestination_: function(destination) {
619 assert(destination.origin == print_preview.Destination.Origin.CROS, 619 assert(destination.origin == print_preview.DestinationOrigin.CROS,
620 'Only local printer on Chrome OS requires setup.'); 620 'Only local printer on Chrome OS requires setup.');
621 this.destinationInConfiguring_ = destination; 621 this.destinationInConfiguring_ = destination;
622 this.destinationStore_.resolveCrosDestination(destination).then( 622 this.destinationStore_.resolveCrosDestination(destination).then(
623 /** 623 /**
624 * @param {!print_preview.PrinterSetupResponse} response. 624 * @param {!print_preview.PrinterSetupResponse} response.
625 */ 625 */
626 function(response) { 626 function(response) {
627 this.destinationInConfiguring_ = null; 627 this.destinationInConfiguring_ = null;
628 this.localList_.getDestinationItem(destination.id) 628 this.localList_.getDestinationItem(destination.id)
629 .onConfigureResolved(response); 629 .onConfigureResolved(response);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 onWindowResize_: function() { 835 onWindowResize_: function() {
836 this.reflowLists_(); 836 this.reflowLists_();
837 } 837 }
838 }; 838 };
839 839
840 // Export 840 // Export
841 return { 841 return {
842 DestinationSearch: DestinationSearch 842 DestinationSearch: DestinationSearch
843 }; 843 };
844 }); 844 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698