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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 | 162 |
163 /** | 163 /** |
164 * Local destinations are CROS destinations on ChromeOS because they require | 164 * Local destinations are CROS destinations on ChromeOS because they require |
165 * extra setup. | 165 * extra setup. |
166 * @private {!print_preview.DestinationOrigin} | 166 * @private {!print_preview.DestinationOrigin} |
167 */ | 167 */ |
168 this.platformOrigin_ = cr.isChromeOS ? | 168 this.platformOrigin_ = cr.isChromeOS ? |
169 print_preview.DestinationOrigin.CROS : | 169 print_preview.DestinationOrigin.CROS : |
170 print_preview.DestinationOrigin.LOCAL; | 170 print_preview.DestinationOrigin.LOCAL; |
171 | 171 |
172 /** | |
173 * Whether to default to the system default printer instead of the most | |
174 * recent destination. | |
175 * @type {boolean} | |
dpapad
2017/06/19 17:43:37
Nit: @private {boolean}
rbpotter
2017/06/19 23:10:49
Done.
| |
176 * @private | |
177 */ | |
178 this.useSystemDefaultAsDefault_ = | |
179 loadTimeData.getBoolean('useSystemDefaultPrinter'); | |
180 | |
172 this.addEventListeners_(); | 181 this.addEventListeners_(); |
173 this.reset_(); | 182 this.reset_(); |
174 } | 183 } |
175 | 184 |
176 /** | 185 /** |
177 * Event types dispatched by the data store. | 186 * Event types dispatched by the data store. |
178 * @enum {string} | 187 * @enum {string} |
179 */ | 188 */ |
180 DestinationStore.EventType = { | 189 DestinationStore.EventType = { |
181 DESTINATION_SEARCH_DONE: | 190 DESTINATION_SEARCH_DONE: |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 name = this.appState_.recentDestinations[i].name || ''; | 603 name = this.appState_.recentDestinations[i].name || ''; |
595 capabilities = this.appState_.recentDestinations[i].capabilities; | 604 capabilities = this.appState_.recentDestinations[i].capabilities; |
596 extensionId = this.appState_.recentDestinations[i].extensionId || | 605 extensionId = this.appState_.recentDestinations[i].extensionId || |
597 ''; | 606 ''; |
598 extensionName = | 607 extensionName = |
599 this.appState_.recentDestinations[i].extensionName || ''; | 608 this.appState_.recentDestinations[i].extensionName || ''; |
600 var candidate = | 609 var candidate = |
601 this.destinationMap_[this.getDestinationKey_(origin, | 610 this.destinationMap_[this.getDestinationKey_(origin, |
602 id, account)]; | 611 id, account)]; |
603 if (candidate != null) { | 612 if (candidate != null) { |
604 if (!foundDestination) | 613 if (!foundDestination && !this.useSystemDefaultAsDefault_) |
605 this.selectDestination(candidate); | 614 this.selectDestination(candidate); |
606 candidate.isRecent = true; | 615 candidate.isRecent = true; |
607 foundDestination = true; | 616 foundDestination = true; |
608 } else if (!foundDestination) { | 617 } else if (!foundDestination && !this.useSystemDefaultAsDefault_) { |
609 foundDestination = this.fetchPreselectedDestination_( | 618 foundDestination = this.fetchPreselectedDestination_( |
610 origin, | 619 origin, |
611 id, | 620 id, |
612 account, | 621 account, |
613 name, | 622 name, |
614 capabilities, | 623 capabilities, |
615 extensionId, | 624 extensionId, |
616 extensionName); | 625 extensionName); |
617 } | 626 } |
618 } | 627 } |
619 } | 628 } |
620 if (foundDestination) return; | 629 if (foundDestination && !this.useSystemDefaultAsDefault_) return; |
621 | 630 |
622 // Try the system default | 631 // Try the system default |
623 id = this.systemDefaultDestinationId_ || ''; | 632 id = this.systemDefaultDestinationId_ || ''; |
624 origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? | 633 origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? |
625 print_preview.DestinationOrigin.LOCAL : | 634 print_preview.DestinationOrigin.LOCAL : |
626 this.platformOrigin_; | 635 this.platformOrigin_; |
627 account = ''; | 636 account = ''; |
628 var candidate = | 637 var candidate = |
629 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; | 638 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; |
630 if (candidate != null) { | 639 if (candidate != null) { |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 return this.getDestinationKey_( | 1674 return this.getDestinationKey_( |
1666 destination.origin, destination.id, destination.account); | 1675 destination.origin, destination.id, destination.account); |
1667 } | 1676 } |
1668 }; | 1677 }; |
1669 | 1678 |
1670 // Export | 1679 // Export |
1671 return { | 1680 return { |
1672 DestinationStore: DestinationStore | 1681 DestinationStore: DestinationStore |
1673 }; | 1682 }; |
1674 }); | 1683 }); |
OLD | NEW |