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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DESTINATION_SEARCH_STARTED: | 136 DESTINATION_SEARCH_STARTED: |
137 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', | 137 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', |
138 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', | 138 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', |
139 DESTINATIONS_INSERTED: | 139 DESTINATIONS_INSERTED: |
140 'print_preview.DestinationStore.DESTINATIONS_INSERTED', | 140 'print_preview.DestinationStore.DESTINATIONS_INSERTED', |
141 SELECTED_DESTINATION_CAPABILITIES_READY: | 141 SELECTED_DESTINATION_CAPABILITIES_READY: |
142 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' | 142 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' |
143 }; | 143 }; |
144 | 144 |
145 /** | 145 /** |
146 * Number of built-in print destinations. This includes the "Save as PDF" | |
147 * destination. | |
148 * @type {number} | |
149 * @const | |
150 */ | |
151 DestinationStore.BUILT_IN_DESTINATION_COUNT = 1; | |
152 | |
153 /** | |
154 * Delay in milliseconds before the destination store ignores the initial | 146 * Delay in milliseconds before the destination store ignores the initial |
155 * destination ID and just selects any printer (since the initial destination | 147 * destination ID and just selects any printer (since the initial destination |
156 * was not found). | 148 * was not found). |
157 * @type {number} | 149 * @type {number} |
158 * @const | 150 * @const |
159 * @private | 151 * @private |
160 */ | 152 */ |
161 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; | 153 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; |
162 | 154 |
163 /** | 155 /** |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 this.tracker_.add( | 268 this.tracker_.add( |
277 this.cloudPrintInterface_, | 269 this.cloudPrintInterface_, |
278 cloudprint.CloudPrintInterface.EventType.PRINTER_FAILED, | 270 cloudprint.CloudPrintInterface.EventType.PRINTER_FAILED, |
279 this.onCloudPrintPrinterFailed_.bind(this)); | 271 this.onCloudPrintPrinterFailed_.bind(this)); |
280 // Fetch initial destination if its a cloud destination. | 272 // Fetch initial destination if its a cloud destination. |
281 if (this.isInAutoSelectMode_ && !this.isInitialDestinationLocal_) { | 273 if (this.isInAutoSelectMode_ && !this.isInitialDestinationLocal_) { |
282 this.cloudPrintInterface_.printer(this.initialDestinationId_); | 274 this.cloudPrintInterface_.printer(this.initialDestinationId_); |
283 } | 275 } |
284 }, | 276 }, |
285 | 277 |
| 278 /** |
| 279 * @return {boolean} Whether only default cloud destinations have been |
| 280 * loaded. |
| 281 */ |
| 282 hasOnlyDefaultCloudDestinations: function() { |
| 283 return this.destinations_.every(function(dest) { |
| 284 return dest.isLocal || |
| 285 dest.id == print_preview.Destination.GooglePromotedId.DOCS || |
| 286 dest.id == print_preview.Destination.GooglePromotedId.FEDEX; |
| 287 }); |
| 288 }, |
| 289 |
286 /** @param {!print_preview.Destination} Destination to select. */ | 290 /** @param {!print_preview.Destination} Destination to select. */ |
287 selectDestination: function(destination) { | 291 selectDestination: function(destination) { |
288 this.selectedDestination_ = destination; | 292 this.selectedDestination_ = destination; |
289 this.selectedDestination_.isRecent = true; | 293 this.selectedDestination_.isRecent = true; |
290 this.isInAutoSelectMode_ = false; | 294 this.isInAutoSelectMode_ = false; |
291 if (this.autoSelectTimeout_ != null) { | 295 if (this.autoSelectTimeout_ != null) { |
292 clearTimeout(this.autoSelectTimeout_); | 296 clearTimeout(this.autoSelectTimeout_); |
293 this.autoSelectTimeout_ = null; | 297 this.autoSelectTimeout_ = null; |
294 } | 298 } |
295 if (destination.id == print_preview.Destination.GooglePromotedId.FEDEX && | 299 if (destination.id == print_preview.Destination.GooglePromotedId.FEDEX && |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 'No destinations were loaded before auto-select timeout expired'); | 638 'No destinations were loaded before auto-select timeout expired'); |
635 this.selectDestination(this.destinations_[0]); | 639 this.selectDestination(this.destinations_[0]); |
636 } | 640 } |
637 }; | 641 }; |
638 | 642 |
639 // Export | 643 // Export |
640 return { | 644 return { |
641 DestinationStore: DestinationStore | 645 DestinationStore: DestinationStore |
642 }; | 646 }; |
643 }); | 647 }); |
OLD | NEW |