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

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

Issue 2920153004: Print Preview: Change getPrivetPrinters to cr.sendWithPromise (Closed)
Patch Set: Fix closure compile error Created 3 years, 6 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.
11 * @param {!print_preview.NativeLayer} nativeLayer Used to fetch local print 11 * @param {!print_preview.NativeLayer} nativeLayer Used to fetch local print
12 * destinations. 12 * destinations.
13 * @param {!print_preview.UserInfo} userInfo User information repository. 13 * @param {!print_preview.UserInfo} userInfo User information repository.
14 * @param {!print_preview.AppState} appState Application state. 14 * @param {!print_preview.AppState} appState Application state.
15 * @constructor 15 * @constructor
16 * @extends {cr.EventTarget} 16 * @extends {cr.EventTarget}
17 */ 17 */
18 function DestinationStore(nativeLayer, userInfo, appState) { 18 function DestinationStore(nativeLayer, userInfo, appState) {
19 cr.EventTarget.call(this); 19 cr.EventTarget.call(this);
20 20
21 /** 21 /**
22 * Used to fetch local print destinations. 22 * Used to fetch local print destinations.
23 * @type {!print_preview.NativeLayer} 23 * @private {!print_preview.NativeLayer}
24 * @private
25 */ 24 */
26 this.nativeLayer_ = nativeLayer; 25 this.nativeLayer_ = nativeLayer;
27 26
28 /** 27 /**
29 * User information repository. 28 * User information repository.
30 * @type {!print_preview.UserInfo} 29 * @private {!print_preview.UserInfo}
31 * @private
32 */ 30 */
33 this.userInfo_ = userInfo; 31 this.userInfo_ = userInfo;
34 32
35 /** 33 /**
36 * Used to load and persist the selected destination. 34 * Used to load and persist the selected destination.
37 * @type {!print_preview.AppState} 35 * @private {!print_preview.AppState}
38 * @private
39 */ 36 */
40 this.appState_ = appState; 37 this.appState_ = appState;
41 38
42 /** 39 /**
43 * Used to track metrics. 40 * Used to track metrics.
44 * @type {!print_preview.DestinationSearchMetricsContext} 41 * @private {!print_preview.DestinationSearchMetricsContext}
45 * @private
46 */ 42 */
47 this.metrics_ = new print_preview.DestinationSearchMetricsContext(); 43 this.metrics_ = new print_preview.DestinationSearchMetricsContext();
48 44
49 /** 45 /**
50 * Internal backing store for the data store. 46 * Internal backing store for the data store.
51 * @type {!Array<!print_preview.Destination>} 47 * @private {!Array<!print_preview.Destination>}
52 * @private
53 */ 48 */
54 this.destinations_ = []; 49 this.destinations_ = [];
55 50
56 /** 51 /**
57 * Cache used for constant lookup of destinations by origin and id. 52 * Cache used for constant lookup of destinations by origin and id.
58 * @type {Object<!print_preview.Destination>} 53 * @private {Object<!print_preview.Destination>}
59 * @private
60 */ 54 */
61 this.destinationMap_ = {}; 55 this.destinationMap_ = {};
62 56
63 /** 57 /**
64 * Currently selected destination. 58 * Currently selected destination.
65 * @type {print_preview.Destination} 59 * @private {print_preview.Destination}
66 * @private
67 */ 60 */
68 this.selectedDestination_ = null; 61 this.selectedDestination_ = null;
69 62
70 /** 63 /**
71 * Whether the destination store will auto select the destination that 64 * Whether the destination store will auto select the destination that
72 * matches this set of parameters. 65 * matches this set of parameters.
73 * @type {print_preview.DestinationMatch} 66 * @private {print_preview.DestinationMatch}
74 * @private
75 */ 67 */
76 this.autoSelectMatchingDestination_ = null; 68 this.autoSelectMatchingDestination_ = null;
77 69
78 /** 70 /**
79 * Event tracker used to track event listeners of the destination store. 71 * Event tracker used to track event listeners of the destination store.
80 * @type {!EventTracker} 72 * @private {!EventTracker}
81 * @private
82 */ 73 */
83 this.tracker_ = new EventTracker(); 74 this.tracker_ = new EventTracker();
84 75
85 /** 76 /**
86 * Whether PDF printer is enabled. It's disabled, for example, in App Kiosk 77 * Whether PDF printer is enabled. It's disabled, for example, in App Kiosk
87 * mode. 78 * mode.
88 * @type {boolean} 79 * @private {boolean}
89 * @private
90 */ 80 */
91 this.pdfPrinterEnabled_ = false; 81 this.pdfPrinterEnabled_ = false;
92 82
93 /** 83 /**
94 * ID of the system default destination. 84 * ID of the system default destination.
95 * @type {?string} 85 * @private {?string}
96 * @private
97 */ 86 */
98 this.systemDefaultDestinationId_ = null; 87 this.systemDefaultDestinationId_ = null;
99 88
100 /** 89 /**
101 * Used to fetch cloud-based print destinations. 90 * Used to fetch cloud-based print destinations.
102 * @type {cloudprint.CloudPrintInterface} 91 * @private {cloudprint.CloudPrintInterface}
103 * @private
104 */ 92 */
105 this.cloudPrintInterface_ = null; 93 this.cloudPrintInterface_ = null;
106 94
107 /** 95 /**
108 * Maps user account to the list of origins for which destinations are 96 * Maps user account to the list of origins for which destinations are
109 * already loaded. 97 * already loaded.
110 * @type {!Object<Array<print_preview.DestinationOrigin>>} 98 * @private {!Object<Array<print_preview.DestinationOrigin>>}
111 * @private
112 */ 99 */
113 this.loadedCloudOrigins_ = {}; 100 this.loadedCloudOrigins_ = {};
114 101
115 /** 102 /**
116 * ID of a timeout after the initial destination ID is set. If no inserted 103 * ID of a timeout after the initial destination ID is set. If no inserted
117 * destination matches the initial destination ID after the specified 104 * destination matches the initial destination ID after the specified
118 * timeout, the first destination in the store will be automatically 105 * timeout, the first destination in the store will be automatically
119 * selected. 106 * selected.
120 * @type {?number} 107 * @private {?number}
121 * @private
122 */ 108 */
123 this.autoSelectTimeout_ = null; 109 this.autoSelectTimeout_ = null;
124 110
125 /** 111 /**
126 * Whether a search for local destinations is in progress. 112 * Whether a search for local destinations is in progress.
127 * @type {boolean} 113 * @private {boolean}
128 * @private
129 */ 114 */
130 this.isLocalDestinationSearchInProgress_ = false; 115 this.isLocalDestinationSearchInProgress_ = false;
131 116
132 /** 117 /**
133 * Whether the destination store has already loaded or is loading all local 118 * Whether the destination store has already loaded or is loading all local
134 * destinations. 119 * destinations.
135 * @type {boolean} 120 * @private {boolean}
136 * @private
137 */ 121 */
138 this.hasLoadedAllLocalDestinations_ = false; 122 this.hasLoadedAllLocalDestinations_ = false;
139 123
140 /** 124 /**
141 * Whether a search for privet destinations is in progress. 125 * Whether a search for privet destinations is in progress.
142 * @type {boolean} 126 * @private {boolean}
143 * @private
144 */ 127 */
145 this.isPrivetDestinationSearchInProgress_ = false; 128 this.isPrivetDestinationSearchInProgress_ = false;
146 129
147 /** 130 /**
148 * Whether the destination store has already loaded or is loading all privet 131 * Whether the destination store has already loaded or is loading all privet
149 * destinations. 132 * destinations.
150 * @type {boolean} 133 * @private {boolean}
151 * @private
152 */ 134 */
153 this.hasLoadedAllPrivetDestinations_ = false; 135 this.hasLoadedAllPrivetDestinations_ = false;
154 136
155 /** 137 /**
156 * ID of a timeout after the start of a privet search to end that privet
157 * search.
158 * @type {?number}
159 * @private
160 */
161 this.privetSearchTimeout_ = null;
162
163 /**
164 * Whether a search for extension destinations is in progress. 138 * Whether a search for extension destinations is in progress.
165 * @type {boolean} 139 * @private {boolean}
166 * @private
167 */ 140 */
168 this.isExtensionDestinationSearchInProgress_ = false; 141 this.isExtensionDestinationSearchInProgress_ = false;
169 142
170 /** 143 /**
171 * Whether the destination store has already loaded all extension 144 * Whether the destination store has already loaded all extension
172 * destinations. 145 * destinations.
173 * @type {boolean} 146 * @private {boolean}
174 * @private
175 */ 147 */
176 this.hasLoadedAllExtensionDestinations_ = false; 148 this.hasLoadedAllExtensionDestinations_ = false;
177 149
178 /** 150 /**
179 * ID of a timeout set at the start of an extension destination search. The 151 * ID of a timeout set at the start of an extension destination search. The
180 * timeout ends the search. 152 * timeout ends the search.
181 * @type {?number} 153 * @private {?number}
182 * @private
183 */ 154 */
184 this.extensionSearchTimeout_ = null; 155 this.extensionSearchTimeout_ = null;
185 156
186 /** 157 /**
187 * MDNS service name of destination that we are waiting to register. 158 * MDNS service name of destination that we are waiting to register.
188 * @type {?string} 159 * @private {?string}
189 * @private
190 */ 160 */
191 this.waitForRegisterDestination_ = null; 161 this.waitForRegisterDestination_ = null;
192 162
193 /** 163 /**
194 * Local destinations are CROS destinations on ChromeOS because they require 164 * Local destinations are CROS destinations on ChromeOS because they require
195 * extra setup. 165 * extra setup.
196 * @type {!print_preview.DestinationOrigin} 166 * @private {!print_preview.DestinationOrigin}
197 * @private
198 */ 167 */
199 this.platformOrigin_ = cr.isChromeOS ? 168 this.platformOrigin_ = cr.isChromeOS ?
200 print_preview.DestinationOrigin.CROS : 169 print_preview.DestinationOrigin.CROS :
201 print_preview.DestinationOrigin.LOCAL; 170 print_preview.DestinationOrigin.LOCAL;
202 171
203 this.addEventListeners_(); 172 this.addEventListeners_();
204 this.reset_(); 173 this.reset_();
205 } 174 }
206 175
207 /** 176 /**
(...skipping 20 matching lines...) Expand all
228 /** 197 /**
229 * Delay in milliseconds before the destination store ignores the initial 198 * Delay in milliseconds before the destination store ignores the initial
230 * destination ID and just selects any printer (since the initial destination 199 * destination ID and just selects any printer (since the initial destination
231 * was not found). 200 * was not found).
232 * @private {number} 201 * @private {number}
233 * @const 202 * @const
234 */ 203 */
235 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; 204 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000;
236 205
237 /** 206 /**
238 * Amount of time spent searching for privet destination, in milliseconds.
239 * @private {number}
240 * @const
241 */
242 DestinationStore.PRIVET_SEARCH_DURATION_ = 5000;
243
244 /**
245 * Maximum amount of time spent searching for extension destinations, in 207 * Maximum amount of time spent searching for extension destinations, in
246 * milliseconds. 208 * milliseconds.
247 * @private {number} 209 * @private {number}
248 * @const 210 * @const
249 */ 211 */
250 DestinationStore.EXTENSION_SEARCH_DURATION_ = 5000; 212 DestinationStore.EXTENSION_SEARCH_DURATION_ = 5000;
251 213
252 /** 214 /**
253 * Human readable names for media sizes in the cloud print CDD. 215 * Human readable names for media sizes in the cloud print CDD.
254 * https://developers.google.com/cloud-print/docs/cdd 216 * https://developers.google.com/cloud-print/docs/cdd
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 this.cloudPrintInterface_.printer( 678 this.cloudPrintInterface_.printer(
717 id, 679 id,
718 /** @type {print_preview.DestinationOrigin} */(origin), 680 /** @type {print_preview.DestinationOrigin} */(origin),
719 account); 681 account);
720 return true; 682 return true;
721 } 683 }
722 684
723 if (origin == print_preview.DestinationOrigin.PRIVET) { 685 if (origin == print_preview.DestinationOrigin.PRIVET) {
724 // TODO(noamsml): Resolve a specific printer instead of listing all 686 // TODO(noamsml): Resolve a specific printer instead of listing all
725 // privet printers in this case. 687 // privet printers in this case.
726 this.nativeLayer_.startGetPrivetDestinations(); 688 cr.addWebUIListener('privet-printer-added',
dpapad 2017/06/06 21:16:33 Is fetchPreselectedDestination_ only called once?
rbpotter 2017/06/07 02:37:46 Done. This can be called once or not at all, and s
689 this.onPrivetPrinterAdded_.bind(this));
690 this.nativeLayer_.getPrivetPrinters().then(
691 this.endPrivetPrinterSearch_.bind(this));
727 692
728 // Create a fake selectedDestination_ that is not actually in the 693 // Create a fake selectedDestination_ that is not actually in the
729 // destination store. When the real destination is created, this 694 // destination store. When the real destination is created, this
730 // destination will be overwritten. 695 // destination will be overwritten.
731 this.selectedDestination_ = new print_preview.Destination( 696 this.selectedDestination_ = new print_preview.Destination(
732 id, 697 id,
733 print_preview.DestinationType.LOCAL, 698 print_preview.DestinationType.LOCAL,
734 print_preview.DestinationOrigin.PRIVET, 699 print_preview.DestinationOrigin.PRIVET,
735 name, 700 name,
736 false /*isRecent*/, 701 false /*isRecent*/,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 this.nativeLayer_.getPrinters().then( 1046 this.nativeLayer_.getPrinters().then(
1082 this.onLocalDestinationsSet_.bind(this)); 1047 this.onLocalDestinationsSet_.bind(this));
1083 this.isLocalDestinationSearchInProgress_ = true; 1048 this.isLocalDestinationSearchInProgress_ = true;
1084 cr.dispatchSimpleEvent( 1049 cr.dispatchSimpleEvent(
1085 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 1050 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
1086 } 1051 }
1087 }, 1052 },
1088 1053
1089 /** Initiates loading of privet print destinations. */ 1054 /** Initiates loading of privet print destinations. */
1090 startLoadPrivetDestinations: function() { 1055 startLoadPrivetDestinations: function() {
1091 if (!this.hasLoadedAllPrivetDestinations_) { 1056 if (this.hasLoadedAllPrivetDestinations_)
1092 if (this.privetDestinationSearchInProgress_) 1057 return;
1093 clearTimeout(this.privetSearchTimeout_); 1058 this.isPrivetDestinationSearchInProgress_ = true;
1094 this.isPrivetDestinationSearchInProgress_ = true; 1059 cr.addWebUIListener('privet-printer-added',
dpapad 2017/06/06 21:16:33 Same question here. Do we need to register this li
rbpotter 2017/06/07 02:37:46 Done.
1095 this.nativeLayer_.startGetPrivetDestinations(); 1060 this.onPrivetPrinterAdded_.bind(this));
1096 cr.dispatchSimpleEvent( 1061 this.nativeLayer_.getPrivetPrinters().then(
1097 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 1062 this.endPrivetPrinterSearch_.bind(this),
1098 this.privetSearchTimeout_ = setTimeout( 1063 function() {
1099 this.endPrivetPrinterSearch_.bind(this), 1064 // Rejected by C++, indicating privet printing is disabled.
1100 DestinationStore.PRIVET_SEARCH_DURATION_); 1065 this.hasLoadedAllPrivetDestinations_ = true;
1101 } 1066 this.isPrivetDestinationSearchInProgress_ = false;
1067 }.bind(this));
1068 cr.dispatchSimpleEvent(
1069 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
1102 }, 1070 },
1103 1071
1104 /** Initializes loading of extension managed print destinations. */ 1072 /** Initializes loading of extension managed print destinations. */
1105 startLoadExtensionDestinations: function() { 1073 startLoadExtensionDestinations: function() {
1106 if (this.hasLoadedAllExtensionDestinations_) 1074 if (this.hasLoadedAllExtensionDestinations_)
1107 return; 1075 return;
1108 1076
1109 if (this.isExtensionDestinationSearchInProgress_) 1077 if (this.isExtensionDestinationSearchInProgress_)
1110 clearTimeout(this.extensionSearchTimeout_); 1078 clearTimeout(this.extensionSearchTimeout_);
1111 1079
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 this.startLoadCloudDestinations(); 1125 this.startLoadCloudDestinations();
1158 this.startLoadLocalDestinations(); 1126 this.startLoadLocalDestinations();
1159 this.startLoadPrivetDestinations(); 1127 this.startLoadPrivetDestinations();
1160 this.startLoadExtensionDestinations(); 1128 this.startLoadExtensionDestinations();
1161 }, 1129 },
1162 1130
1163 /** 1131 /**
1164 * Wait for a privet device to be registered. 1132 * Wait for a privet device to be registered.
1165 */ 1133 */
1166 waitForRegister: function(id) { 1134 waitForRegister: function(id) {
1167 this.nativeLayer_.startGetPrivetDestinations(); 1135 cr.addWebUIListener('privet-printer-added',
1136 this.onPrivetPrinterAdded_.bind(this));
1137 this.nativeLayer_.getPrivetPrinters().then(
1138 this.endPrivetPrinterSearch_.bind(this));
1168 this.waitForRegisterDestination_ = id; 1139 this.waitForRegisterDestination_ = id;
1169 }, 1140 },
1170 1141
1171 /** 1142 /**
1172 * Event handler for {@code 1143 * Event handler for {@code
1173 * print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED}. 1144 * print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED}.
1174 * Currently assumes the provisional destination is an extension 1145 * Currently assumes the provisional destination is an extension
1175 * destination. 1146 * destination.
1176 * Called when a provisional destination resolvement attempt finishes. 1147 * Called when a provisional destination resolvement attempt finishes.
1177 * The provisional destination is removed from the store and replaced with 1148 * The provisional destination is removed from the store and replaced with
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 this, 1267 this,
1297 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); 1268 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY);
1298 } 1269 }
1299 }, 1270 },
1300 1271
1301 /** 1272 /**
1302 * Called when the search for Privet printers is done. 1273 * Called when the search for Privet printers is done.
1303 * @private 1274 * @private
1304 */ 1275 */
1305 endPrivetPrinterSearch_: function() { 1276 endPrivetPrinterSearch_: function() {
1306 this.nativeLayer_.stopGetPrivetDestinations();
1307 this.isPrivetDestinationSearchInProgress_ = false; 1277 this.isPrivetDestinationSearchInProgress_ = false;
1308 this.hasLoadedAllPrivetDestinations_ = true; 1278 this.hasLoadedAllPrivetDestinations_ = true;
1309 cr.dispatchSimpleEvent( 1279 cr.dispatchSimpleEvent(
1310 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); 1280 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE);
1311 }, 1281 },
1312 1282
1313 /** 1283 /**
1314 * Called when loading of extension managed printers is done. 1284 * Called when loading of extension managed printers is done.
1315 * @private 1285 * @private
1316 */ 1286 */
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 this.tracker_.add( 1342 this.tracker_.add(
1373 nativeLayerEventTarget, 1343 nativeLayerEventTarget,
1374 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL, 1344 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL,
1375 this.onGetCapabilitiesFail_.bind(this)); 1345 this.onGetCapabilitiesFail_.bind(this));
1376 this.tracker_.add( 1346 this.tracker_.add(
1377 nativeLayerEventTarget, 1347 nativeLayerEventTarget,
1378 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, 1348 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD,
1379 this.onDestinationsReload_.bind(this)); 1349 this.onDestinationsReload_.bind(this));
1380 this.tracker_.add( 1350 this.tracker_.add(
1381 nativeLayerEventTarget, 1351 nativeLayerEventTarget,
1382 print_preview.NativeLayer.EventType.PRIVET_PRINTER_CHANGED,
1383 this.onPrivetPrinterAdded_.bind(this));
1384 this.tracker_.add(
1385 nativeLayerEventTarget,
1386 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET, 1352 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET,
1387 this.onPrivetCapabilitiesSet_.bind(this)); 1353 this.onPrivetCapabilitiesSet_.bind(this));
1388 this.tracker_.add( 1354 this.tracker_.add(
1389 nativeLayerEventTarget, 1355 nativeLayerEventTarget,
1390 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, 1356 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET,
1391 this.onExtensionCapabilitiesSet_.bind(this)); 1357 this.onExtensionCapabilitiesSet_.bind(this));
1392 this.tracker_.add( 1358 this.tracker_.add(
1393 nativeLayerEventTarget, 1359 nativeLayerEventTarget,
1394 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED, 1360 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED,
1395 this.handleProvisionalDestinationResolved_.bind(this)); 1361 this.handleProvisionalDestinationResolved_.bind(this));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 onCloudPrintProcessInviteDone_: function(event) { 1548 onCloudPrintProcessInviteDone_: function(event) {
1583 if (event.accept && event.printer) { 1549 if (event.accept && event.printer) {
1584 // Hint the destination list to promote this new destination. 1550 // Hint the destination list to promote this new destination.
1585 event.printer.isRecent = true; 1551 event.printer.isRecent = true;
1586 this.insertDestination_(event.printer); 1552 this.insertDestination_(event.printer);
1587 } 1553 }
1588 }, 1554 },
1589 1555
1590 /** 1556 /**
1591 * Called when a Privet printer is added to the local network. 1557 * Called when a Privet printer is added to the local network.
1592 * @param {{printer: {serviceName: string, 1558 * @param {!{serviceName: string,
1593 * name: string, 1559 * name: string,
1594 * hasLocalPrinting: boolean, 1560 * hasLocalPrinting: boolean,
1595 * isUnregistered: boolean, 1561 * isUnregistered: boolean,
1596 * cloudID: string}}} event Contains information about 1562 * cloudID: string}} printer Information about the added printer.
1597 * the added printer.
1598 * @private 1563 * @private
1599 */ 1564 */
1600 onPrivetPrinterAdded_: function(event) { 1565 onPrivetPrinterAdded_: function(printer) {
1601 if (event.printer.serviceName == this.waitForRegisterDestination_ && 1566 if (printer.serviceName == this.waitForRegisterDestination_ &&
1602 !event.printer.isUnregistered) { 1567 !printer.isUnregistered) {
1603 this.waitForRegisterDestination_ = null; 1568 this.waitForRegisterDestination_ = null;
1604 this.onDestinationsReload_(); 1569 this.onDestinationsReload_();
1605 } else { 1570 } else {
1606 this.insertDestinations_( 1571 this.insertDestinations_(
1607 print_preview.PrivetDestinationParser.parse(event.printer)); 1572 print_preview.PrivetDestinationParser.parse(printer));
1608 } 1573 }
1609 }, 1574 },
1610 1575
1611 /** 1576 /**
1612 * Called when capabilities for a privet printer are set. 1577 * Called when capabilities for a privet printer are set.
1613 * @param {Object} event Contains the capabilities and printer ID. 1578 * @param {Object} event Contains the capabilities and printer ID.
1614 * @private 1579 * @private
1615 */ 1580 */
1616 onPrivetCapabilitiesSet_: function(event) { 1581 onPrivetCapabilitiesSet_: function(event) {
1617 var destinations = 1582 var destinations =
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 return this.getDestinationKey_( 1669 return this.getDestinationKey_(
1705 destination.origin, destination.id, destination.account); 1670 destination.origin, destination.id, destination.account);
1706 } 1671 }
1707 }; 1672 };
1708 1673
1709 // Export 1674 // Export
1710 return { 1675 return {
1711 DestinationStore: DestinationStore 1676 DestinationStore: DestinationStore
1712 }; 1677 };
1713 }); 1678 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698