| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 */ | 376 */ |
| 377 hasOnlyDefaultCloudDestinations: function() { | 377 hasOnlyDefaultCloudDestinations: function() { |
| 378 // TODO: Move the logic to print_preview. | 378 // TODO: Move the logic to print_preview. |
| 379 return this.destinations_.every(function(dest) { | 379 return this.destinations_.every(function(dest) { |
| 380 return dest.isLocal || | 380 return dest.isLocal || |
| 381 dest.id == print_preview.Destination.GooglePromotedId.DOCS || | 381 dest.id == print_preview.Destination.GooglePromotedId.DOCS || |
| 382 dest.id == print_preview.Destination.GooglePromotedId.FEDEX; | 382 dest.id == print_preview.Destination.GooglePromotedId.FEDEX; |
| 383 }); | 383 }); |
| 384 }, | 384 }, |
| 385 | 385 |
| 386 /** @param {!print_preview.Destination} Destination to select. */ | 386 /** |
| 387 * @param {!print_preview.Destination} destination Destination to select. |
| 388 */ |
| 387 selectDestination: function(destination) { | 389 selectDestination: function(destination) { |
| 388 this.isInAutoSelectMode_ = false; | 390 this.isInAutoSelectMode_ = false; |
| 389 // When auto select expires, DESTINATION_SELECT event has to be dispatched | 391 // When auto select expires, DESTINATION_SELECT event has to be dispatched |
| 390 // anyway (see isAutoSelectDestinationInProgress() logic). | 392 // anyway (see isAutoSelectDestinationInProgress() logic). |
| 391 if (this.autoSelectTimeout_) { | 393 if (this.autoSelectTimeout_) { |
| 392 clearTimeout(this.autoSelectTimeout_); | 394 clearTimeout(this.autoSelectTimeout_); |
| 393 this.autoSelectTimeout_ = null; | 395 this.autoSelectTimeout_ = null; |
| 394 } else if (destination == this.selectedDestination_) { | 396 } else if (destination == this.selectedDestination_) { |
| 395 return; | 397 return; |
| 396 } | 398 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 this.hasLoadedAllLocalDestinations_ = false; | 711 this.hasLoadedAllLocalDestinations_ = false; |
| 710 | 712 |
| 711 clearTimeout(this.autoSelectTimeout_); | 713 clearTimeout(this.autoSelectTimeout_); |
| 712 this.autoSelectTimeout_ = setTimeout( | 714 this.autoSelectTimeout_ = setTimeout( |
| 713 this.selectDefaultDestination_.bind(this), | 715 this.selectDefaultDestination_.bind(this), |
| 714 DestinationStore.AUTO_SELECT_TIMEOUT_); | 716 DestinationStore.AUTO_SELECT_TIMEOUT_); |
| 715 }, | 717 }, |
| 716 | 718 |
| 717 /** | 719 /** |
| 718 * Called when the local destinations have been got from the native layer. | 720 * Called when the local destinations have been got from the native layer. |
| 719 * @param {Event} Contains the local destinations. | 721 * @param {Event} event Contains the local destinations. |
| 720 * @private | 722 * @private |
| 721 */ | 723 */ |
| 722 onLocalDestinationsSet_: function(event) { | 724 onLocalDestinationsSet_: function(event) { |
| 723 var localDestinations = event.destinationInfos.map(function(destInfo) { | 725 var localDestinations = event.destinationInfos.map(function(destInfo) { |
| 724 return print_preview.LocalDestinationParser.parse(destInfo); | 726 return print_preview.LocalDestinationParser.parse(destInfo); |
| 725 }); | 727 }); |
| 726 this.insertDestinations_(localDestinations); | 728 this.insertDestinations_(localDestinations); |
| 727 this.isLocalDestinationSearchInProgress_ = false; | 729 this.isLocalDestinationSearchInProgress_ = false; |
| 728 cr.dispatchSimpleEvent( | 730 cr.dispatchSimpleEvent( |
| 729 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); | 731 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 return id == this.appState_.selectedDestinationId && | 951 return id == this.appState_.selectedDestinationId && |
| 950 origin == this.appState_.selectedDestinationOrigin; | 952 origin == this.appState_.selectedDestinationOrigin; |
| 951 } | 953 } |
| 952 }; | 954 }; |
| 953 | 955 |
| 954 // Export | 956 // Export |
| 955 return { | 957 return { |
| 956 DestinationStore: DestinationStore | 958 DestinationStore: DestinationStore |
| 957 }; | 959 }; |
| 958 }); | 960 }); |
| OLD | NEW |