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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 147 |
148 /** | 148 /** |
149 * ID of a timeout after the start of a privet search to end that privet | 149 * ID of a timeout after the start of a privet search to end that privet |
150 * search. | 150 * search. |
151 * @type {?number} | 151 * @type {?number} |
152 * @private | 152 * @private |
153 */ | 153 */ |
154 this.privetSearchTimeout_ = null; | 154 this.privetSearchTimeout_ = null; |
155 | 155 |
156 /** | 156 /** |
157 * Whether a search for extension destinations is in progress. | |
158 * @type {boolean} | |
159 * @private | |
160 */ | |
161 this.isExtensionDestinationSearchInProgress_ = false; | |
162 | |
163 /** | |
164 * Whether the destination store has already loaded all extension | |
165 * destinations. | |
166 * @type {boolean} | |
167 * @private | |
168 */ | |
169 this.hasLoadedAllExtensionDestinations_ = false; | |
170 | |
171 /** | |
172 * ID of a timeout set at the start of an extension destination search. The | |
173 * timeout ends the search. | |
174 * @type {?number} | |
175 * @private | |
176 */ | |
177 this.extensionSearchTimeout_ = null; | |
178 | |
179 /** | |
157 * MDNS service name of destination that we are waiting to register. | 180 * MDNS service name of destination that we are waiting to register. |
158 * @type {?string} | 181 * @type {?string} |
159 * @private | 182 * @private |
160 */ | 183 */ |
161 this.waitForRegisterDestination_ = null; | 184 this.waitForRegisterDestination_ = null; |
162 | 185 |
163 this.addEventListeners_(); | 186 this.addEventListeners_(); |
164 this.reset_(); | 187 this.reset_(); |
165 }; | 188 }; |
166 | 189 |
(...skipping 27 matching lines...) Expand all Loading... | |
194 | 217 |
195 /** | 218 /** |
196 * Amount of time spent searching for privet destination, in milliseconds. | 219 * Amount of time spent searching for privet destination, in milliseconds. |
197 * @type {number} | 220 * @type {number} |
198 * @const | 221 * @const |
199 * @private | 222 * @private |
200 */ | 223 */ |
201 DestinationStore.PRIVET_SEARCH_DURATION_ = 2000; | 224 DestinationStore.PRIVET_SEARCH_DURATION_ = 2000; |
202 | 225 |
203 /** | 226 /** |
227 * Maximum amount of time spent searching for extension destinations, in | |
228 * milliseconds. | |
229 * @type {number} | |
230 * @const | |
231 * @private | |
232 */ | |
233 DestinationStore.EXTENSION_SEARCH_DURATION_ = 5000; | |
234 | |
235 /** | |
204 * Localizes printer capabilities. | 236 * Localizes printer capabilities. |
205 * @param {!Object} capabilities Printer capabilities to localize. | 237 * @param {!Object} capabilities Printer capabilities to localize. |
206 * @return {!Object} Localized capabilities. | 238 * @return {!Object} Localized capabilities. |
207 * @private | 239 * @private |
208 */ | 240 */ |
209 DestinationStore.localizeCapabilities_ = function(capabilities) { | 241 DestinationStore.localizeCapabilities_ = function(capabilities) { |
210 var mediaSize = capabilities.printer.media_size; | 242 var mediaSize = capabilities.printer.media_size; |
211 if (mediaSize) { | 243 if (mediaSize) { |
212 var mediaDisplayNames = { | 244 var mediaDisplayNames = { |
213 'ISO_A4': 'A4', | 245 'ISO_A4': 'A4', |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 get isAutoSelectDestinationInProgress() { | 292 get isAutoSelectDestinationInProgress() { |
261 return this.selectedDestination_ == null && | 293 return this.selectedDestination_ == null && |
262 this.autoSelectTimeout_ != null; | 294 this.autoSelectTimeout_ != null; |
263 }, | 295 }, |
264 | 296 |
265 /** | 297 /** |
266 * @return {boolean} Whether a search for local destinations is in progress. | 298 * @return {boolean} Whether a search for local destinations is in progress. |
267 */ | 299 */ |
268 get isLocalDestinationSearchInProgress() { | 300 get isLocalDestinationSearchInProgress() { |
269 return this.isLocalDestinationSearchInProgress_ || | 301 return this.isLocalDestinationSearchInProgress_ || |
270 this.isPrivetDestinationSearchInProgress_; | 302 this.isPrivetDestinationSearchInProgress_ || |
303 this.isExtensionDestinationSearchInProgress_; | |
271 }, | 304 }, |
272 | 305 |
273 /** | 306 /** |
274 * @return {boolean} Whether a search for cloud destinations is in progress. | 307 * @return {boolean} Whether a search for cloud destinations is in progress. |
275 */ | 308 */ |
276 get isCloudDestinationSearchInProgress() { | 309 get isCloudDestinationSearchInProgress() { |
277 return !!this.cloudPrintInterface_ && | 310 return !!this.cloudPrintInterface_ && |
278 this.cloudPrintInterface_.isCloudDestinationSearchInProgress; | 311 this.cloudPrintInterface_.isCloudDestinationSearchInProgress; |
279 }, | 312 }, |
280 | 313 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 print_preview.Destination.Origin.PRIVET, | 365 print_preview.Destination.Origin.PRIVET, |
333 destinationName, | 366 destinationName, |
334 false /*isRecent*/, | 367 false /*isRecent*/, |
335 print_preview.Destination.ConnectionStatus.ONLINE); | 368 print_preview.Destination.ConnectionStatus.ONLINE); |
336 this.selectedDestination_.capabilities = | 369 this.selectedDestination_.capabilities = |
337 this.appState_.selectedDestinationCapabilities; | 370 this.appState_.selectedDestinationCapabilities; |
338 | 371 |
339 cr.dispatchSimpleEvent( | 372 cr.dispatchSimpleEvent( |
340 this, | 373 this, |
341 DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY); | 374 DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY); |
375 } else if (this.appState_.selectedDestinationOrigin == | |
376 print_preview.Destination.Origin.EXTENSION && | |
377 this.appState_.selectedDestinationExtensionId) { | |
Vitaly Buka (NO REVIEWS)
2015/02/04 02:54:45
this should be impossible
tbarzic
2015/02/04 19:27:41
Done.
| |
378 // TODO(tbarzic): Add support for requesting a single extension's | |
379 // printer list. | |
380 this.startLoadExtensionDestinations(); | |
381 | |
382 this.selectedDestination_ = | |
383 print_preview.ExtensionDestinationParser.parse({ | |
384 extensionId: this.appState_.selectedDestinationExtensionId, | |
385 id: this.appState_.selectedDestinationId, | |
386 name: this.appState_.selectedDestinationName || '' | |
387 }); | |
388 | |
389 if (this.appState_.selectedDestinationCapabilities) { | |
390 this.selectedDestination_.capabilities = | |
391 this.appState_.selectedDestinationCapabilities; | |
392 | |
393 cr.dispatchSimpleEvent( | |
394 this, | |
395 DestinationStore.EventType | |
396 .CACHED_SELECTED_DESTINATION_INFO_READY); | |
397 } | |
342 } else { | 398 } else { |
343 this.selectDefaultDestination_(); | 399 this.selectDefaultDestination_(); |
344 } | 400 } |
345 } | 401 } |
346 }, | 402 }, |
347 | 403 |
348 /** | 404 /** |
349 * Sets the destination store's Google Cloud Print interface. | 405 * Sets the destination store's Google Cloud Print interface. |
350 * @param {!cloudprint.CloudPrintInterface} cloudPrintInterface Interface | 406 * @param {!cloudprint.CloudPrintInterface} cloudPrintInterface Interface |
351 * to set. | 407 * to set. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 CLOUD_DUPLICATE_SELECTED); | 486 CLOUD_DUPLICATE_SELECTED); |
431 } | 487 } |
432 // Notify about selected destination change. | 488 // Notify about selected destination change. |
433 cr.dispatchSimpleEvent( | 489 cr.dispatchSimpleEvent( |
434 this, DestinationStore.EventType.DESTINATION_SELECT); | 490 this, DestinationStore.EventType.DESTINATION_SELECT); |
435 // Request destination capabilities, of not known yet. | 491 // Request destination capabilities, of not known yet. |
436 if (destination.capabilities == null) { | 492 if (destination.capabilities == null) { |
437 if (destination.isPrivet) { | 493 if (destination.isPrivet) { |
438 this.nativeLayer_.startGetPrivetDestinationCapabilities( | 494 this.nativeLayer_.startGetPrivetDestinationCapabilities( |
439 destination.id); | 495 destination.id); |
440 } | 496 } else if (destination.isExtension) { |
441 else if (destination.isLocal) { | 497 this.nativeLayer_.startGetExtensionDestinationCapabilities( |
498 destination.id); | |
499 } else if (destination.isLocal) { | |
442 this.nativeLayer_.startGetLocalDestinationCapabilities( | 500 this.nativeLayer_.startGetLocalDestinationCapabilities( |
443 destination.id); | 501 destination.id); |
444 } else { | 502 } else { |
445 assert(this.cloudPrintInterface_ != null, | 503 assert(this.cloudPrintInterface_ != null, |
446 'Cloud destination selected, but GCP is not enabled'); | 504 'Cloud destination selected, but GCP is not enabled'); |
447 this.cloudPrintInterface_.printer( | 505 this.cloudPrintInterface_.printer( |
448 destination.id, destination.origin, destination.account); | 506 destination.id, destination.origin, destination.account); |
449 } | 507 } |
450 } else { | 508 } else { |
451 cr.dispatchSimpleEvent( | 509 cr.dispatchSimpleEvent( |
(...skipping 22 matching lines...) Expand all Loading... | |
474 this.nativeLayer_.startGetLocalDestinations(); | 532 this.nativeLayer_.startGetLocalDestinations(); |
475 this.isLocalDestinationSearchInProgress_ = true; | 533 this.isLocalDestinationSearchInProgress_ = true; |
476 cr.dispatchSimpleEvent( | 534 cr.dispatchSimpleEvent( |
477 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); | 535 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); |
478 } | 536 } |
479 }, | 537 }, |
480 | 538 |
481 /** Initiates loading of privet print destinations. */ | 539 /** Initiates loading of privet print destinations. */ |
482 startLoadPrivetDestinations: function() { | 540 startLoadPrivetDestinations: function() { |
483 if (!this.hasLoadedAllPrivetDestinations_) { | 541 if (!this.hasLoadedAllPrivetDestinations_) { |
542 if (this.privetDestinationSearchInProgress_) | |
543 clearTimeout(this.privetSearchTimeout_); | |
484 this.isPrivetDestinationSearchInProgress_ = true; | 544 this.isPrivetDestinationSearchInProgress_ = true; |
485 this.nativeLayer_.startGetPrivetDestinations(); | 545 this.nativeLayer_.startGetPrivetDestinations(); |
486 cr.dispatchSimpleEvent( | 546 cr.dispatchSimpleEvent( |
487 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); | 547 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); |
488 if (this.privetDestinationSearchInProgress_) | |
489 clearTimeout(this.privetSearchTimeout_); | |
490 this.privetSearchTimeout_ = setTimeout( | 548 this.privetSearchTimeout_ = setTimeout( |
491 this.endPrivetPrinterSearch_.bind(this), | 549 this.endPrivetPrinterSearch_.bind(this), |
492 DestinationStore.PRIVET_SEARCH_DURATION_); | 550 DestinationStore.PRIVET_SEARCH_DURATION_); |
493 } | 551 } |
494 }, | 552 }, |
495 | 553 |
554 /** Initializes loading of extension managed print destinations. */ | |
555 startLoadExtensionDestinations: function() { | |
556 if (this.hasLoadedAllExtensionDestinations_) | |
557 return; | |
558 | |
559 if (this.isExtensionDestinationSearchInProgress_) | |
560 clearTimeout(this.extensionSearchTimeout_); | |
561 | |
562 this.isExtensionDestinationSearchInProgress_ = true; | |
563 this.nativeLayer_.startGetExtensionDestinations(); | |
564 cr.dispatchSimpleEvent( | |
565 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); | |
566 this.extensionSearchTimeout_ = setTimeout( | |
567 this.endExtensionPrinterSearch_.bind(this), | |
568 DestinationStore.EXTENSION_SEARCH_DURATION_); | |
569 }, | |
570 | |
496 /** | 571 /** |
497 * Initiates loading of cloud destinations. | 572 * Initiates loading of cloud destinations. |
498 * @param {print_preview.Destination.Origin=} opt_origin Search destinations | 573 * @param {print_preview.Destination.Origin=} opt_origin Search destinations |
499 * for the specified origin only. | 574 * for the specified origin only. |
500 */ | 575 */ |
501 startLoadCloudDestinations: function(opt_origin) { | 576 startLoadCloudDestinations: function(opt_origin) { |
502 if (this.cloudPrintInterface_ != null) { | 577 if (this.cloudPrintInterface_ != null) { |
503 var origins = this.loadedCloudOrigins_[this.userInfo_.activeUser] || []; | 578 var origins = this.loadedCloudOrigins_[this.userInfo_.activeUser] || []; |
504 if (origins.length == 0 || | 579 if (origins.length == 0 || |
505 (opt_origin && origins.indexOf(opt_origin) < 0)) { | 580 (opt_origin && origins.indexOf(opt_origin) < 0)) { |
(...skipping 15 matching lines...) Expand all Loading... | |
521 this.startLoadCloudDestinations( | 596 this.startLoadCloudDestinations( |
522 print_preview.Destination.Origin.COOKIES); | 597 print_preview.Destination.Origin.COOKIES); |
523 } | 598 } |
524 }, | 599 }, |
525 | 600 |
526 /** Initiates loading of all known destination types. */ | 601 /** Initiates loading of all known destination types. */ |
527 startLoadAllDestinations: function() { | 602 startLoadAllDestinations: function() { |
528 this.startLoadCloudDestinations(); | 603 this.startLoadCloudDestinations(); |
529 this.startLoadLocalDestinations(); | 604 this.startLoadLocalDestinations(); |
530 this.startLoadPrivetDestinations(); | 605 this.startLoadPrivetDestinations(); |
606 this.startLoadExtensionDestinations(); | |
531 }, | 607 }, |
532 | 608 |
533 /** | 609 /** |
534 * Wait for a privet device to be registered. | 610 * Wait for a privet device to be registered. |
535 */ | 611 */ |
536 waitForRegister: function(id) { | 612 waitForRegister: function(id) { |
537 this.nativeLayer_.startGetPrivetDestinations(); | 613 this.nativeLayer_.startGetPrivetDestinations(); |
538 this.waitForRegisterDestination_ = id; | 614 this.waitForRegisterDestination_ = id; |
539 }, | 615 }, |
540 | 616 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
625 */ | 701 */ |
626 endPrivetPrinterSearch_: function() { | 702 endPrivetPrinterSearch_: function() { |
627 this.nativeLayer_.stopGetPrivetDestinations(); | 703 this.nativeLayer_.stopGetPrivetDestinations(); |
628 this.isPrivetDestinationSearchInProgress_ = false; | 704 this.isPrivetDestinationSearchInProgress_ = false; |
629 this.hasLoadedAllPrivetDestinations_ = true; | 705 this.hasLoadedAllPrivetDestinations_ = true; |
630 cr.dispatchSimpleEvent( | 706 cr.dispatchSimpleEvent( |
631 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); | 707 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); |
632 }, | 708 }, |
633 | 709 |
634 /** | 710 /** |
711 * Called when loading of extension managed printers is done. | |
712 * @private | |
713 */ | |
714 endExtensionPrinterSearch_: function() { | |
715 this.isExtensionDestinationSearchInProgress_ = false; | |
716 this.hasLoadedAllExtensionDestinations_ = true; | |
717 cr.dispatchSimpleEvent( | |
718 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); | |
719 // Clear initially selected (cached) extension destination if it hasn't | |
720 // been found among reported extension destinations. | |
721 if (this.isInAutoSelectMode_ && this.selectedDestination_.isExtension) | |
722 this.selectDefaultDestination_(); | |
723 }, | |
724 | |
725 /** | |
635 * Inserts a destination into the store without dispatching any events. | 726 * Inserts a destination into the store without dispatching any events. |
636 * @return {boolean} Whether the inserted destination was not already in the | 727 * @return {boolean} Whether the inserted destination was not already in the |
637 * store. | 728 * store. |
638 * @private | 729 * @private |
639 */ | 730 */ |
640 insertIntoStore_: function(destination) { | 731 insertIntoStore_: function(destination) { |
641 var key = this.getKey_(destination); | 732 var key = this.getKey_(destination); |
642 var existingDestination = this.destinationMap_[key]; | 733 var existingDestination = this.destinationMap_[key]; |
643 if (existingDestination == null) { | 734 if (existingDestination == null) { |
644 this.destinations_.push(destination); | 735 this.destinations_.push(destination); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, | 768 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, |
678 this.onDestinationsReload_.bind(this)); | 769 this.onDestinationsReload_.bind(this)); |
679 this.tracker_.add( | 770 this.tracker_.add( |
680 this.nativeLayer_, | 771 this.nativeLayer_, |
681 print_preview.NativeLayer.EventType.PRIVET_PRINTER_CHANGED, | 772 print_preview.NativeLayer.EventType.PRIVET_PRINTER_CHANGED, |
682 this.onPrivetPrinterAdded_.bind(this)); | 773 this.onPrivetPrinterAdded_.bind(this)); |
683 this.tracker_.add( | 774 this.tracker_.add( |
684 this.nativeLayer_, | 775 this.nativeLayer_, |
685 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET, | 776 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET, |
686 this.onPrivetCapabilitiesSet_.bind(this)); | 777 this.onPrivetCapabilitiesSet_.bind(this)); |
778 this.tracker_.add( | |
779 this.nativeLayer_, | |
780 print_preview.NativeLayer.EventType.EXTENSION_PRINTERS_ADDED, | |
781 this.onExtensionPrintersAdded_.bind(this)); | |
782 this.tracker_.add( | |
783 this.nativeLayer_, | |
784 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, | |
785 this.onExtensionCapabilitiesSet_.bind(this)); | |
687 }, | 786 }, |
688 | 787 |
689 /** | 788 /** |
690 * Creates a local PDF print destination. | 789 * Creates a local PDF print destination. |
691 * @return {!print_preview.Destination} Created print destination. | 790 * @return {!print_preview.Destination} Created print destination. |
692 * @private | 791 * @private |
693 */ | 792 */ |
694 createLocalPdfPrintDestination_: function() { | 793 createLocalPdfPrintDestination_: function() { |
695 // TODO(alekseys): Create PDF printer in the native code and send its | 794 // TODO(alekseys): Create PDF printer in the native code and send its |
696 // capabilities back with other local printers. | 795 // capabilities back with other local printers. |
(...skipping 12 matching lines...) Expand all Loading... | |
709 * Resets the state of the destination store to its initial state. | 808 * Resets the state of the destination store to its initial state. |
710 * @private | 809 * @private |
711 */ | 810 */ |
712 reset_: function() { | 811 reset_: function() { |
713 this.destinations_ = []; | 812 this.destinations_ = []; |
714 this.destinationMap_ = {}; | 813 this.destinationMap_ = {}; |
715 this.selectDestination(null); | 814 this.selectDestination(null); |
716 this.loadedCloudOrigins_ = {}; | 815 this.loadedCloudOrigins_ = {}; |
717 this.hasLoadedAllLocalDestinations_ = false; | 816 this.hasLoadedAllLocalDestinations_ = false; |
718 this.hasLoadedAllPrivetDestinations_ = false; | 817 this.hasLoadedAllPrivetDestinations_ = false; |
818 this.hasLoadedAllExtensionDestinations_ = false; | |
719 | 819 |
720 clearTimeout(this.autoSelectTimeout_); | 820 clearTimeout(this.autoSelectTimeout_); |
721 this.autoSelectTimeout_ = setTimeout( | 821 this.autoSelectTimeout_ = setTimeout( |
722 this.selectDefaultDestination_.bind(this), | 822 this.selectDefaultDestination_.bind(this), |
723 DestinationStore.AUTO_SELECT_TIMEOUT_); | 823 DestinationStore.AUTO_SELECT_TIMEOUT_); |
724 }, | 824 }, |
725 | 825 |
726 /** | 826 /** |
727 * Called when the local destinations have been got from the native layer. | 827 * Called when the local destinations have been got from the native layer. |
728 * @param {Event} event Contains the local destinations. | 828 * @param {Event} event Contains the local destinations. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 print_preview.PrivetDestinationParser.parse(event.printer)); | 984 print_preview.PrivetDestinationParser.parse(event.printer)); |
885 } | 985 } |
886 }, | 986 }, |
887 | 987 |
888 /** | 988 /** |
889 * Called when capabilities for a privet printer are set. | 989 * Called when capabilities for a privet printer are set. |
890 * @param {Object} event Contains the capabilities and printer ID. | 990 * @param {Object} event Contains the capabilities and printer ID. |
891 * @private | 991 * @private |
892 */ | 992 */ |
893 onPrivetCapabilitiesSet_: function(event) { | 993 onPrivetCapabilitiesSet_: function(event) { |
894 var destinationId = event.printerId; | |
895 var destinations = | 994 var destinations = |
896 print_preview.PrivetDestinationParser.parse(event.printer); | 995 print_preview.PrivetDestinationParser.parse(event.printer); |
897 destinations.forEach(function(dest) { | 996 destinations.forEach(function(dest) { |
898 dest.capabilities = event.capabilities; | 997 dest.capabilities = event.capabilities; |
899 this.updateDestination_(dest); | 998 this.updateDestination_(dest); |
900 }, this); | 999 }, this); |
901 }, | 1000 }, |
902 | 1001 |
903 /** | 1002 /** |
1003 * Called when an extension responds to a getExtensionDestinations | |
1004 * request. | |
1005 * @param {Object} event Contains information about list of printers | |
1006 * reported by the extension. | |
1007 * {@code done} parameter is set iff this is the final list of printers | |
1008 * returned as part of getExtensionDestinations request. | |
1009 * @private | |
1010 */ | |
1011 onExtensionPrintersAdded_: function(event) { | |
1012 this.insertDestinations_(event.printers.map(function(printer) { | |
1013 return print_preview.ExtensionDestinationParser.parse(printer); | |
1014 })); | |
1015 | |
1016 if (event.done && this.isExtensionDestinationSearchInProgress_) { | |
1017 clearTimeout(this.extensionSearchTimeout_); | |
1018 this.endExtensionPrinterSearch_(); | |
1019 } | |
1020 }, | |
1021 | |
1022 /** | |
1023 * Called when capabilities for an extension managed printer are set. | |
1024 * @param {Object} event Contains the printer's capabilities and ID. | |
1025 * @private | |
1026 */ | |
1027 onExtensionCapabilitiesSet_: function(event) { | |
1028 var destinationKey = this.getDestinationKey_( | |
1029 print_preview.Destination.Origin.EXTENSION, | |
1030 event.printerId, | |
1031 '' /* account */); | |
1032 var destination = this.destinationMap_[destinationKey]; | |
1033 if (!destination) | |
1034 return; | |
1035 destination.capabilities = event.capabilities; | |
1036 this.updateDestination_(destination); | |
1037 }, | |
1038 | |
1039 /** | |
904 * Called from native layer after the user was requested to sign in, and did | 1040 * Called from native layer after the user was requested to sign in, and did |
905 * so successfully. | 1041 * so successfully. |
906 * @private | 1042 * @private |
907 */ | 1043 */ |
908 onDestinationsReload_: function() { | 1044 onDestinationsReload_: function() { |
909 this.reset_(); | 1045 this.reset_(); |
910 this.isInAutoSelectMode_ = true; | 1046 this.isInAutoSelectMode_ = true; |
911 this.createLocalPdfPrintDestination_(); | 1047 this.createLocalPdfPrintDestination_(); |
912 this.startLoadAllDestinations(); | 1048 this.startLoadAllDestinations(); |
913 }, | 1049 }, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 return id == this.appState_.selectedDestinationId && | 1094 return id == this.appState_.selectedDestinationId && |
959 origin == this.appState_.selectedDestinationOrigin; | 1095 origin == this.appState_.selectedDestinationOrigin; |
960 } | 1096 } |
961 }; | 1097 }; |
962 | 1098 |
963 // Export | 1099 // Export |
964 return { | 1100 return { |
965 DestinationStore: DestinationStore | 1101 DestinationStore: DestinationStore |
966 }; | 1102 }; |
967 }); | 1103 }); |
OLD | NEW |