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

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: Change notation 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/native_layer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized 550 * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized
589 * default destination selection rules. 551 * default destination selection rules.
590 */ 552 */
591 init: function( 553 init: function(
592 isInAppKioskMode, 554 isInAppKioskMode,
593 systemDefaultDestinationId, 555 systemDefaultDestinationId,
594 serializedDefaultDestinationSelectionRulesStr) { 556 serializedDefaultDestinationSelectionRulesStr) {
595 this.pdfPrinterEnabled_ = !isInAppKioskMode; 557 this.pdfPrinterEnabled_ = !isInAppKioskMode;
596 this.systemDefaultDestinationId_ = systemDefaultDestinationId; 558 this.systemDefaultDestinationId_ = systemDefaultDestinationId;
597 this.createLocalPdfPrintDestination_(); 559 this.createLocalPdfPrintDestination_();
560 cr.addWebUIListener('privet-printer-added',
561 this.onPrivetPrinterAdded_.bind(this));
598 cr.addWebUIListener('extension-printers-added', 562 cr.addWebUIListener('extension-printers-added',
599 this.onExtensionPrintersAdded_.bind(this)); 563 this.onExtensionPrintersAdded_.bind(this));
600 564
601 if (!this.appState_.isSelectedDestinationValid()) { 565 if (!this.appState_.isSelectedDestinationValid()) {
602 var destinationMatch = this.convertToDestinationMatch_( 566 var destinationMatch = this.convertToDestinationMatch_(
603 serializedDefaultDestinationSelectionRulesStr); 567 serializedDefaultDestinationSelectionRulesStr);
604 if (destinationMatch) { 568 if (destinationMatch) {
605 this.fetchMatchingDestination_(destinationMatch); 569 this.fetchMatchingDestination_(destinationMatch);
606 return; 570 return;
607 } 571 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 this.cloudPrintInterface_.printer( 682 this.cloudPrintInterface_.printer(
719 id, 683 id,
720 /** @type {print_preview.DestinationOrigin} */(origin), 684 /** @type {print_preview.DestinationOrigin} */(origin),
721 account); 685 account);
722 return true; 686 return true;
723 } 687 }
724 688
725 if (origin == print_preview.DestinationOrigin.PRIVET) { 689 if (origin == print_preview.DestinationOrigin.PRIVET) {
726 // TODO(noamsml): Resolve a specific printer instead of listing all 690 // TODO(noamsml): Resolve a specific printer instead of listing all
727 // privet printers in this case. 691 // privet printers in this case.
728 this.nativeLayer_.startGetPrivetDestinations(); 692 this.nativeLayer_.getPrivetPrinters().then(
693 this.endPrivetPrinterSearch_.bind(this));
729 694
730 // Create a fake selectedDestination_ that is not actually in the 695 // Create a fake selectedDestination_ that is not actually in the
731 // destination store. When the real destination is created, this 696 // destination store. When the real destination is created, this
732 // destination will be overwritten. 697 // destination will be overwritten.
733 this.selectedDestination_ = new print_preview.Destination( 698 this.selectedDestination_ = new print_preview.Destination(
734 id, 699 id,
735 print_preview.DestinationType.LOCAL, 700 print_preview.DestinationType.LOCAL,
736 print_preview.DestinationOrigin.PRIVET, 701 print_preview.DestinationOrigin.PRIVET,
737 name, 702 name,
738 false /*isRecent*/, 703 false /*isRecent*/,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 this.nativeLayer_.getPrinters().then( 1048 this.nativeLayer_.getPrinters().then(
1084 this.onLocalDestinationsSet_.bind(this)); 1049 this.onLocalDestinationsSet_.bind(this));
1085 this.isLocalDestinationSearchInProgress_ = true; 1050 this.isLocalDestinationSearchInProgress_ = true;
1086 cr.dispatchSimpleEvent( 1051 cr.dispatchSimpleEvent(
1087 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 1052 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
1088 } 1053 }
1089 }, 1054 },
1090 1055
1091 /** Initiates loading of privet print destinations. */ 1056 /** Initiates loading of privet print destinations. */
1092 startLoadPrivetDestinations: function() { 1057 startLoadPrivetDestinations: function() {
1093 if (!this.hasLoadedAllPrivetDestinations_) { 1058 if (this.hasLoadedAllPrivetDestinations_)
1094 if (this.privetDestinationSearchInProgress_) 1059 return;
1095 clearTimeout(this.privetSearchTimeout_); 1060 this.isPrivetDestinationSearchInProgress_ = true;
1096 this.isPrivetDestinationSearchInProgress_ = true; 1061 this.nativeLayer_.getPrivetPrinters().then(
1097 this.nativeLayer_.startGetPrivetDestinations(); 1062 this.endPrivetPrinterSearch_.bind(this),
1098 cr.dispatchSimpleEvent( 1063 function() {
1099 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 1064 // Rejected by C++, indicating privet printing is disabled.
1100 this.privetSearchTimeout_ = setTimeout( 1065 this.hasLoadedAllPrivetDestinations_ = true;
1101 this.endPrivetPrinterSearch_.bind(this), 1066 this.isPrivetDestinationSearchInProgress_ = false;
1102 DestinationStore.PRIVET_SEARCH_DURATION_); 1067 }.bind(this));
1103 } 1068 cr.dispatchSimpleEvent(
1069 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
1104 }, 1070 },
1105 1071
1106 /** Initializes loading of extension managed print destinations. */ 1072 /** Initializes loading of extension managed print destinations. */
1107 startLoadExtensionDestinations: function() { 1073 startLoadExtensionDestinations: function() {
1108 if (this.hasLoadedAllExtensionDestinations_) 1074 if (this.hasLoadedAllExtensionDestinations_)
1109 return; 1075 return;
1110 1076
1111 if (this.isExtensionDestinationSearchInProgress_) 1077 if (this.isExtensionDestinationSearchInProgress_)
1112 clearTimeout(this.extensionSearchTimeout_); 1078 clearTimeout(this.extensionSearchTimeout_);
1113 1079
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 this.startLoadCloudDestinations(); 1122 this.startLoadCloudDestinations();
1157 this.startLoadLocalDestinations(); 1123 this.startLoadLocalDestinations();
1158 this.startLoadPrivetDestinations(); 1124 this.startLoadPrivetDestinations();
1159 this.startLoadExtensionDestinations(); 1125 this.startLoadExtensionDestinations();
1160 }, 1126 },
1161 1127
1162 /** 1128 /**
1163 * Wait for a privet device to be registered. 1129 * Wait for a privet device to be registered.
1164 */ 1130 */
1165 waitForRegister: function(id) { 1131 waitForRegister: function(id) {
1166 this.nativeLayer_.startGetPrivetDestinations(); 1132 this.nativeLayer_.getPrivetPrinters().then(
1133 this.endPrivetPrinterSearch_.bind(this));
1167 this.waitForRegisterDestination_ = id; 1134 this.waitForRegisterDestination_ = id;
1168 }, 1135 },
1169 1136
1170 /** 1137 /**
1171 * Event handler for {@code 1138 * Event handler for {@code
1172 * print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED}. 1139 * print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED}.
1173 * Currently assumes the provisional destination is an extension 1140 * Currently assumes the provisional destination is an extension
1174 * destination. 1141 * destination.
1175 * Called when a provisional destination resolvement attempt finishes. 1142 * Called when a provisional destination resolvement attempt finishes.
1176 * The provisional destination is removed from the store and replaced with 1143 * The provisional destination is removed from the store and replaced with
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 this, 1262 this,
1296 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY); 1263 DestinationStore.EventType.SELECTED_DESTINATION_CAPABILITIES_READY);
1297 } 1264 }
1298 }, 1265 },
1299 1266
1300 /** 1267 /**
1301 * Called when the search for Privet printers is done. 1268 * Called when the search for Privet printers is done.
1302 * @private 1269 * @private
1303 */ 1270 */
1304 endPrivetPrinterSearch_: function() { 1271 endPrivetPrinterSearch_: function() {
1305 this.nativeLayer_.stopGetPrivetDestinations();
1306 this.isPrivetDestinationSearchInProgress_ = false; 1272 this.isPrivetDestinationSearchInProgress_ = false;
1307 this.hasLoadedAllPrivetDestinations_ = true; 1273 this.hasLoadedAllPrivetDestinations_ = true;
1308 cr.dispatchSimpleEvent( 1274 cr.dispatchSimpleEvent(
1309 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); 1275 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE);
1310 }, 1276 },
1311 1277
1312 /** 1278 /**
1313 * Called when loading of extension managed printers is done. 1279 * Called when loading of extension managed printers is done.
1314 * @private 1280 * @private
1315 */ 1281 */
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 this.tracker_.add( 1337 this.tracker_.add(
1372 nativeLayerEventTarget, 1338 nativeLayerEventTarget,
1373 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL, 1339 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL,
1374 this.onGetCapabilitiesFail_.bind(this)); 1340 this.onGetCapabilitiesFail_.bind(this));
1375 this.tracker_.add( 1341 this.tracker_.add(
1376 nativeLayerEventTarget, 1342 nativeLayerEventTarget,
1377 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, 1343 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD,
1378 this.onDestinationsReload_.bind(this)); 1344 this.onDestinationsReload_.bind(this));
1379 this.tracker_.add( 1345 this.tracker_.add(
1380 nativeLayerEventTarget, 1346 nativeLayerEventTarget,
1381 print_preview.NativeLayer.EventType.PRIVET_PRINTER_CHANGED,
1382 this.onPrivetPrinterAdded_.bind(this));
1383 this.tracker_.add(
1384 nativeLayerEventTarget,
1385 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET, 1347 print_preview.NativeLayer.EventType.PRIVET_CAPABILITIES_SET,
1386 this.onPrivetCapabilitiesSet_.bind(this)); 1348 this.onPrivetCapabilitiesSet_.bind(this));
1387 this.tracker_.add( 1349 this.tracker_.add(
1388 nativeLayerEventTarget, 1350 nativeLayerEventTarget,
1389 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET, 1351 print_preview.NativeLayer.EventType.EXTENSION_CAPABILITIES_SET,
1390 this.onExtensionCapabilitiesSet_.bind(this)); 1352 this.onExtensionCapabilitiesSet_.bind(this));
1391 this.tracker_.add( 1353 this.tracker_.add(
1392 nativeLayerEventTarget, 1354 nativeLayerEventTarget,
1393 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED, 1355 print_preview.NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED,
1394 this.handleProvisionalDestinationResolved_.bind(this)); 1356 this.handleProvisionalDestinationResolved_.bind(this));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 onCloudPrintProcessInviteDone_: function(event) { 1543 onCloudPrintProcessInviteDone_: function(event) {
1582 if (event.accept && event.printer) { 1544 if (event.accept && event.printer) {
1583 // Hint the destination list to promote this new destination. 1545 // Hint the destination list to promote this new destination.
1584 event.printer.isRecent = true; 1546 event.printer.isRecent = true;
1585 this.insertDestination_(event.printer); 1547 this.insertDestination_(event.printer);
1586 } 1548 }
1587 }, 1549 },
1588 1550
1589 /** 1551 /**
1590 * Called when a Privet printer is added to the local network. 1552 * Called when a Privet printer is added to the local network.
1591 * @param {{printer: {serviceName: string, 1553 * @param {!{serviceName: string,
1592 * name: string, 1554 * name: string,
1593 * hasLocalPrinting: boolean, 1555 * hasLocalPrinting: boolean,
1594 * isUnregistered: boolean, 1556 * isUnregistered: boolean,
1595 * cloudID: string}}} event Contains information about 1557 * cloudID: string}} printer Information about the added printer.
1596 * the added printer.
1597 * @private 1558 * @private
1598 */ 1559 */
1599 onPrivetPrinterAdded_: function(event) { 1560 onPrivetPrinterAdded_: function(printer) {
1600 if (event.printer.serviceName == this.waitForRegisterDestination_ && 1561 if (printer.serviceName == this.waitForRegisterDestination_ &&
1601 !event.printer.isUnregistered) { 1562 !printer.isUnregistered) {
1602 this.waitForRegisterDestination_ = null; 1563 this.waitForRegisterDestination_ = null;
1603 this.onDestinationsReload_(); 1564 this.onDestinationsReload_();
1604 } else { 1565 } else {
1605 this.insertDestinations_( 1566 this.insertDestinations_(
1606 print_preview.PrivetDestinationParser.parse(event.printer)); 1567 print_preview.PrivetDestinationParser.parse(printer));
1607 } 1568 }
1608 }, 1569 },
1609 1570
1610 /** 1571 /**
1611 * Called when capabilities for a privet printer are set. 1572 * Called when capabilities for a privet printer are set.
1612 * @param {Object} event Contains the capabilities and printer ID. 1573 * @param {Object} event Contains the capabilities and printer ID.
1613 * @private 1574 * @private
1614 */ 1575 */
1615 onPrivetCapabilitiesSet_: function(event) { 1576 onPrivetCapabilitiesSet_: function(event) {
1616 var destinations = 1577 var destinations =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 return this.getDestinationKey_( 1663 return this.getDestinationKey_(
1703 destination.origin, destination.id, destination.account); 1664 destination.origin, destination.id, destination.account);
1704 } 1665 }
1705 }; 1666 };
1706 1667
1707 // Export 1668 // Export
1708 return { 1669 return {
1709 DestinationStore: DestinationStore 1670 DestinationStore: DestinationStore
1710 }; 1671 };
1711 }); 1672 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/native_layer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698