Chromium Code Reviews| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 */ | 273 */ |
| 274 this.extensionSearchTimeout_ = null; | 274 this.extensionSearchTimeout_ = null; |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * MDNS service name of destination that we are waiting to register. | 277 * MDNS service name of destination that we are waiting to register. |
| 278 * @type {?string} | 278 * @type {?string} |
| 279 * @private | 279 * @private |
| 280 */ | 280 */ |
| 281 this.waitForRegisterDestination_ = null; | 281 this.waitForRegisterDestination_ = null; |
| 282 | 282 |
| 283 /** | |
| 284 * Local destinations are CROS destinations on ChromeOS because they require | |
| 285 * extra setup. | |
| 286 * @type{!print_preview.Destination.Origin} | |
| 287 * @private | |
| 288 */ | |
| 289 this.platformOrigin_ = cr.isChromeOS ? | |
| 290 print_preview.Destination.Origin.CROS : | |
| 291 print_preview.Destination.Origin.LOCAL; | |
| 292 | |
| 283 this.addEventListeners_(); | 293 this.addEventListeners_(); |
| 284 this.reset_(); | 294 this.reset_(); |
| 285 }; | 295 }; |
| 286 | 296 |
| 287 /** | 297 /** |
| 288 * Event types dispatched by the data store. | 298 * Event types dispatched by the data store. |
| 289 * @enum {string} | 299 * @enum {string} |
| 290 */ | 300 */ |
| 291 DestinationStore.EventType = { | 301 DestinationStore.EventType = { |
| 292 DESTINATION_SEARCH_DONE: | 302 DESTINATION_SEARCH_DONE: |
| 293 'print_preview.DestinationStore.DESTINATION_SEARCH_DONE', | 303 'print_preview.DestinationStore.DESTINATION_SEARCH_DONE', |
| 294 DESTINATION_SEARCH_STARTED: | 304 DESTINATION_SEARCH_STARTED: |
| 295 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', | 305 'print_preview.DestinationStore.DESTINATION_SEARCH_STARTED', |
| 296 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', | 306 DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', |
| 297 DESTINATIONS_INSERTED: | 307 DESTINATIONS_INSERTED: |
| 298 'print_preview.DestinationStore.DESTINATIONS_INSERTED', | 308 'print_preview.DestinationStore.DESTINATIONS_INSERTED', |
| 299 PROVISIONAL_DESTINATION_RESOLVED: | 309 PROVISIONAL_DESTINATION_RESOLVED: |
| 300 'print_preview.DestinationStore.PROVISIONAL_DESTINATION_RESOLVED', | 310 'print_preview.DestinationStore.PROVISIONAL_DESTINATION_RESOLVED', |
| 301 CACHED_SELECTED_DESTINATION_INFO_READY: | 311 CACHED_SELECTED_DESTINATION_INFO_READY: |
| 302 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', | 312 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', |
| 303 SELECTED_DESTINATION_CAPABILITIES_READY: | 313 SELECTED_DESTINATION_CAPABILITIES_READY: |
| 304 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' | 314 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' , |
| 315 PRINTER_CONFIGURED: | |
| 316 'print_preview.DestinationStore.PRINTER_CONFIGURED', | |
| 305 }; | 317 }; |
| 306 | 318 |
| 307 /** | 319 /** |
| 308 * Delay in milliseconds before the destination store ignores the initial | 320 * Delay in milliseconds before the destination store ignores the initial |
| 309 * destination ID and just selects any printer (since the initial destination | 321 * destination ID and just selects any printer (since the initial destination |
| 310 * was not found). | 322 * was not found). |
| 311 * @private {number} | 323 * @private {number} |
| 312 * @const | 324 * @const |
| 313 */ | 325 */ |
| 314 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; | 326 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 return; | 695 return; |
| 684 } | 696 } |
| 685 } | 697 } |
| 686 | 698 |
| 687 if (!this.systemDefaultDestinationId_ && | 699 if (!this.systemDefaultDestinationId_ && |
| 688 !this.appState_.isSelectedDestinationValid()) { | 700 !this.appState_.isSelectedDestinationValid()) { |
| 689 this.selectPdfDestination_(); | 701 this.selectPdfDestination_(); |
| 690 return; | 702 return; |
| 691 } | 703 } |
| 692 | 704 |
| 693 var origin = print_preview.Destination.Origin.LOCAL; | 705 var origin = null; |
| 694 var id = this.systemDefaultDestinationId_; | 706 var id = ''; |
| 695 var account = ''; | 707 var account = ''; |
| 696 var name = ''; | 708 var name = ''; |
| 697 var capabilities = null; | 709 var capabilities = null; |
| 698 var extensionId = ''; | 710 var extensionId = ''; |
| 699 var extensionName = ''; | 711 var extensionName = ''; |
| 700 var foundDestination = false; | 712 var foundDestination = false; |
| 701 if (this.appState_.recentDestinations) { | 713 if (this.appState_.recentDestinations) { |
| 702 // Run through the destinations forward. As soon as we find a | 714 // Run through the destinations forward. As soon as we find a |
| 703 // destination, don't select any future destinations, just mark | 715 // destination, don't select any future destinations, just mark |
| 704 // them recent. Otherwise, there is a race condition between selecting | 716 // them recent. Otherwise, there is a race condition between selecting |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 728 id, | 740 id, |
| 729 account, | 741 account, |
| 730 name, | 742 name, |
| 731 capabilities, | 743 capabilities, |
| 732 extensionId, | 744 extensionId, |
| 733 extensionName); | 745 extensionName); |
| 734 } | 746 } |
| 735 } | 747 } |
| 736 } | 748 } |
| 737 if (foundDestination) return; | 749 if (foundDestination) return; |
| 750 | |
| 738 // Try the system default | 751 // Try the system default |
| 752 id = this.systemDefaultDestinationId_; | |
| 753 origin = id == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? | |
| 754 print_preview.Destination.Origin.LOCAL : | |
| 755 this.platformOrigin_; | |
| 756 account = ''; | |
| 739 var candidate = | 757 var candidate = |
| 740 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; | 758 this.destinationMap_[this.getDestinationKey_(origin, id, account)]; |
| 741 if (candidate != null) { | 759 if (candidate != null) { |
| 742 this.selectDestination(candidate); | 760 this.selectDestination(candidate); |
| 743 return; | 761 return; |
| 744 } | 762 } |
| 745 | 763 |
| 746 if (this.fetchPreselectedDestination_( | 764 if (this.fetchPreselectedDestination_( |
| 747 origin, | 765 origin, |
| 748 id, | 766 id, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 769 * destination. | 787 * destination. |
| 770 * @param {string} extensionName Extension name associated with this | 788 * @param {string} extensionName Extension name associated with this |
| 771 * destination. | 789 * destination. |
| 772 * @private | 790 * @private |
| 773 */ | 791 */ |
| 774 fetchPreselectedDestination_: function( | 792 fetchPreselectedDestination_: function( |
| 775 origin, id, account, name, capabilities, extensionId, extensionName) { | 793 origin, id, account, name, capabilities, extensionId, extensionName) { |
| 776 this.autoSelectMatchingDestination_ = | 794 this.autoSelectMatchingDestination_ = |
| 777 this.createExactDestinationMatch_(origin, id); | 795 this.createExactDestinationMatch_(origin, id); |
| 778 | 796 |
| 779 if (origin == print_preview.Destination.Origin.LOCAL) { | 797 if (origin == print_preview.Destination.Origin.LOCAL || |
| 798 origin == print_preview.Destination.Origin.CROS) { | |
| 780 this.nativeLayer_.startGetLocalDestinationCapabilities(id); | 799 this.nativeLayer_.startGetLocalDestinationCapabilities(id); |
| 781 return true; | 800 return true; |
| 782 } | 801 } |
| 783 | 802 |
| 784 if (this.cloudPrintInterface_ && | 803 if (this.cloudPrintInterface_ && |
| 785 (origin == print_preview.Destination.Origin.COOKIES || | 804 (origin == print_preview.Destination.Origin.COOKIES || |
| 786 origin == print_preview.Destination.Origin.DEVICE)) { | 805 origin == print_preview.Destination.Origin.DEVICE)) { |
| 787 this.cloudPrintInterface_.printer(id, origin, account); | 806 this.cloudPrintInterface_.printer(id, origin, account); |
| 788 return true; | 807 return true; |
| 789 } | 808 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 | 859 |
| 841 /** | 860 /** |
| 842 * Attempts to find a destination matching the provided rules. | 861 * Attempts to find a destination matching the provided rules. |
| 843 * @param {!print_preview.DestinationMatch} destinationMatch Rules to match. | 862 * @param {!print_preview.DestinationMatch} destinationMatch Rules to match. |
| 844 * @private | 863 * @private |
| 845 */ | 864 */ |
| 846 fetchMatchingDestination_: function(destinationMatch) { | 865 fetchMatchingDestination_: function(destinationMatch) { |
| 847 this.autoSelectMatchingDestination_ = destinationMatch; | 866 this.autoSelectMatchingDestination_ = destinationMatch; |
| 848 | 867 |
| 849 if (destinationMatch.matchOrigin( | 868 if (destinationMatch.matchOrigin( |
| 850 print_preview.Destination.Origin.LOCAL)) { | 869 print_preview.Destination.Origin.LOCAL) || |
| 870 destinationMatch.matchOrigin( | |
| 871 print_preview.Destination.Origin.CROS)) { | |
| 851 this.startLoadLocalDestinations(); | 872 this.startLoadLocalDestinations(); |
| 852 } | 873 } |
| 853 if (destinationMatch.matchOrigin( | 874 if (destinationMatch.matchOrigin( |
| 854 print_preview.Destination.Origin.PRIVET)) { | 875 print_preview.Destination.Origin.PRIVET)) { |
| 855 this.startLoadPrivetDestinations(); | 876 this.startLoadPrivetDestinations(); |
| 856 } | 877 } |
| 857 if (destinationMatch.matchOrigin( | 878 if (destinationMatch.matchOrigin( |
| 858 print_preview.Destination.Origin.EXTENSION)) { | 879 print_preview.Destination.Origin.EXTENSION)) { |
| 859 this.startLoadExtensionDestinations(); | 880 this.startLoadExtensionDestinations(); |
| 860 } | 881 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 if (!isLocal && !isCloud) { | 916 if (!isLocal && !isCloud) { |
| 896 console.error('Unsupported type: "' + matchRules.kind + '"'); | 917 console.error('Unsupported type: "' + matchRules.kind + '"'); |
| 897 return null; | 918 return null; |
| 898 } | 919 } |
| 899 | 920 |
| 900 var origins = []; | 921 var origins = []; |
| 901 if (isLocal) { | 922 if (isLocal) { |
| 902 origins.push(print_preview.Destination.Origin.LOCAL); | 923 origins.push(print_preview.Destination.Origin.LOCAL); |
| 903 origins.push(print_preview.Destination.Origin.PRIVET); | 924 origins.push(print_preview.Destination.Origin.PRIVET); |
| 904 origins.push(print_preview.Destination.Origin.EXTENSION); | 925 origins.push(print_preview.Destination.Origin.EXTENSION); |
| 926 origins.push(print_preview.Destination.Origin.CROS); | |
| 905 } | 927 } |
| 906 if (isCloud) { | 928 if (isCloud) { |
| 907 origins.push(print_preview.Destination.Origin.COOKIES); | 929 origins.push(print_preview.Destination.Origin.COOKIES); |
| 908 origins.push(print_preview.Destination.Origin.DEVICE); | 930 origins.push(print_preview.Destination.Origin.DEVICE); |
| 909 origins.push(print_preview.Destination.Origin.PROFILE); | 931 origins.push(print_preview.Destination.Origin.PROFILE); |
| 910 } | 932 } |
| 911 | 933 |
| 912 var idRegExp = null; | 934 var idRegExp = null; |
| 913 try { | 935 try { |
| 914 if (matchRules.idPattern) { | 936 if (matchRules.idPattern) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 940 * @private | 962 * @private |
| 941 */ | 963 */ |
| 942 convertPreselectedToDestinationMatch_: function() { | 964 convertPreselectedToDestinationMatch_: function() { |
| 943 if (this.appState_.isSelectedDestinationValid()) { | 965 if (this.appState_.isSelectedDestinationValid()) { |
| 944 return this.createExactDestinationMatch_( | 966 return this.createExactDestinationMatch_( |
| 945 this.appState_.selectedDestination.origin, | 967 this.appState_.selectedDestination.origin, |
| 946 this.appState_.selectedDestination.id); | 968 this.appState_.selectedDestination.id); |
| 947 } | 969 } |
| 948 if (this.systemDefaultDestinationId_) { | 970 if (this.systemDefaultDestinationId_) { |
| 949 return this.createExactDestinationMatch_( | 971 return this.createExactDestinationMatch_( |
| 950 print_preview.Destination.Origin.LOCAL, | 972 this.platformOrigin_, |
| 951 this.systemDefaultDestinationId_); | 973 this.systemDefaultDestinationId_); |
| 952 } | 974 } |
| 953 return null; | 975 return null; |
| 954 }, | 976 }, |
| 955 | 977 |
| 956 /** | 978 /** |
| 957 * @param {!print_preview.Destination.Origin} origin Destination origin. | 979 * @param {!print_preview.Destination.Origin} origin Destination origin. |
| 958 * @param {string} id Destination id. | 980 * @param {string} id Destination id. |
| 959 * @return {!print_preview.DestinationMatch} Creates rules matching | 981 * @return {!print_preview.DestinationMatch} Creates rules matching |
| 960 * provided destination. | 982 * provided destination. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1076 this.cloudPrintInterface_.printer( | 1098 this.cloudPrintInterface_.printer( |
| 1077 destination.id, destination.origin, destination.account); | 1099 destination.id, destination.origin, destination.account); |
| 1078 } | 1100 } |
| 1079 } else { | 1101 } else { |
| 1080 cr.dispatchSimpleEvent( | 1102 cr.dispatchSimpleEvent( |
| 1081 this, | 1103 this, |
| 1082 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); | 1104 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); |
| 1083 } | 1105 } |
| 1084 }, | 1106 }, |
| 1085 | 1107 |
| 1108 resolveCrosDestination: function(destination) { | |
|
dpapad
2017/01/11 20:36:30
@param annotation missing.
skau
2017/01/12 00:36:16
Done.
| |
| 1109 this.nativeLayer_.setupPrinter(destination.id); | |
| 1110 }, | |
| 1111 | |
| 1086 /** | 1112 /** |
| 1087 * Attempts to resolve a provisional destination. | 1113 * Attempts to resolve a provisional destination. |
| 1088 * @param {!print_preview.Destination} destinaion Provisional destination | 1114 * @param {!print_preview.Destination} destinaion Provisional destination |
| 1089 * that should be resolved. | 1115 * that should be resolved. |
| 1090 */ | 1116 */ |
| 1091 resolveProvisionalDestination: function(destination) { | 1117 resolveProvisionalDestination: function(destination) { |
| 1092 assert( | 1118 assert( |
| 1093 destination.provisionalType == | 1119 destination.provisionalType == |
| 1094 print_preview.Destination.ProvisionalType.NEEDS_USB_PERMISSION, | 1120 print_preview.Destination.ProvisionalType.NEEDS_USB_PERMISSION, |
| 1095 'Provisional type cannot be resolved.'); | 1121 'Provisional type cannot be resolved.'); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1112 /** | 1138 /** |
| 1113 * Attempts to select system default destination with a fallback to | 1139 * Attempts to select system default destination with a fallback to |
| 1114 * 'Save to PDF' destination. | 1140 * 'Save to PDF' destination. |
| 1115 * @private | 1141 * @private |
| 1116 */ | 1142 */ |
| 1117 selectDefaultDestination_: function() { | 1143 selectDefaultDestination_: function() { |
| 1118 if (this.systemDefaultDestinationId_) { | 1144 if (this.systemDefaultDestinationId_) { |
| 1119 if (this.autoSelectMatchingDestination_ && | 1145 if (this.autoSelectMatchingDestination_ && |
| 1120 !this.autoSelectMatchingDestination_.matchIdAndOrigin( | 1146 !this.autoSelectMatchingDestination_.matchIdAndOrigin( |
| 1121 this.systemDefaultDestinationId_, | 1147 this.systemDefaultDestinationId_, |
| 1122 print_preview.Destination.Origin.LOCAL)) { | 1148 this.plaformOrigin_)) { |
| 1123 if (this.fetchPreselectedDestination_( | 1149 if (this.fetchPreselectedDestination_( |
| 1124 print_preview.Destination.Origin.LOCAL, | 1150 this.platformOrigin_, |
| 1125 this.systemDefaultDestinationId_, | 1151 this.systemDefaultDestinationId_, |
| 1126 '' /*account*/, | 1152 '' /*account*/, |
| 1127 '' /*name*/, | 1153 '' /*name*/, |
| 1128 null /*capabilities*/, | 1154 null /*capabilities*/, |
| 1129 '' /*extensionId*/, | 1155 '' /*extensionId*/, |
| 1130 '' /*extensionName*/)) { | 1156 '' /*extensionName*/)) { |
| 1131 return; | 1157 return; |
| 1132 } | 1158 } |
| 1133 } | 1159 } |
| 1134 } | 1160 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 this.insertIntoStore_(destination); | 1291 this.insertIntoStore_(destination); |
| 1266 | 1292 |
| 1267 var event = new Event( | 1293 var event = new Event( |
| 1268 DestinationStore.EventType.PROVISIONAL_DESTINATION_RESOLVED); | 1294 DestinationStore.EventType.PROVISIONAL_DESTINATION_RESOLVED); |
| 1269 event.provisionalId = evt.provisionalId; | 1295 event.provisionalId = evt.provisionalId; |
| 1270 event.destination = destination; | 1296 event.destination = destination; |
| 1271 this.dispatchEvent(event); | 1297 this.dispatchEvent(event); |
| 1272 }, | 1298 }, |
| 1273 | 1299 |
| 1274 /** | 1300 /** |
| 1301 * Handle the result of a PRINTER_SETUP request. | |
| 1302 * @param {!Event} evt event carrying the results. | |
| 1303 * @private | |
| 1304 */ | |
| 1305 handleCrosDestinationResolved_: function(evt) { | |
| 1306 var event = new Event( | |
| 1307 DestinationStore.EventType.PRINTER_CONFIGURED); | |
| 1308 event.printerId = evt.printerId; | |
| 1309 event.capabilities = evt.capabilities; | |
| 1310 event.success = evt.success; | |
| 1311 this.dispatchEvent(event); | |
| 1312 }, | |
| 1313 | |
| 1314 /** | |
| 1275 * Inserts {@code destination} to the data store and dispatches a | 1315 * Inserts {@code destination} to the data store and dispatches a |
| 1276 * DESTINATIONS_INSERTED event. | 1316 * DESTINATIONS_INSERTED event. |
| 1277 * @param {!print_preview.Destination} destination Print destination to | 1317 * @param {!print_preview.Destination} destination Print destination to |
| 1278 * insert. | 1318 * insert. |
| 1279 * @private | 1319 * @private |
| 1280 */ | 1320 */ |
| 1281 insertDestination_: function(destination) { | 1321 insertDestination_: function(destination) { |
| 1282 if (this.insertIntoStore_(destination)) { | 1322 if (this.insertIntoStore_(destination)) { |
| 1283 this.destinationsInserted_(destination); | 1323 this.destinationsInserted_(destination); |
| 1284 } | 1324 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 print_preview.NativeLayer.EventType.EXTENSION_PRINTERS_ADDED, | 1489 print_preview.NativeLayer.EventType.EXTENSION_PRINTERS_ADDED, |
| 1450 this.onExtensionPrintersAdded_.bind(this)); | 1490 this.onExtensionPrintersAdded_.bind(this)); |
| 1451 this.tracker_.add( | 1491 this.tracker_.add( |
| 1452 this.nativeLayer_, | 1492 this.nativeLayer_, |
| 1453 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, | 1493 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, |
| 1454 this.onExtensionCapabilitiesSet_.bind(this)); | 1494 this.onExtensionCapabilitiesSet_.bind(this)); |
| 1455 this.tracker_.add( | 1495 this.tracker_.add( |
| 1456 this.nativeLayer_, | 1496 this.nativeLayer_, |
| 1457 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED, | 1497 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED, |
| 1458 this.handleProvisionalDestinationResolved_.bind(this)); | 1498 this.handleProvisionalDestinationResolved_.bind(this)); |
| 1499 this.tracker_.add( | |
| 1500 this.nativeLayer_, | |
| 1501 print_preview.NativeLayer.EventType.PRINTER_SETUP, | |
| 1502 this.handleCrosDestinationResolved_.bind(this)); | |
|
dpapad
2017/01/11 20:36:30
This breaks naming convention within this file.
fo
skau
2017/01/12 00:36:16
Done.
| |
| 1459 }, | 1503 }, |
| 1460 | 1504 |
| 1461 /** | 1505 /** |
| 1462 * Creates a local PDF print destination. | 1506 * Creates a local PDF print destination. |
| 1463 * @return {!print_preview.Destination} Created print destination. | 1507 * @return {!print_preview.Destination} Created print destination. |
| 1464 * @private | 1508 * @private |
| 1465 */ | 1509 */ |
| 1466 createLocalPdfPrintDestination_: function() { | 1510 createLocalPdfPrintDestination_: function() { |
| 1467 // TODO(alekseys): Create PDF printer in the native code and send its | 1511 // TODO(alekseys): Create PDF printer in the native code and send its |
| 1468 // capabilities back with other local printers. | 1512 // capabilities back with other local printers. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1517 * destination already exists, otherwise it creates a new destination and | 1561 * destination already exists, otherwise it creates a new destination and |
| 1518 * then updates its capabilities. | 1562 * then updates its capabilities. |
| 1519 * @param {Event} event Contains the capabilities of the local print | 1563 * @param {Event} event Contains the capabilities of the local print |
| 1520 * destination. | 1564 * destination. |
| 1521 * @private | 1565 * @private |
| 1522 */ | 1566 */ |
| 1523 onLocalDestinationCapabilitiesSet_: function(event) { | 1567 onLocalDestinationCapabilitiesSet_: function(event) { |
| 1524 var destinationId = event.settingsInfo['printerId']; | 1568 var destinationId = event.settingsInfo['printerId']; |
| 1525 var printerName = event.settingsInfo['printerName']; | 1569 var printerName = event.settingsInfo['printerName']; |
| 1526 var printerDescription = event.settingsInfo['printerDescription']; | 1570 var printerDescription = event.settingsInfo['printerDescription']; |
| 1571 // PDF is special since we don't need to query the device for | |
| 1572 // capabilities. | |
| 1573 var origin = destinationId == | |
| 1574 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? | |
| 1575 print_preview.Destination.Origin.LOCAL : this.platformOrigin_; | |
| 1527 var key = this.getDestinationKey_( | 1576 var key = this.getDestinationKey_( |
| 1528 print_preview.Destination.Origin.LOCAL, | 1577 origin, |
| 1529 destinationId, | 1578 destinationId, |
| 1530 ''); | 1579 ''); |
| 1531 var destination = this.destinationMap_[key]; | 1580 var destination = this.destinationMap_[key]; |
| 1532 var capabilities = DestinationStore.localizeCapabilities_( | 1581 var capabilities = DestinationStore.localizeCapabilities_( |
| 1533 event.settingsInfo.capabilities); | 1582 event.settingsInfo.capabilities); |
| 1534 // Special case for PDF printer (until local printers capabilities are | 1583 // Special case for PDF printer (until local printers capabilities are |
| 1535 // reported in CDD format too). | 1584 // reported in CDD format too). |
| 1536 if (destinationId == | 1585 if (destinationId == |
| 1537 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { | 1586 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { |
| 1538 if (destination) { | 1587 if (destination) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 return this.getDestinationKey_( | 1794 return this.getDestinationKey_( |
| 1746 destination.origin, destination.id, destination.account); | 1795 destination.origin, destination.id, destination.account); |
| 1747 } | 1796 } |
| 1748 }; | 1797 }; |
| 1749 | 1798 |
| 1750 // Export | 1799 // Export |
| 1751 return { | 1800 return { |
| 1752 DestinationStore: DestinationStore | 1801 DestinationStore: DestinationStore |
| 1753 }; | 1802 }; |
| 1754 }); | 1803 }); |
| OLD | NEW |