OLD | NEW |
---|---|
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 * A data store that stores destinations and dispatches events when the data | 9 * A data store that stores destinations and dispatches events when the data |
10 * store changes. | 10 * store changes. |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 } | 478 } |
479 }, | 479 }, |
480 | 480 |
481 /** Initiates loading of privet print destinations. */ | 481 /** Initiates loading of privet print destinations. */ |
482 startLoadPrivetDestinations: function() { | 482 startLoadPrivetDestinations: function() { |
483 if (!this.hasLoadedAllPrivetDestinations_) { | 483 if (!this.hasLoadedAllPrivetDestinations_) { |
484 this.isPrivetDestinationSearchInProgress_ = true; | 484 this.isPrivetDestinationSearchInProgress_ = true; |
485 this.nativeLayer_.startGetPrivetDestinations(); | 485 this.nativeLayer_.startGetPrivetDestinations(); |
486 cr.dispatchSimpleEvent( | 486 cr.dispatchSimpleEvent( |
487 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); | 487 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); |
488 if (this.privetDestinationSearchInProgress_) | |
tbarzic
2015/02/02 20:19:17
oops, this should go before we set this.privetDest
| |
489 clearTimeout(this.privetSearchTimeout_); | |
488 this.privetSearchTimeout_ = setTimeout( | 490 this.privetSearchTimeout_ = setTimeout( |
489 this.endPrivetPrinterSearch_.bind(this), | 491 this.endPrivetPrinterSearch_.bind(this), |
490 DestinationStore.PRIVET_SEARCH_DURATION_); | 492 DestinationStore.PRIVET_SEARCH_DURATION_); |
491 } | 493 } |
492 }, | 494 }, |
493 | 495 |
494 /** | 496 /** |
495 * Initiates loading of cloud destinations. | 497 * Initiates loading of cloud destinations. |
496 * @param {print_preview.Destination.Origin=} opt_origin Search destinations | 498 * @param {print_preview.Destination.Origin=} opt_origin Search destinations |
497 * for the specified origin only. | 499 * for the specified origin only. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 /** | 708 /** |
707 * Resets the state of the destination store to its initial state. | 709 * Resets the state of the destination store to its initial state. |
708 * @private | 710 * @private |
709 */ | 711 */ |
710 reset_: function() { | 712 reset_: function() { |
711 this.destinations_ = []; | 713 this.destinations_ = []; |
712 this.destinationMap_ = {}; | 714 this.destinationMap_ = {}; |
713 this.selectDestination(null); | 715 this.selectDestination(null); |
714 this.loadedCloudOrigins_ = {}; | 716 this.loadedCloudOrigins_ = {}; |
715 this.hasLoadedAllLocalDestinations_ = false; | 717 this.hasLoadedAllLocalDestinations_ = false; |
718 this.hasLoadedAllPrivetDestinations_ = false; | |
716 | 719 |
717 clearTimeout(this.autoSelectTimeout_); | 720 clearTimeout(this.autoSelectTimeout_); |
718 this.autoSelectTimeout_ = setTimeout( | 721 this.autoSelectTimeout_ = setTimeout( |
719 this.selectDefaultDestination_.bind(this), | 722 this.selectDefaultDestination_.bind(this), |
720 DestinationStore.AUTO_SELECT_TIMEOUT_); | 723 DestinationStore.AUTO_SELECT_TIMEOUT_); |
721 }, | 724 }, |
722 | 725 |
723 /** | 726 /** |
724 * Called when the local destinations have been got from the native layer. | 727 * Called when the local destinations have been got from the native layer. |
725 * @param {Event} event Contains the local destinations. | 728 * @param {Event} event Contains the local destinations. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 return id == this.appState_.selectedDestinationId && | 958 return id == this.appState_.selectedDestinationId && |
956 origin == this.appState_.selectedDestinationOrigin; | 959 origin == this.appState_.selectedDestinationOrigin; |
957 } | 960 } |
958 }; | 961 }; |
959 | 962 |
960 // Export | 963 // Export |
961 return { | 964 return { |
962 DestinationStore: DestinationStore | 965 DestinationStore: DestinationStore |
963 }; | 966 }; |
964 }); | 967 }); |
OLD | NEW |