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

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

Issue 284223004: List cloud devices in chrome://devices page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 322
323 /** 323 /**
324 * Create the DOM for a cloud device described by the device section. 324 * Create the DOM for a cloud device described by the device section.
325 * @param {Array.<Object>} devices_list List of devices. 325 * @param {Array.<Object>} devices_list List of devices.
326 */ 326 */
327 function createCloudDeviceDOM(device) { 327 function createCloudDeviceDOM(device) {
328 var devicesDomElement = document.createElement('div'); 328 var devicesDomElement = document.createElement('div');
329 329
330 var description; 330 var description;
331 if (device.description == '') { 331 if (device.description == '') {
332 description = loadTimeData.getString('noDescription'); 332 if (device.type == 'printer')
333 description = loadTimeData.getString('noDescriptionPrinter');
334 else
335 description = loadTimeData.getString('noDescriptionDevice');
333 } else { 336 } else {
334 description = device.description; 337 description = device.description;
335 } 338 }
336 339
337 fillDeviceDescription(devicesDomElement, device.display_name, 340 fillDeviceDescription(devicesDomElement, device.display_name,
338 description, device.type, 341 description, device.type,
339 loadTimeData.getString('manageDevice'), 342 loadTimeData.getString('manageDevice'),
340 manageCloudDevice.bind(null, device.id)); 343 manageCloudDevice.bind(null, device.id));
341 return devicesDomElement; 344 return devicesDomElement;
342 } 345 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 var pages = $('register-overlay').querySelectorAll('.register-page'); 427 var pages = $('register-overlay').querySelectorAll('.register-page');
425 var pagesLength = pages.length; 428 var pagesLength = pages.length;
426 for (var i = 0; i < pagesLength; i++) { 429 for (var i = 0; i < pagesLength; i++) {
427 pages[i].hidden = true; 430 pages[i].hidden = true;
428 } 431 }
429 432
430 $(page_id).hidden = false; 433 $(page_id).hidden = false;
431 } 434 }
432 435
433 /** 436 /**
434 * Request the printer list. 437 * Request the device list.
435 */ 438 */
436 function requestPrinterList() { 439 function requestDeviceList() {
437 if (isUserLoggedIn) { 440 if (isUserLoggedIn) {
438 clearElement($('cloud-devices')); 441 clearElement($('cloud-devices'));
439 $('cloud-devices-loading').hidden = false; 442 $('cloud-devices-loading').hidden = false;
440 $('cloud-devices-unavailable').hidden = true; 443 $('cloud-devices-unavailable').hidden = true;
441 444
442 chrome.send('requestPrinterList'); 445 chrome.send('requestDeviceList');
443 } 446 }
444 } 447 }
445 448
446 /** 449 /**
447 * Go to management page for a cloud device. 450 * Go to management page for a cloud device.
448 * @param {string} device_id ID of device. 451 * @param {string} device_id ID of device.
449 */ 452 */
450 function manageCloudDevice(device_id) { 453 function manageCloudDevice(device_id) {
451 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED); 454 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED);
452 chrome.send('openCloudPrintURL', [device_id]); 455 chrome.send('openCloudPrintURL', [device_id]);
(...skipping 15 matching lines...) Expand all
468 function cancelRegistration() { 471 function cancelRegistration() {
469 hideRegisterOverlay(); 472 hideRegisterOverlay();
470 chrome.send('cancelRegistration'); 473 chrome.send('cancelRegistration');
471 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL); 474 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL);
472 } 475 }
473 476
474 /** 477 /**
475 * Retry loading the devices from Google Cloud Print. 478 * Retry loading the devices from Google Cloud Print.
476 */ 479 */
477 function retryLoadCloudDevices() { 480 function retryLoadCloudDevices() {
478 requestPrinterList(); 481 requestDeviceList();
479 } 482 }
480 483
481 /** 484 /**
482 * User is not logged in. 485 * User is not logged in.
483 */ 486 */
484 function setUserLoggedIn(userLoggedIn) { 487 function setUserLoggedIn(userLoggedIn) {
485 isUserLoggedIn = userLoggedIn; 488 isUserLoggedIn = userLoggedIn;
486 489
487 $('cloud-devices-login-promo').hidden = isUserLoggedIn; 490 $('cloud-devices-login-promo').hidden = isUserLoggedIn;
488 $('register-overlay-login-promo').hidden = isUserLoggedIn; 491 $('register-overlay-login-promo').hidden = isUserLoggedIn;
489 $('register-continue-button').disabled = !isUserLoggedIn; 492 $('register-continue-button').disabled = !isUserLoggedIn;
490 493
491 if (isUserLoggedIn) { 494 if (isUserLoggedIn) {
492 requestPrinterList(); 495 requestDeviceList();
493 $('register-login-promo').hidden = true; 496 $('register-login-promo').hidden = true;
494 } else { 497 } else {
495 $('cloud-devices-loading').hidden = true; 498 $('cloud-devices-loading').hidden = true;
496 $('cloud-devices-unavailable').hidden = true; 499 $('cloud-devices-unavailable').hidden = true;
497 clearElement($('cloud-devices')); 500 clearElement($('cloud-devices'));
498 hideRegisterOverlay(); 501 hideRegisterOverlay();
499 } 502 }
500 503
501 updateUIToReflectState(); 504 updateUIToReflectState();
502 505
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 $('cloudPrintConnectorSetupButton').onclick = function(event) { 548 $('cloudPrintConnectorSetupButton').onclick = function(event) {
546 // Disable the button, set its text to the intermediate state. 549 // Disable the button, set its text to the intermediate state.
547 $('cloudPrintConnectorSetupButton').textContent = 550 $('cloudPrintConnectorSetupButton').textContent =
548 loadTimeData.getString('cloudPrintConnectorEnablingButton'); 551 loadTimeData.getString('cloudPrintConnectorEnablingButton');
549 $('cloudPrintConnectorSetupButton').disabled = true; 552 $('cloudPrintConnectorSetupButton').disabled = true;
550 chrome.send('showCloudPrintSetupDialog'); 553 chrome.send('showCloudPrintSetupDialog');
551 }; 554 };
552 } else { 555 } else {
553 $('cloudPrintConnectorSetupButton').onclick = function(event) { 556 $('cloudPrintConnectorSetupButton').onclick = function(event) {
554 chrome.send('disableCloudPrintConnector'); 557 chrome.send('disableCloudPrintConnector');
555 requestPrinterList(); 558 requestDeviceList();
556 }; 559 };
557 } 560 }
558 } 561 }
559 } 562 }
560 563
561 function removeCloudPrintConnectorSection() { 564 function removeCloudPrintConnectorSection() {
562 if (!cr.isChromeOS) { 565 if (!cr.isChromeOS) {
563 var connectorSectionElm = $('cloud-print-connector-section'); 566 var connectorSectionElm = $('cloud-print-connector-section');
564 if (connectorSectionElm) 567 if (connectorSectionElm)
565 connectorSectionElm.parentNode.removeChild(connectorSectionElm); 568 connectorSectionElm.parentNode.removeChild(connectorSectionElm);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 onCloudDeviceListAvailable: onCloudDeviceListAvailable, 623 onCloudDeviceListAvailable: onCloudDeviceListAvailable,
621 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, 624 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable,
622 onDeviceCacheFlushed: onDeviceCacheFlushed, 625 onDeviceCacheFlushed: onDeviceCacheFlushed,
623 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, 626 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter,
624 onRegistrationTimeout: onRegistrationTimeout, 627 onRegistrationTimeout: onRegistrationTimeout,
625 setUserLoggedIn: setUserLoggedIn, 628 setUserLoggedIn: setUserLoggedIn,
626 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, 629 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection,
627 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection 630 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection
628 }; 631 };
629 }); 632 });
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/gcd_base_api_flow.cc ('k') | chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698