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

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

Issue 2760753002: [CUPS] Implement the local CUPS printer setup waiting UI. (Closed)
Patch Set: . Created 3 years, 9 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 */ 80 */
81 this.searchBox_ = new print_preview.SearchBox( 81 this.searchBox_ = new print_preview.SearchBox(
82 loadTimeData.getString('searchBoxPlaceholder')); 82 loadTimeData.getString('searchBoxPlaceholder'));
83 this.addChild(this.searchBox_); 83 this.addChild(this.searchBox_);
84 84
85 /** 85 /**
86 * Destination list containing recent destinations. 86 * Destination list containing recent destinations.
87 * @type {!print_preview.DestinationList} 87 * @type {!print_preview.DestinationList}
88 * @private 88 * @private
89 */ 89 */
90 this.recentList_ = new print_preview.RecentDestinationList(this); 90 this.recentList_ =
91 new print_preview.RecentDestinationList(this, this.destinationStore_);
91 this.addChild(this.recentList_); 92 this.addChild(this.recentList_);
92 93
93 /** 94 /**
94 * Destination list containing local destinations. 95 * Destination list containing local destinations.
95 * @type {!print_preview.DestinationList} 96 * @type {!print_preview.DestinationList}
96 * @private 97 * @private
97 */ 98 */
98 this.localList_ = new print_preview.DestinationList( 99 this.localList_ = new print_preview.DestinationList(
99 this, 100 this,
101 this.destinationStore_,
100 loadTimeData.getString('localDestinationsTitle'), 102 loadTimeData.getString('localDestinationsTitle'),
101 loadTimeData.getBoolean('showLocalManageButton') ? 103 loadTimeData.getBoolean('showLocalManageButton') ?
102 loadTimeData.getString('manage') : null); 104 loadTimeData.getString('manage') : null);
103 this.addChild(this.localList_); 105 this.addChild(this.localList_);
104 106
105 /** 107 /**
106 * Destination list containing cloud destinations. 108 * Destination list containing cloud destinations.
107 * @type {!print_preview.DestinationList} 109 * @type {!print_preview.DestinationList}
108 * @private 110 * @private
109 */ 111 */
110 this.cloudList_ = new print_preview.CloudDestinationList(this); 112 this.cloudList_ =
113 new print_preview.CloudDestinationList(this, this.destinationStore_);
111 this.addChild(this.cloudList_); 114 this.addChild(this.cloudList_);
112 }; 115 };
113 116
114 /** 117 /**
115 * Event types dispatched by the component. 118 * Event types dispatched by the component.
116 * @enum {string} 119 * @enum {string}
117 */ 120 */
118 DestinationSearch.EventType = { 121 DestinationSearch.EventType = {
119 // Dispatched when user requests to sign-in into another Google account. 122 // Dispatched when user requests to sign-in into another Google account.
120 ADD_ACCOUNT: 'print_preview.DestinationSearch.ADD_ACCOUNT', 123 ADD_ACCOUNT: 'print_preview.DestinationSearch.ADD_ACCOUNT',
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 }, 579 },
577 580
578 /** 581 /**
579 * Called when a destination is selected. Clears the search and hides the 582 * Called when a destination is selected. Clears the search and hides the
580 * widget. If The destination is provisional, it runs provisional 583 * widget. If The destination is provisional, it runs provisional
581 * destination resolver first. 584 * destination resolver first.
582 * @param {!print_preview.Destination} destination The selected destination. 585 * @param {!print_preview.Destination} destination The selected destination.
583 * @private 586 * @private
584 */ 587 */
585 handleOnDestinationSelect_: function(destination) { 588 handleOnDestinationSelect_: function(destination) {
586 if (destination.origin == print_preview.Destination.Origin.CROS &&
587 !destination.capabilities) {
588 // local printers on CrOS require setup.
589 assert(!this.printerConfigurer_);
590 this.printerConfigurer_ = new print_preview.CrosDestinationResolver(
591 this.destinationStore_, destination);
592 this.addChild(this.printerConfigurer_);
593 this.printerConfigurer_.run(this.getElement()).
594 then(
595 /**
596 * @param {!print_preview.PrinterSetupResponse} result
597 * An object containing the printerId and capabilities.
598 */
599 function(result) {
600 assert(result.printerId == destination.id);
601 destination.capabilities = result.capabilities;
602 this.handleOnDestinationSelect_(destination);
603 }.bind(this),
604 function() {
605 console.warn(
606 'Failed to setup destination: ' + destination.id);
607 }).
608 then(function() {
609 this.removeChild(this.printerConfigurer_);
610 this.printerConfigurer_ = null;
611 }.bind(this));
612 return;
613 }
614
615 if (destination.isProvisional) { 589 if (destination.isProvisional) {
616 assert(!this.provisionalDestinationResolver_, 590 assert(!this.provisionalDestinationResolver_,
617 'Provisional destination resolver already exists.'); 591 'Provisional destination resolver already exists.');
618 this.provisionalDestinationResolver_ = 592 this.provisionalDestinationResolver_ =
619 print_preview.ProvisionalDestinationResolver.create( 593 print_preview.ProvisionalDestinationResolver.create(
620 this.destinationStore_, destination); 594 this.destinationStore_, destination);
621 assert(!!this.provisionalDestinationResolver_, 595 assert(!!this.provisionalDestinationResolver_,
622 'Unable to create provisional destination resolver'); 596 'Unable to create provisional destination resolver');
623 597
624 var lastFocusedElement = document.activeElement; 598 var lastFocusedElement = document.activeElement;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 onWindowResize_: function() { 767 onWindowResize_: function() {
794 this.reflowLists_(); 768 this.reflowLists_();
795 } 769 }
796 }; 770 };
797 771
798 // Export 772 // Export
799 return { 773 return {
800 DestinationSearch: DestinationSearch 774 DestinationSearch: DestinationSearch
801 }; 775 };
802 }); 776 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698