Commit b2cd4822 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos/user_manager: adds has_gaia_account to ash

Specifically ash::mojom::UserInfo. I'm going to need this to have ash call
into wallpaper code, which needs the gaia account.

BUG=756085
TEST=none

Change-Id: I9a9c1970bd3cd28ce36cca3d5ff919225dee8084
Reviewed-on: https://chromium-review.googlesource.com/c/1328564Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607300}
parent 8369a08e
......@@ -62,4 +62,6 @@ struct UserInfo {
bool is_ephemeral;
// True if the user is also the device owner.
bool is_device_owner;
// True if the user has a gaia account.
bool has_gaia_account;
};
......@@ -100,6 +100,7 @@ ash::mojom::UserSessionPtr UserToUserSession(const User& user) {
session->user_info->display_email = user.display_email();
session->user_info->is_ephemeral =
UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user.GetAccountId());
session->user_info->has_gaia_account = user.has_gaia_account();
const AccountId& owner_id = UserManager::Get()->GetOwnerAccountId();
session->user_info->is_device_owner =
owner_id.is_valid() && owner_id == user.GetAccountId();
......
......@@ -241,6 +241,26 @@ bool User::is_active() const {
return is_active_;
}
bool User::has_gaia_account() const {
static_assert(user_manager::NUM_USER_TYPES == 9,
"NUM_USER_TYPES should equal 9");
switch (GetType()) {
case user_manager::USER_TYPE_REGULAR:
case user_manager::USER_TYPE_CHILD:
return true;
case user_manager::USER_TYPE_GUEST:
case user_manager::USER_TYPE_PUBLIC_ACCOUNT:
case user_manager::USER_TYPE_SUPERVISED:
case user_manager::USER_TYPE_KIOSK_APP:
case user_manager::USER_TYPE_ARC_KIOSK_APP:
case user_manager::USER_TYPE_ACTIVE_DIRECTORY:
return false;
default:
NOTREACHED();
}
return false;
}
void User::AddProfileCreatedObserver(base::OnceClosure on_profile_created) {
DCHECK(!profile_is_created_);
on_profile_created_observers_.push_back(std::move(on_profile_created));
......@@ -459,24 +479,4 @@ UserType PublicAccountUser::GetType() const {
return user_manager::USER_TYPE_PUBLIC_ACCOUNT;
}
bool User::has_gaia_account() const {
static_assert(user_manager::NUM_USER_TYPES == 9,
"NUM_USER_TYPES should equal 9");
switch (GetType()) {
case user_manager::USER_TYPE_REGULAR:
case user_manager::USER_TYPE_CHILD:
return true;
case user_manager::USER_TYPE_GUEST:
case user_manager::USER_TYPE_PUBLIC_ACCOUNT:
case user_manager::USER_TYPE_SUPERVISED:
case user_manager::USER_TYPE_KIOSK_APP:
case user_manager::USER_TYPE_ARC_KIOSK_APP:
case user_manager::USER_TYPE_ACTIVE_DIRECTORY:
return false;
default:
NOTREACHED();
}
return false;
}
} // namespace user_manager
......@@ -185,6 +185,9 @@ class USER_MANAGER_EXPORT User : public UserInfo {
// True if the user Profile is created.
bool is_profile_created() const { return profile_is_created_; }
// True if user has google account (not a guest or managed user).
bool has_gaia_account() const;
static User* CreatePublicAccountUserForTesting(const AccountId& account_id) {
return CreatePublicAccountUser(account_id);
}
......@@ -274,9 +277,6 @@ class USER_MANAGER_EXPORT User : public UserInfo {
void SetProfileIsCreated();
// True if user has google account (not a guest or managed user).
bool has_gaia_account() const;
virtual void SetAffiliation(bool is_affiliated);
private:
......
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