| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 print_preview.DestinationOrigin.LOCAL; | 170 print_preview.DestinationOrigin.LOCAL; |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * Whether to default to the system default printer instead of the most | 173 * Whether to default to the system default printer instead of the most |
| 174 * recent destination. | 174 * recent destination. |
| 175 * @private {boolean} | 175 * @private {boolean} |
| 176 */ | 176 */ |
| 177 this.useSystemDefaultAsDefault_ = | 177 this.useSystemDefaultAsDefault_ = |
| 178 loadTimeData.getBoolean('useSystemDefaultPrinter'); | 178 loadTimeData.getBoolean('useSystemDefaultPrinter'); |
| 179 | 179 |
| 180 this.addEventListeners_(); | |
| 181 this.reset_(); | 180 this.reset_(); |
| 182 } | 181 } |
| 183 | 182 |
| 184 /** | 183 /** |
| 185 * Event types dispatched by the data store. | 184 * Event types dispatched by the data store. |
| 186 * @enum {string} | 185 * @enum {string} |
| 187 */ | 186 */ |
| 188 DestinationStore.EventType = { | 187 DestinationStore.EventType = { |
| 189 DESTINATION_SEARCH_DONE: | 188 DESTINATION_SEARCH_DONE: |
| 190 'print_preview.DestinationStore.DESTINATION_SEARCH_DONE', | 189 'print_preview.DestinationStore.DESTINATION_SEARCH_DONE', |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 destination.connectionStatus != | 1325 destination.connectionStatus != |
| 1327 print_preview.DestinationConnectionStatus.UNKNOWN) { | 1326 print_preview.DestinationConnectionStatus.UNKNOWN) { |
| 1328 existingDestination.connectionStatus = destination.connectionStatus; | 1327 existingDestination.connectionStatus = destination.connectionStatus; |
| 1329 return true; | 1328 return true; |
| 1330 } else { | 1329 } else { |
| 1331 return false; | 1330 return false; |
| 1332 } | 1331 } |
| 1333 }, | 1332 }, |
| 1334 | 1333 |
| 1335 /** | 1334 /** |
| 1336 * Binds handlers to events. | |
| 1337 * @private | |
| 1338 */ | |
| 1339 addEventListeners_: function() { | |
| 1340 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); | |
| 1341 this.tracker_.add( | |
| 1342 nativeLayerEventTarget, | |
| 1343 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, | |
| 1344 this.onDestinationsReload_.bind(this)); | |
| 1345 }, | |
| 1346 | |
| 1347 /** | |
| 1348 * Creates a local PDF print destination. | 1335 * Creates a local PDF print destination. |
| 1349 * @private | 1336 * @private |
| 1350 */ | 1337 */ |
| 1351 createLocalPdfPrintDestination_: function() { | 1338 createLocalPdfPrintDestination_: function() { |
| 1352 // TODO(alekseys): Create PDF printer in the native code and send its | 1339 // TODO(alekseys): Create PDF printer in the native code and send its |
| 1353 // capabilities back with other local printers. | 1340 // capabilities back with other local printers. |
| 1354 if (this.pdfPrinterEnabled_) { | 1341 if (this.pdfPrinterEnabled_) { |
| 1355 this.insertDestination_(new print_preview.Destination( | 1342 this.insertDestination_(new print_preview.Destination( |
| 1356 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 1343 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
| 1357 print_preview.DestinationType.LOCAL, | 1344 print_preview.DestinationType.LOCAL, |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 */ | 1637 */ |
| 1651 getKey_: function(destination) { | 1638 getKey_: function(destination) { |
| 1652 return this.getDestinationKey_( | 1639 return this.getDestinationKey_( |
| 1653 destination.origin, destination.id, destination.account); | 1640 destination.origin, destination.id, destination.account); |
| 1654 } | 1641 } |
| 1655 }; | 1642 }; |
| 1656 | 1643 |
| 1657 // Export | 1644 // Export |
| 1658 return {DestinationStore: DestinationStore}; | 1645 return {DestinationStore: DestinationStore}; |
| 1659 }); | 1646 }); |
| OLD | NEW |