| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', | 305 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', |
| 306 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', | 306 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', |
| 307 DESTINATIONS_INSERTED: | 307 DESTINATIONS_INSERTED: |
| 308 'print_preview.DestinationStore.DESTINATIONS_INSERTED', | 308 'print_preview.DestinationStore.DESTINATIONS_INSERTED', |
| 309 PROVISIONAL_DESTINATION_RESOLVED: | 309 PROVISIONAL_DESTINATION_RESOLVED: |
| 310 'print_preview.DestinationStore.PROVISIONAL_DESTINATION_RESOLVED', | 310 'print_preview.DestinationStore.PROVISIONAL_DESTINATION_RESOLVED', |
| 311 CACHED_SELECTED_DESTINATION_INFO_READY: | 311 CACHED_SELECTED_DESTINATION_INFO_READY: |
| 312 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', | 312 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', |
| 313 SELECTED_DESTINATION_CAPABILITIES_READY: | 313 SELECTED_DESTINATION_CAPABILITIES_READY: |
| 314 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY'
, | 314 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY'
, |
| 315 PRINTER_CONFIGURED: | |
| 316 'print_preview.DestinationStore.PRINTER_CONFIGURED', | |
| 317 }; | 315 }; |
| 318 | 316 |
| 319 /** | 317 /** |
| 320 * Delay in milliseconds before the destination store ignores the initial | 318 * Delay in milliseconds before the destination store ignores the initial |
| 321 * destination ID and just selects any printer (since the initial destination | 319 * destination ID and just selects any printer (since the initial destination |
| 322 * was not found). | 320 * was not found). |
| 323 * @private {number} | 321 * @private {number} |
| 324 * @const | 322 * @const |
| 325 */ | 323 */ |
| 326 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; | 324 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 cr.dispatchSimpleEvent( | 1100 cr.dispatchSimpleEvent( |
| 1103 this, | 1101 this, |
| 1104 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); | 1102 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); |
| 1105 } | 1103 } |
| 1106 }, | 1104 }, |
| 1107 | 1105 |
| 1108 /** | 1106 /** |
| 1109 * Attempt to resolve the capabilities for a Chrome OS printer. | 1107 * Attempt to resolve the capabilities for a Chrome OS printer. |
| 1110 * @param {!print_preview.Destination} destination The destination which | 1108 * @param {!print_preview.Destination} destination The destination which |
| 1111 * requires resolution. | 1109 * requires resolution. |
| 1110 * @return {!Promise<!print_preview.PrinterSetupResponse>} |
| 1112 */ | 1111 */ |
| 1113 resolveCrosDestination: function(destination) { | 1112 resolveCrosDestination: function(destination) { |
| 1114 assert(destination.origin == print_preview.Destination.Origin.CROS); | 1113 assert(destination.origin == print_preview.Destination.Origin.CROS); |
| 1115 this.nativeLayer_.setupPrinter(destination.id).then( | 1114 return this.nativeLayer_.setupPrinter(destination.id); |
| 1116 /** | |
| 1117 * Handle the result of a successful PRINTER_SETUP request. | |
| 1118 * @param {!print_preview.PrinterSetupResponse} response. | |
| 1119 */ | |
| 1120 function(response) { | |
| 1121 this.dispatchEvent(new CustomEvent( | |
| 1122 DestinationStore.EventType.PRINTER_CONFIGURED, { | |
| 1123 detail: response | |
| 1124 })); | |
| 1125 }.bind(this), | |
| 1126 /** | |
| 1127 * Calling printer setup failed. | |
| 1128 */ | |
| 1129 function() { | |
| 1130 this.dispatchEvent(new CustomEvent( | |
| 1131 DestinationStore.EventType.PRINTER_CONFIGURED, | |
| 1132 {detail: {printerId: destination.id, success: false}})); | |
| 1133 }.bind(this)); | |
| 1134 }, | 1115 }, |
| 1135 | 1116 |
| 1136 /** | 1117 /** |
| 1137 * Attempts to resolve a provisional destination. | 1118 * Attempts to resolve a provisional destination. |
| 1138 * @param {!print_preview.Destination} destinaion Provisional destination | 1119 * @param {!print_preview.Destination} destinaion Provisional destination |
| 1139 * that should be resolved. | 1120 * that should be resolved. |
| 1140 */ | 1121 */ |
| 1141 resolveProvisionalDestination: function(destination) { | 1122 resolveProvisionalDestination: function(destination) { |
| 1142 assert( | 1123 assert( |
| 1143 destination.provisionalType == | 1124 destination.provisionalType == |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 return this.getDestinationKey_( | 1783 return this.getDestinationKey_( |
| 1803 destination.origin, destination.id, destination.account); | 1784 destination.origin, destination.id, destination.account); |
| 1804 } | 1785 } |
| 1805 }; | 1786 }; |
| 1806 | 1787 |
| 1807 // Export | 1788 // Export |
| 1808 return { | 1789 return { |
| 1809 DestinationStore: DestinationStore | 1790 DestinationStore: DestinationStore |
| 1810 }; | 1791 }; |
| 1811 }); | 1792 }); |
| OLD | NEW |