| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 */ | 39 */ |
| 40 var devices = {}; | 40 var devices = {}; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Whether or not the user is currently logged in. | 43 * Whether or not the user is currently logged in. |
| 44 * @type bool | 44 * @type bool |
| 45 */ | 45 */ |
| 46 var isUserLoggedIn = true; | 46 var isUserLoggedIn = true; |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Whether or not the user is supervised or off the record. |
| 50 * @type bool |
| 51 */ |
| 52 var isUserSupervisedOrOffTheRecord = false; |
| 53 |
| 54 /** |
| 49 * Whether or not the path-based dialog has been shown. | 55 * Whether or not the path-based dialog has been shown. |
| 50 * @type bool | 56 * @type bool |
| 51 */ | 57 */ |
| 52 var dialogFromPathHasBeenShown = false; | 58 var dialogFromPathHasBeenShown = false; |
| 53 | 59 |
| 54 /** | 60 /** |
| 55 * Focus manager for page. | 61 * Focus manager for page. |
| 56 */ | 62 */ |
| 57 var focusManager = null; | 63 var focusManager = null; |
| 58 | 64 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 * Update UI strings to reflect the number of local devices. | 406 * Update UI strings to reflect the number of local devices. |
| 401 */ | 407 */ |
| 402 function updateUIToReflectState() { | 408 function updateUIToReflectState() { |
| 403 var numberPrinters = $('register-device-list').children.length; | 409 var numberPrinters = $('register-device-list').children.length; |
| 404 if (numberPrinters == 0) { | 410 if (numberPrinters == 0) { |
| 405 $('no-printers-message').hidden = false; | 411 $('no-printers-message').hidden = false; |
| 406 | 412 |
| 407 $('register-login-promo').hidden = true; | 413 $('register-login-promo').hidden = true; |
| 408 } else { | 414 } else { |
| 409 $('no-printers-message').hidden = true; | 415 $('no-printers-message').hidden = true; |
| 410 $('register-login-promo').hidden = isUserLoggedIn; | 416 $('register-login-promo').hidden = isUserLoggedIn || |
| 417 isUserSupervisedOrOffTheRecord; |
| 411 } | 418 } |
| 412 } | 419 } |
| 413 | 420 |
| 414 /** | 421 /** |
| 415 * Announce that a registration succeeeded. | 422 * Announce that a registration succeeeded. |
| 416 */ | 423 */ |
| 417 function onRegistrationSuccess(device_data) { | 424 function onRegistrationSuccess(device_data) { |
| 418 hideRegisterOverlay(); | 425 hideRegisterOverlay(); |
| 419 | 426 |
| 420 if (device_data.service_name == getOverlayIDFromPath()) { | 427 if (device_data.service_name == getOverlayIDFromPath()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 /** | 506 /** |
| 500 * Retry loading the devices from Google Cloud Print. | 507 * Retry loading the devices from Google Cloud Print. |
| 501 */ | 508 */ |
| 502 function retryLoadCloudDevices() { | 509 function retryLoadCloudDevices() { |
| 503 requestDeviceList(); | 510 requestDeviceList(); |
| 504 } | 511 } |
| 505 | 512 |
| 506 /** | 513 /** |
| 507 * User is not logged in. | 514 * User is not logged in. |
| 508 */ | 515 */ |
| 509 function setUserLoggedIn(userLoggedIn) { | 516 function setUserLoggedIn(userLoggedIn, userSupervisedOrOffTheRecord) { |
| 510 isUserLoggedIn = userLoggedIn; | 517 isUserLoggedIn = userLoggedIn; |
| 518 isUserSupervisedOrOffTheRecord = userSupervisedOrOffTheRecord; |
| 511 | 519 |
| 512 $('cloud-devices-login-promo').hidden = isUserLoggedIn; | 520 $('cloud-devices-login-promo').hidden = isUserLoggedIn || |
| 513 $('register-overlay-login-promo').hidden = isUserLoggedIn; | 521 isUserSupervisedOrOffTheRecord; |
| 514 $('register-continue-button').disabled = !isUserLoggedIn; | 522 $('register-overlay-login-promo').hidden = isUserLoggedIn || |
| 523 isUserSupervisedOrOffTheRecord; |
| 524 $('register-continue-button').disabled = !isUserLoggedIn || |
| 525 isUserSupervisedOrOffTheRecord; |
| 515 | 526 |
| 516 if (isUserLoggedIn) { | 527 $('my-devices-container').hidden = userSupervisedOrOffTheRecord; |
| 528 |
| 529 if (isUserSupervisedOrOffTheRecord) { |
| 530 $('cloud-print-connector-section').hidden = true; |
| 531 } |
| 532 |
| 533 if (isUserLoggedIn && !isUserSupervisedOrOffTheRecord) { |
| 517 requestDeviceList(); | 534 requestDeviceList(); |
| 518 $('register-login-promo').hidden = true; | 535 $('register-login-promo').hidden = true; |
| 519 } else { | 536 } else { |
| 520 $('cloud-devices-loading').hidden = true; | 537 $('cloud-devices-loading').hidden = true; |
| 521 $('cloud-devices-unavailable').hidden = true; | 538 $('cloud-devices-unavailable').hidden = true; |
| 522 clearElement($('cloud-devices')); | 539 clearElement($('cloud-devices')); |
| 523 hideRegisterOverlay(); | 540 hideRegisterOverlay(); |
| 524 } | 541 } |
| 525 | 542 |
| 526 updateUIToReflectState(); | 543 updateUIToReflectState(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 onCloudDeviceListAvailable: onCloudDeviceListAvailable, | 682 onCloudDeviceListAvailable: onCloudDeviceListAvailable, |
| 666 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, | 683 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, |
| 667 onDeviceCacheFlushed: onDeviceCacheFlushed, | 684 onDeviceCacheFlushed: onDeviceCacheFlushed, |
| 668 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, | 685 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, |
| 669 onRegistrationTimeout: onRegistrationTimeout, | 686 onRegistrationTimeout: onRegistrationTimeout, |
| 670 setUserLoggedIn: setUserLoggedIn, | 687 setUserLoggedIn: setUserLoggedIn, |
| 671 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, | 688 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, |
| 672 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection | 689 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection |
| 673 }; | 690 }; |
| 674 }); | 691 }); |
| OLD | NEW |