| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 * @param {string | print_preview.DestinationOrigin} origin Destination | 690 * @param {string | print_preview.DestinationOrigin} origin Destination |
| 691 * origin. | 691 * origin. |
| 692 * @param {string} id Destination id. | 692 * @param {string} id Destination id. |
| 693 * @param {string} account User account destination is registered for. | 693 * @param {string} account User account destination is registered for. |
| 694 * @param {string} name Destination display name. | 694 * @param {string} name Destination display name. |
| 695 * @param {?print_preview.Cdd} capabilities Destination capabilities. | 695 * @param {?print_preview.Cdd} capabilities Destination capabilities. |
| 696 * @param {string} extensionId Extension ID associated with this | 696 * @param {string} extensionId Extension ID associated with this |
| 697 * destination. | 697 * destination. |
| 698 * @param {string} extensionName Extension name associated with this | 698 * @param {string} extensionName Extension name associated with this |
| 699 * destination. | 699 * destination. |
| 700 * @return {boolean} Whether capabilities fetch was successfully started. |
| 700 * @private | 701 * @private |
| 701 */ | 702 */ |
| 702 fetchPreselectedDestination_: function( | 703 fetchPreselectedDestination_: function( |
| 703 origin, id, account, name, capabilities, extensionId, extensionName) { | 704 origin, id, account, name, capabilities, extensionId, extensionName) { |
| 704 this.autoSelectMatchingDestination_ = | 705 this.autoSelectMatchingDestination_ = |
| 705 this.createExactDestinationMatch_(origin, id); | 706 this.createExactDestinationMatch_(origin, id); |
| 706 | 707 |
| 707 if (origin == print_preview.DestinationOrigin.LOCAL || | 708 if (origin == print_preview.DestinationOrigin.LOCAL || |
| 708 origin == print_preview.DestinationOrigin.CROS) { | 709 origin == print_preview.DestinationOrigin.CROS) { |
| 709 this.nativeLayer_.startGetLocalDestinationCapabilities(id); | 710 this.nativeLayer_.startGetLocalDestinationCapabilities(id); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 728 // Create a fake selectedDestination_ that is not actually in the | 729 // Create a fake selectedDestination_ that is not actually in the |
| 729 // destination store. When the real destination is created, this | 730 // destination store. When the real destination is created, this |
| 730 // destination will be overwritten. | 731 // destination will be overwritten. |
| 731 this.selectedDestination_ = new print_preview.Destination( | 732 this.selectedDestination_ = new print_preview.Destination( |
| 732 id, | 733 id, |
| 733 print_preview.DestinationType.LOCAL, | 734 print_preview.DestinationType.LOCAL, |
| 734 print_preview.DestinationOrigin.PRIVET, | 735 print_preview.DestinationOrigin.PRIVET, |
| 735 name, | 736 name, |
| 736 false /*isRecent*/, | 737 false /*isRecent*/, |
| 737 print_preview.DestinationConnectionStatus.ONLINE); | 738 print_preview.DestinationConnectionStatus.ONLINE); |
| 738 this.selectedDestination_.capabilities = capabilities; | |
| 739 | 739 |
| 740 cr.dispatchSimpleEvent( | 740 if (capabilities) { |
| 741 this, | 741 this.selectedDestination_.capabilities = capabilities; |
| 742 DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY); | 742 |
| 743 cr.dispatchSimpleEvent( |
| 744 this, |
| 745 DestinationStore.EventType |
| 746 .CACHED_SELECTED_DESTINATION_INFO_READY); |
| 747 } |
| 743 return true; | 748 return true; |
| 744 } | 749 } |
| 745 | 750 |
| 746 if (origin == print_preview.DestinationOrigin.EXTENSION) { | 751 if (origin == print_preview.DestinationOrigin.EXTENSION) { |
| 747 // TODO(tbarzic): Add support for requesting a single extension's | 752 // TODO(tbarzic): Add support for requesting a single extension's |
| 748 // printer list. | 753 // printer list. |
| 749 this.startLoadExtensionDestinations(); | 754 this.startLoadExtensionDestinations(); |
| 750 | 755 |
| 751 this.selectedDestination_ = | 756 this.selectedDestination_ = |
| 752 print_preview.ExtensionDestinationParser.parse({ | 757 print_preview.ExtensionDestinationParser.parse({ |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 return this.getDestinationKey_( | 1700 return this.getDestinationKey_( |
| 1696 destination.origin, destination.id, destination.account); | 1701 destination.origin, destination.id, destination.account); |
| 1697 } | 1702 } |
| 1698 }; | 1703 }; |
| 1699 | 1704 |
| 1700 // Export | 1705 // Export |
| 1701 return { | 1706 return { |
| 1702 DestinationStore: DestinationStore | 1707 DestinationStore: DestinationStore |
| 1703 }; | 1708 }; |
| 1704 }); | 1709 }); |
| OLD | NEW |