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

Side by Side Diff: chrome/browser/resources/local_discovery/local_discovery.js

Issue 23851008: Added cache flush on network change to ServiceDiscoveryHostClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 5 /**
6 * Javascript for local_discovery.html, served from chrome://devices/ 6 * Javascript for local_discovery.html, served from chrome://devices/
7 * This is used to show discoverable devices near the user as well as 7 * This is used to show discoverable devices near the user as well as
8 * cloud devices registered to them. 8 * cloud devices registered to them.
9 * 9 *
10 * The object defined in this javascript file listens for callbacks from the 10 * The object defined in this javascript file listens for callbacks from the
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 devices[name] = new Device(info); 197 devices[name] = new Device(info);
198 devices[name].renderDevice(); 198 devices[name].renderDevice();
199 } 199 }
200 } else { 200 } else {
201 if (devices.hasOwnProperty(name)) { 201 if (devices.hasOwnProperty(name)) {
202 devices[name].removeDevice(); 202 devices[name].removeDevice();
203 delete devices[name]; 203 delete devices[name];
204 } 204 }
205 } 205 }
206 206
207 var numberPrinters = $('register-device-list').children.length; 207 updateUIToReflectNumberOfLocalDevices();
208 $('printer-num').textContent = generateNumberPrintersAvailableText(
209 numberPrinters);
210
211 if (numberPrinters == 0) {
212 $('register-message').textContent = loadTimeData.getString(
213 'noPrintersOnNetworkExplanation');
214 } else {
215 $('register-message').textContent = loadTimeData.getString(
216 'registerConfirmMessage');
217 }
218 } 208 }
219 209
220 /** 210 /**
221 * Handle a list of cloud devices available to the user globally. 211 * Handle a list of cloud devices available to the user globally.
222 * @param {Array.<Object>} devices_list List of devices. 212 * @param {Array.<Object>} devices_list List of devices.
223 */ 213 */
224 function onCloudDeviceListAvailable(devices_list) { 214 function onCloudDeviceListAvailable(devices_list) {
225 var devicesListLength = devices_list.length; 215 var devicesListLength = devices_list.length;
226 var devicesContainer = $('cloud-devices'); 216 var devicesContainer = $('cloud-devices');
227 217
(...skipping 10 matching lines...) Expand all
238 } else { 228 } else {
239 description = devices_list[i].description; 229 description = devices_list[i].description;
240 } 230 }
241 231
242 fillDeviceDescription(devicesDomElement, devices_list[i].display_name, 232 fillDeviceDescription(devicesDomElement, devices_list[i].display_name,
243 description, 'Manage' /*Localize*/, 233 description, 'Manage' /*Localize*/,
244 manageCloudDevice.bind(null, devices_list[i].id)); 234 manageCloudDevice.bind(null, devices_list[i].id));
245 } 235 }
246 } 236 }
247 237
238 function onDeviceCacheFlushed() {
239 for (var deviceName in devices) {
240 devices[deviceName].removeDevice();
241 delete devices[deviceName];
242 }
243
244 updateUIToReflectNumberOfLocalDevices();
245 }
246
247 function updateUIToReflectNumberOfLocalDevices() {
248 var numberPrinters = $('register-device-list').children.length;
249 $('printer-num').textContent = generateNumberPrintersAvailableText(
250 numberPrinters);
251
252 if (numberPrinters == 0) {
253 $('register-message').textContent = loadTimeData.getString(
254 'noPrintersOnNetworkExplanation');
255 } else {
256 $('register-message').textContent = loadTimeData.getString(
257 'registerConfirmMessage');
258 }
259 }
260
248 261
249 /** 262 /**
250 * Announce that a registration succeeeded. 263 * Announce that a registration succeeeded.
251 */ 264 */
252 function onRegistrationSuccess() { 265 function onRegistrationSuccess() {
253 hideRegisterOverlay(); 266 hideRegisterOverlay();
254 requestPrinterList(); 267 requestPrinterList();
255 } 268 }
256 269
257 /** 270 /**
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 334
322 chrome.send('start'); 335 chrome.send('start');
323 requestPrinterList(); 336 requestPrinterList();
324 }); 337 });
325 338
326 return { 339 return {
327 onRegistrationSuccess: onRegistrationSuccess, 340 onRegistrationSuccess: onRegistrationSuccess,
328 onRegistrationFailed: onRegistrationFailed, 341 onRegistrationFailed: onRegistrationFailed,
329 onUnregisteredDeviceUpdate: onUnregisteredDeviceUpdate, 342 onUnregisteredDeviceUpdate: onUnregisteredDeviceUpdate,
330 onRegistrationConfirmedOnPrinter: onRegistrationConfirmedOnPrinter, 343 onRegistrationConfirmedOnPrinter: onRegistrationConfirmedOnPrinter,
331 onCloudDeviceListAvailable: onCloudDeviceListAvailable 344 onCloudDeviceListAvailable: onCloudDeviceListAvailable,
345 onDeviceCacheFlushed: onDeviceCacheFlushed
332 }; 346 };
333 }); 347 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698