Commit 00b31698 authored by noamsml's avatar noamsml Committed by Commit bot

Do not show irrelevant registration promos to supervised and guest users

Hide registration promos for supervised and guest users. Also hide cloud print
connector section and irrelevant "cloud devices" section (since users cannot log
in).

BUG=288614,340893

Review URL: https://codereview.chromium.org/521953002

Cr-Commit-Position: refs/heads/master@{#292806}
parent fd8bc125
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection">
<head>
<meta charset="utf-8">
......@@ -136,6 +136,7 @@
</if>
</div>
<div id="my-devices-container">
<h2 i18n-content="myDevicesTitle"></h2>
<div id="cloud-devices-loading" class="cloud-print-message" hidden>
<div class="inline-spinner"> </div> <span i18n-content="loading"></span>
......@@ -155,6 +156,7 @@
<div id="cloud-devices">
</div>
</div>
</div>
<script src="chrome://resources/js/i18n_template2.js"></script>
......
......@@ -45,6 +45,12 @@ cr.define('local_discovery', function() {
*/
var isUserLoggedIn = true;
/**
* Whether or not the user is supervised or off the record.
* @type bool
*/
var isUserSupervisedOrOffTheRecord = false;
/**
* Whether or not the path-based dialog has been shown.
* @type bool
......@@ -407,7 +413,8 @@ cr.define('local_discovery', function() {
$('register-login-promo').hidden = true;
} else {
$('no-printers-message').hidden = true;
$('register-login-promo').hidden = isUserLoggedIn;
$('register-login-promo').hidden = isUserLoggedIn ||
isUserSupervisedOrOffTheRecord;
}
}
......@@ -506,14 +513,24 @@ cr.define('local_discovery', function() {
/**
* User is not logged in.
*/
function setUserLoggedIn(userLoggedIn) {
function setUserLoggedIn(userLoggedIn, userSupervisedOrOffTheRecord) {
isUserLoggedIn = userLoggedIn;
isUserSupervisedOrOffTheRecord = userSupervisedOrOffTheRecord;
$('cloud-devices-login-promo').hidden = isUserLoggedIn;
$('register-overlay-login-promo').hidden = isUserLoggedIn;
$('register-continue-button').disabled = !isUserLoggedIn;
$('cloud-devices-login-promo').hidden = isUserLoggedIn ||
isUserSupervisedOrOffTheRecord;
$('register-overlay-login-promo').hidden = isUserLoggedIn ||
isUserSupervisedOrOffTheRecord;
$('register-continue-button').disabled = !isUserLoggedIn ||
isUserSupervisedOrOffTheRecord;
if (isUserLoggedIn) {
$('my-devices-container').hidden = userSupervisedOrOffTheRecord;
if (isUserSupervisedOrOffTheRecord) {
$('cloud-print-connector-section').hidden = true;
}
if (isUserLoggedIn && !isUserSupervisedOrOffTheRecord) {
requestDeviceList();
$('register-login-promo').hidden = true;
} else {
......
......@@ -564,8 +564,9 @@ void LocalDiscoveryUIHandler::PrivetClientToV3(
void LocalDiscoveryUIHandler::CheckUserLoggedIn() {
base::FundamentalValue logged_in_value(!GetSyncAccount().empty());
web_ui()->CallJavascriptFunction("local_discovery.setUserLoggedIn",
logged_in_value);
base::FundamentalValue is_supervised_value(IsUserSupervisedOrOffTheRecord());
web_ui()->CallJavascriptFunction(
"local_discovery.setUserLoggedIn", logged_in_value, is_supervised_value);
}
void LocalDiscoveryUIHandler::CheckListingDone() {
......@@ -636,6 +637,12 @@ void LocalDiscoveryUIHandler::CreatePrivetV3Client(
privet_resolution_->Start();
}
bool LocalDiscoveryUIHandler::IsUserSupervisedOrOffTheRecord() {
Profile* profile = Profile::FromWebUI(web_ui());
return profile->IsSupervised() || profile->IsOffTheRecord();
}
#if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
void LocalDiscoveryUIHandler::StartCloudPrintConnector() {
Profile* profile = Profile::FromWebUI(web_ui());
......
......@@ -165,6 +165,8 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
void CheckListingDone();
bool IsUserSupervisedOrOffTheRecord();
#if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
void StartCloudPrintConnector();
void OnCloudPrintPrefsChanged();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment