Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: chrome/browser/resources/print_preview/data/destination_store.js

Issue 606213002: Compile print_preview, part 6: reduce down to 48 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@J_print_preview_5
Patch Set: vitalybuka@'s review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 /** 195 /**
196 * Amount of time spent searching for privet destination, in milliseconds. 196 * Amount of time spent searching for privet destination, in milliseconds.
197 * @type {number} 197 * @type {number}
198 * @const 198 * @const
199 * @private 199 * @private
200 */ 200 */
201 DestinationStore.PRIVET_SEARCH_DURATION_ = 2000; 201 DestinationStore.PRIVET_SEARCH_DURATION_ = 2000;
202 202
203 /** 203 /**
204 * Localizes printer capabilities. 204 * Localizes printer capabilities.
205 * @param {!Object} capabilities Printer capabilities to localize. 205 * @param {!print_preview.Cdd} capabilities Printer capabilities to localize.
206 * @return {!Object} Localized capabilities. 206 * @return {!print_preview.Cdd} Localized capabilities.
207 * @private 207 * @private
208 */ 208 */
209 DestinationStore.localizeCapabilities_ = function(capabilities) { 209 DestinationStore.localizeCapabilities_ = function(capabilities) {
210 var mediaSize = capabilities.printer.media_size; 210 var mediaSize = capabilities.printer.media_size;
211 if (mediaSize) { 211 if (mediaSize) {
212 var mediaDisplayNames = { 212 var mediaDisplayNames = {
213 'ISO_A4': 'A4', 213 'ISO_A4': 'A4',
214 'ISO_A3': 'A3', 214 'ISO_A3': 'A3',
215 'NA_LETTER': 'Letter', 215 'NA_LETTER': 'Letter',
216 'NA_LEGAL': 'Legal', 216 'NA_LEGAL': 'Legal',
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 487 }
488 }, 488 },
489 489
490 /** 490 /**
491 * Initiates loading of cloud destinations. 491 * Initiates loading of cloud destinations.
492 * @param {print_preview.Destination.Origin=} opt_origin Search destinations 492 * @param {print_preview.Destination.Origin=} opt_origin Search destinations
493 * for the specified origin only. 493 * for the specified origin only.
494 */ 494 */
495 startLoadCloudDestinations: function(opt_origin) { 495 startLoadCloudDestinations: function(opt_origin) {
496 if (this.cloudPrintInterface_ != null) { 496 if (this.cloudPrintInterface_ != null) {
497 var origins = this.loadedCloudOrigins_[this.userInfo_.activeUser] || []; 497 var origins = this.userInfo_.activeUser ?
498 (this.loadedCloudOrigins_[this.userInfo_.activeUser] || []) : [];
498 if (origins.length == 0 || 499 if (origins.length == 0 ||
499 (opt_origin && origins.indexOf(opt_origin) < 0)) { 500 (opt_origin && origins.indexOf(opt_origin) < 0)) {
500 this.cloudPrintInterface_.search( 501 this.cloudPrintInterface_.search(
501 this.userInfo_.activeUser, opt_origin); 502 this.userInfo_.activeUser, opt_origin);
502 cr.dispatchSimpleEvent( 503 cr.dispatchSimpleEvent(
503 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 504 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
504 } 505 }
505 } 506 }
506 }, 507 },
507 508
508 /** Requests load of COOKIE based cloud destinations. */ 509 /** Requests load of COOKIE based cloud destinations. */
509 reloadUserCookieBasedDestinations: function() { 510 reloadUserCookieBasedDestinations: function() {
510 var origins = this.loadedCloudOrigins_[this.userInfo_.activeUser] || []; 511 var origins = this.userInfo_.activeUser ?
512 (this.loadedCloudOrigins_[this.userInfo_.activeUser] || []) : [];
511 if (origins.indexOf(print_preview.Destination.Origin.COOKIES) >= 0) { 513 if (origins.indexOf(print_preview.Destination.Origin.COOKIES) >= 0) {
512 cr.dispatchSimpleEvent( 514 cr.dispatchSimpleEvent(
513 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); 515 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE);
514 } else { 516 } else {
515 this.startLoadCloudDestinations( 517 this.startLoadCloudDestinations(
516 print_preview.Destination.Origin.COOKIES); 518 print_preview.Destination.Origin.COOKIES);
517 } 519 }
518 }, 520 },
519 521
520 /** Initiates loading of all known destination types. */ 522 /** Initiates loading of all known destination types. */
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 /** 736 /**
735 * Called when the native layer retrieves the capabilities for the selected 737 * Called when the native layer retrieves the capabilities for the selected
736 * local destination. Updates the destination with new capabilities if the 738 * local destination. Updates the destination with new capabilities if the
737 * destination already exists, otherwise it creates a new destination and 739 * destination already exists, otherwise it creates a new destination and
738 * then updates its capabilities. 740 * then updates its capabilities.
739 * @param {Event} event Contains the capabilities of the local print 741 * @param {Event} event Contains the capabilities of the local print
740 * destination. 742 * destination.
741 * @private 743 * @private
742 */ 744 */
743 onLocalDestinationCapabilitiesSet_: function(event) { 745 onLocalDestinationCapabilitiesSet_: function(event) {
744 var destinationId = event.settingsInfo['printerId']; 746 var destinationId = /** @type {string} */(
747 event.settingsInfo['printerId']);
745 var key = this.getDestinationKey_( 748 var key = this.getDestinationKey_(
746 print_preview.Destination.Origin.LOCAL, 749 print_preview.Destination.Origin.LOCAL,
747 destinationId, 750 destinationId,
748 ''); 751 '');
749 var destination = this.destinationMap_[key]; 752 var destination = this.destinationMap_[key];
750 var capabilities = DestinationStore.localizeCapabilities_( 753 var capabilities = DestinationStore.localizeCapabilities_(
751 event.settingsInfo.capabilities); 754 event.settingsInfo.capabilities);
752 // Special case for PDF printer (until local printers capabilities are 755 // Special case for PDF printer (until local printers capabilities are
753 // reported in CDD format too). 756 // reported in CDD format too).
754 if (destinationId == 757 if (destinationId ==
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 onCloudPrintProcessInviteDone_: function(event) { 860 onCloudPrintProcessInviteDone_: function(event) {
858 if (event.accept && event.printer) { 861 if (event.accept && event.printer) {
859 // Hint the destination list to promote this new destination. 862 // Hint the destination list to promote this new destination.
860 event.printer.isRecent = true; 863 event.printer.isRecent = true;
861 this.insertDestination_(event.printer); 864 this.insertDestination_(event.printer);
862 } 865 }
863 }, 866 },
864 867
865 /** 868 /**
866 * Called when a Privet printer is added to the local network. 869 * Called when a Privet printer is added to the local network.
867 * @param {Object} event Contains information about the added printer. 870 * @param {{printer: {serviceName: string,
871 * name: string,
872 * hasLocalPrinting: boolean,
873 * isUnregistered: boolean,
874 * cloudID: string}}} event Contains information about
875 * the added printer.
868 * @private 876 * @private
869 */ 877 */
870 onPrivetPrinterAdded_: function(event) { 878 onPrivetPrinterAdded_: function(event) {
871 if (event.printer.serviceName == this.waitForRegisterDestination_ && 879 if (event.printer.serviceName == this.waitForRegisterDestination_ &&
872 !event.printer.isUnregistered) { 880 !event.printer.isUnregistered) {
873 this.waitForRegisterDestination_ = null; 881 this.waitForRegisterDestination_ = null;
874 this.onDestinationsReload_(); 882 this.onDestinationsReload_();
875 } else { 883 } else {
876 this.insertDestinations_( 884 this.insertDestinations_(
877 print_preview.PrivetDestinationParser.parse(event.printer)); 885 print_preview.PrivetDestinationParser.parse(event.printer));
878 } 886 }
879 }, 887 },
880 888
881 /** 889 /**
882 * Called when capabilities for a privet printer are set. 890 * Called when capabilities for a privet printer are set.
883 * @param {Object} event Contains the capabilities and printer ID. 891 * @param {Object} event Contains the capabilities and printer ID.
884 * @private 892 * @private
885 */ 893 */
886 onPrivetCapabilitiesSet_: function(event) { 894 onPrivetCapabilitiesSet_: function(event) {
887 var destinationId = event.printerId;
888 var destinations = 895 var destinations =
889 print_preview.PrivetDestinationParser.parse(event.printer); 896 print_preview.PrivetDestinationParser.parse(event.printer);
890 destinations.forEach(function(dest) { 897 destinations.forEach(function(dest) {
891 dest.capabilities = event.capabilities; 898 dest.capabilities = event.capabilities;
892 this.updateDestination_(dest); 899 this.updateDestination_(dest);
893 }, this); 900 }, this);
894 }, 901 },
895 902
896 /** 903 /**
897 * Called from native layer after the user was requested to sign in, and did 904 * Called from native layer after the user was requested to sign in, and did
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 return id == this.appState_.selectedDestinationId && 958 return id == this.appState_.selectedDestinationId &&
952 origin == this.appState_.selectedDestinationOrigin; 959 origin == this.appState_.selectedDestinationOrigin;
953 } 960 }
954 }; 961 };
955 962
956 // Export 963 // Export
957 return { 964 return {
958 DestinationStore: DestinationStore 965 DestinationStore: DestinationStore
959 }; 966 };
960 }); 967 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698