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 * @private {boolean} |
| 176 */ |
| 177 this.useSystemDefaultAsDefault_ = |
| 178 loadTimeData.getBoolean('useSystemDefaultPrinter'); |
| 179 |
172 this.addEventListeners_(); | 180 this.addEventListeners_(); |
173 this.reset_(); | 181 this.reset_(); |
174 } | 182 } |
175 | 183 |
176 /** | 184 /** |
177 * Event types dispatched by the data store. | 185 * Event types dispatched by the data store. |
178 * @enum {string} | 186 * @enum {string} |
179 */ | 187 */ |
180 DestinationStore.EventType = { | 188 DestinationStore.EventType = { |
181 DESTINATION_SEARCH_DONE: | 189 DESTINATION_SEARCH_DONE: |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 id = this.appState_.recentDestinations[i].id; | 598 id = this.appState_.recentDestinations[i].id; |
591 account = this.appState_.recentDestinations[i].account || ''; | 599 account = this.appState_.recentDestinations[i].account || ''; |
592 name = this.appState_.recentDestinations[i].name || ''; | 600 name = this.appState_.recentDestinations[i].name || ''; |
593 capabilities = this.appState_.recentDestinations[i].capabilities; | 601 capabilities = this.appState_.recentDestinations[i].capabilities; |
594 extensionId = this.appState_.recentDestinations[i].extensionId || ''; | 602 extensionId = this.appState_.recentDestinations[i].extensionId || ''; |
595 extensionName = | 603 extensionName = |
596 this.appState_.recentDestinations[i].extensionName || ''; | 604 this.appState_.recentDestinations[i].extensionName || ''; |
597 var candidate = this.destinationMap_[this.getDestinationKey_( | 605 var candidate = this.destinationMap_[this.getDestinationKey_( |
598 origin, id, account)]; | 606 origin, id, account)]; |
599 if (candidate != null) { | 607 if (candidate != null) { |
600 if (!foundDestination) | 608 if (!foundDestination && !this.useSystemDefaultAsDefault_) |
601 this.selectDestination(candidate); | 609 this.selectDestination(candidate); |
602 candidate.isRecent = true; | 610 candidate.isRecent = true; |
603 foundDestination = true; | 611 foundDestination = true; |
604 } else if (!foundDestination) { | 612 } else if (!foundDestination && !this.useSystemDefaultAsDefault_) { |
605 foundDestination = this.fetchPreselectedDestination_( | 613 foundDestination = this.fetchPreselectedDestination_( |
606 origin, id, account, name, capabilities, extensionId, | 614 origin, id, account, name, capabilities, extensionId, |
607 extensionName); | 615 extensionName); |
608 } | 616 } |
609 } | 617 } |
610 } | 618 } |
611 if (foundDestination) | 619 |
| 620 if (foundDestination && !this.useSystemDefaultAsDefault_) |
612 return; | 621 return; |
613 | 622 |
614 // Try the system default | 623 // Try the system default |
615 id = this.systemDefaultDestinationId_ || ''; | 624 id = this.systemDefaultDestinationId_ || ''; |
616 origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? | 625 origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? |
617 print_preview.DestinationOrigin.LOCAL : | 626 print_preview.DestinationOrigin.LOCAL : |
618 this.platformOrigin_; | 627 this.platformOrigin_; |
619 account = ''; | 628 account = ''; |
620 var candidate = | 629 var candidate = |
621 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; | 630 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 */ | 1642 */ |
1634 getKey_: function(destination) { | 1643 getKey_: function(destination) { |
1635 return this.getDestinationKey_( | 1644 return this.getDestinationKey_( |
1636 destination.origin, destination.id, destination.account); | 1645 destination.origin, destination.id, destination.account); |
1637 } | 1646 } |
1638 }; | 1647 }; |
1639 | 1648 |
1640 // Export | 1649 // Export |
1641 return {DestinationStore: DestinationStore}; | 1650 return {DestinationStore: DestinationStore}; |
1642 }); | 1651 }); |
OLD | NEW |