Commit 4237fa75 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

Disable Guest sign-in button for child devices for WebUI.

Bug: 823534

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I062d1ef97feb3778622e48dfc75d353e0a4dd1e9
Reviewed-on: https://chromium-review.googlesource.com/1067682
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561593}
parent 96986fc8
......@@ -12,6 +12,7 @@
#include "chrome/browser/chromeos/settings/device_settings_provider.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/prefs/pref_value_map.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_names.h"
#include "components/user_manager/user_type.h"
......@@ -110,6 +111,18 @@ bool AreSupervisedUsersAllowed(const CrosSettings* cros_settings) {
}
bool IsGuestSessionAllowed(const CrosSettings* cros_settings) {
const AccountId& owner_account_id =
user_manager::UserManager::Get()->GetOwnerAccountId();
if (owner_account_id.is_valid() &&
user_manager::UserManager::Get()->FindUser(owner_account_id)->GetType() ==
user_manager::UserType::USER_TYPE_CHILD) {
return false;
}
// In tests CrosSettings might not be initialized.
if (!cros_settings)
return false;
bool is_guest_allowed = false;
cros_settings->GetBoolean(kAccountsPrefAllowGuest, &is_guest_allowed);
return is_guest_allowed;
......
......@@ -31,6 +31,7 @@
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/temp_certs_cache_nss.h"
......@@ -173,9 +174,9 @@ void UpdateAuthParams(base::DictionaryValue* params,
CrosSettings* cros_settings = CrosSettings::Get();
bool allow_new_user = true;
cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
bool allow_guest = true;
cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
params->SetBoolean("guestSignin", allow_guest);
params->SetBoolean(
"guestSignin",
chrome_user_manager_util::IsGuestSessionAllowed(cros_settings));
// nosignup flow if new users are not allowed.
if (!allow_new_user || is_restrictive_proxy)
......
......@@ -57,6 +57,7 @@
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/login_display_webui.h"
#include "chrome/browser/chromeos/login/ui/login_feedback.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
......@@ -862,7 +863,7 @@ void SigninScreenHandler::SetupAndShowOfflineMessage(
}
const bool guest_signin_allowed =
IsGuestSigninAllowed() &&
chrome_user_manager_util::IsGuestSessionAllowed(CrosSettings::Get()) &&
IsSigninScreenError(error_screen_->GetErrorState());
error_screen_->AllowGuestSignin(guest_signin_allowed);
......@@ -1711,15 +1712,6 @@ bool SigninScreenHandler::IsSigninScreenHiddenByError() const {
(IsSigninScreen(error_screen_->GetParentScreen()));
}
bool SigninScreenHandler::IsGuestSigninAllowed() const {
CrosSettings* cros_settings = CrosSettings::Get();
if (!cros_settings)
return false;
bool allow_guest;
cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
return allow_guest;
}
net::Error SigninScreenHandler::FrameError() const {
return gaia_screen_handler_->frame_error();
}
......
......@@ -461,9 +461,6 @@ class SigninScreenHandler
// screen.
bool IsSigninScreenHiddenByError() const;
// Returns true if guest signin is allowed.
bool IsGuestSigninAllowed() const;
bool ShouldLoadGaia() const;
net::Error FrameError() const;
......
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