Move ash::MultiProfileUserBehavior to user_manager with rename.
Following the go/multi-something concept the type is renamed to MultiUserSignInPolicy. Also, the style is changed from UPPER_SNAKE_CASE to kCamelCase. BUG=b:278643115 TEST=Tryjob. Change-Id: Ic5f3e251d838565d01ecfb822e2ae05eb182255e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4702623 Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Commit-Queue: Hidehiko Abe <hidehiko@chromium.org> Cr-Commit-Position: refs/heads/main@{#1172670}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d23fab250d
commit
ace7fefed4
ash
DEPSash_strings.grd
ash_strings_grd
IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_NOT_ALLOWED_POLICY_MSG.png.sha1IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_PRIMARY_ONLY_POLICY_MSG.png.sha1IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_RESTRICTED_POLICY_TITLE.png.sha1
login
ui
public
chrome/browser/ash/login
components/user_manager
1
ash/DEPS
1
ash/DEPS
@ -122,6 +122,7 @@ include_rules = [
|
||||
"+components/session_manager/session_manager_types.h",
|
||||
"-components/user_manager",
|
||||
"+components/user_manager/known_user.h",
|
||||
"+components/user_manager/multi_user/multi_user_sign_in_policy.h",
|
||||
"+components/user_manager/user_directory_integrity_manager.h",
|
||||
"+components/user_manager/user_names.h",
|
||||
"+components/user_manager/user_type.h",
|
||||
|
@ -4525,13 +4525,13 @@ Turning on battery saver to increase your battery life.
|
||||
<message name="IDS_ASH_LOGIN_MANUAL_LOCK_MESSAGE" desc="Message shown to user indicating that their parent locked the device.">
|
||||
Your parent locked this device
|
||||
</message>
|
||||
<message name="IDS_ASH_LOGIN_MULTI_PROFILES_RESTRICTED_POLICY_TITLE" desc="Text that is shown on the title of the bubble shown for user pod which is not allowed in multi-profiles session.">
|
||||
<message name="IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_RESTRICTED_POLICY_TITLE" desc="Text that is shown on the title of the bubble shown for user pod which is not allowed in multi-profiles session.">
|
||||
Can't set up multiple sign-in
|
||||
</message>
|
||||
<message name="IDS_ASH_LOGIN_MULTI_PROFILES_NOT_ALLOWED_POLICY_MSG" desc="Text that is shown on the bubble shown for user pod which is not allowed in multi-profiles session because of not-allowed policy or because of usage policy-pushed certificates.">
|
||||
<message name="IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_NOT_ALLOWED_POLICY_MSG" desc="Text that is shown on the bubble shown for user pod which is not allowed in multi-profiles session because of not-allowed policy or because of usage policy-pushed certificates.">
|
||||
The administrator for this account has disallowed multiple sign-in.
|
||||
</message>
|
||||
<message name="IDS_ASH_LOGIN_MULTI_PROFILES_PRIMARY_ONLY_POLICY_MSG" desc="Text that is shown on the bubble shown for user pod which is not allowed in multi-profiles session because of primary-only policy.">
|
||||
<message name="IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_PRIMARY_ONLY_POLICY_MSG" desc="Text that is shown on the bubble shown for user pod which is not allowed in multi-profiles session because of primary-only policy.">
|
||||
The administrator for this account requires this account to be the first signed-in account in a multiple sign-in session.
|
||||
</message>
|
||||
<message name="IDS_ASH_LOGIN_ONLINE_SIGN_IN_MESSAGE" desc="Message shown in the login screen when online sign-in is required.">
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "chromeos/strings/grit/chromeos_strings.h"
|
||||
#include "chromeos/ui/vector_icons/vector_icons.h"
|
||||
#include "components/user_manager/known_user.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
#include "components/user_manager/user_type.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/accessibility/ax_node_data.h"
|
||||
@ -1351,14 +1352,14 @@ void LockContentsView::ToggleManagementForUserForDebug(const AccountId& user) {
|
||||
}
|
||||
}
|
||||
|
||||
void LockContentsView::SetMultiprofilePolicyForUserForDebug(
|
||||
void LockContentsView::SetMultiUserSignInPolicyForUserForDebug(
|
||||
const AccountId& user,
|
||||
const MultiProfileUserBehavior& multiprofile_policy) {
|
||||
auto replace = [multiprofile_policy](const LoginUserInfo& user_info) {
|
||||
user_manager::MultiUserSignInPolicy policy) {
|
||||
auto replace = [policy](const LoginUserInfo& user_info) {
|
||||
auto changed = user_info;
|
||||
changed.multiprofile_policy = multiprofile_policy;
|
||||
changed.is_multiprofile_allowed =
|
||||
multiprofile_policy == MultiProfileUserBehavior::UNRESTRICTED;
|
||||
changed.multi_user_sign_in_policy = policy;
|
||||
changed.is_multi_user_sign_in_allowed =
|
||||
policy == user_manager::MultiUserSignInPolicy::kUnrestricted;
|
||||
return changed;
|
||||
};
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "chromeos/dbus/power/power_manager_client.h"
|
||||
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
|
||||
#include "components/account_id/account_id.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/display/display_observer.h"
|
||||
@ -209,10 +210,10 @@ class ASH_EXPORT LockContentsView
|
||||
// a note in the menu user view.
|
||||
void ToggleManagementForUserForDebug(const AccountId& user);
|
||||
|
||||
// Called for debugging to make |user| having a multiprofile policy.
|
||||
void SetMultiprofilePolicyForUserForDebug(
|
||||
// Called for debugging to make |user| having a multi-user-sign-in policy.
|
||||
void SetMultiUserSignInPolicyForUserForDebug(
|
||||
const AccountId& user,
|
||||
const MultiProfileUserBehavior& multiprofile_policy);
|
||||
user_manager::MultiUserSignInPolicy policy);
|
||||
|
||||
// Called for debugging to toggle forced online sign-in form |user|.
|
||||
void ToggleForceOnlineSignInForUserForDebug(const AccountId& user);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "components/user_manager/known_user.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/base/ime/ash/ime_keyboard.h"
|
||||
#include "ui/views/controls/button/md_text_button.h"
|
||||
@ -83,8 +84,8 @@ enum class DebugAuthEnabledState {
|
||||
|
||||
// The auth disabled message is displayed because of multiprofile policy.
|
||||
// Note that this would only be displayed on the secondary login screen.
|
||||
kMultiProfilePrimaryOnly,
|
||||
kMultiProfileNotAllowed,
|
||||
kMultiUserPolicyPrimaryOnly,
|
||||
kMultiUserPolicyNotAllowed,
|
||||
|
||||
// The auth disabled message is displayed because the force online
|
||||
// sign in is unavailable on the secondary login screen.
|
||||
@ -428,7 +429,8 @@ class LockDebugView::DebugDataDispatcherTransformer
|
||||
|
||||
debug_user->enable_auth = true;
|
||||
AuthDisabledReason reason;
|
||||
MultiProfileUserBehavior behavior = MultiProfileUserBehavior::UNRESTRICTED;
|
||||
user_manager::MultiUserSignInPolicy multi_user_sign_in_policy =
|
||||
user_manager::MultiUserSignInPolicy::kUnrestricted;
|
||||
|
||||
switch (debug_user->auth_enable_state) {
|
||||
case DebugAuthEnabledState::kAuthEnabled:
|
||||
@ -443,19 +445,21 @@ class LockDebugView::DebugDataDispatcherTransformer
|
||||
case DebugAuthEnabledState::kTimeWindowLimit:
|
||||
reason = AuthDisabledReason::kTimeWindowLimit;
|
||||
break;
|
||||
case DebugAuthEnabledState::kMultiProfilePrimaryOnly:
|
||||
behavior = MultiProfileUserBehavior::PRIMARY_ONLY;
|
||||
case DebugAuthEnabledState::kMultiUserPolicyPrimaryOnly:
|
||||
multi_user_sign_in_policy =
|
||||
user_manager::MultiUserSignInPolicy::kPrimaryOnly;
|
||||
break;
|
||||
case DebugAuthEnabledState::kMultiProfileNotAllowed:
|
||||
behavior = MultiProfileUserBehavior::NOT_ALLOWED;
|
||||
case DebugAuthEnabledState::kMultiUserPolicyNotAllowed:
|
||||
multi_user_sign_in_policy =
|
||||
user_manager::MultiUserSignInPolicy::kNotAllowed;
|
||||
break;
|
||||
case DebugAuthEnabledState::kForceOnlineSignIn:
|
||||
break;
|
||||
}
|
||||
|
||||
debug_dispatcher_.EnableAuthForUser(debug_user->account_id);
|
||||
lock_debug_view_->lock()->SetMultiprofilePolicyForUserForDebug(
|
||||
debug_users_[user_index].account_id, behavior);
|
||||
lock_debug_view_->lock()->SetMultiUserSignInPolicyForUserForDebug(
|
||||
debug_users_[user_index].account_id, multi_user_sign_in_policy);
|
||||
lock_debug_view_->lock()->UndoForceOnlineSignInForUserForDebug(
|
||||
debug_users_[user_index].account_id);
|
||||
|
||||
@ -472,10 +476,10 @@ class LockDebugView::DebugDataDispatcherTransformer
|
||||
base::Time::Now() + base::Hours(user_index) + base::Hours(8),
|
||||
base::Minutes(15), true /*bool disable_lock_screen_media*/));
|
||||
break;
|
||||
case DebugAuthEnabledState::kMultiProfilePrimaryOnly:
|
||||
case DebugAuthEnabledState::kMultiProfileNotAllowed:
|
||||
lock_debug_view_->lock()->SetMultiprofilePolicyForUserForDebug(
|
||||
debug_users_[user_index].account_id, behavior);
|
||||
case DebugAuthEnabledState::kMultiUserPolicyPrimaryOnly:
|
||||
case DebugAuthEnabledState::kMultiUserPolicyNotAllowed:
|
||||
lock_debug_view_->lock()->SetMultiUserSignInPolicyForUserForDebug(
|
||||
debug_users_[user_index].account_id, multi_user_sign_in_policy);
|
||||
break;
|
||||
case DebugAuthEnabledState::kForceOnlineSignIn:
|
||||
debug_dispatcher_.ForceOnlineSignInForUser(
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "chromeos/ash/components/login/auth/auth_events_recorder.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "components/user_manager/known_user.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
#include "components/user_manager/user.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/accessibility/ax_enums.mojom.h"
|
||||
@ -676,13 +677,13 @@ void LoginAuthUserView::SetAuthMethods(
|
||||
Shell::Get()->session_controller()->GetSessionState() ==
|
||||
session_manager::SessionState::LOGIN_SECONDARY;
|
||||
|
||||
if (is_secondary_login && !user.is_multiprofile_allowed) {
|
||||
if (is_secondary_login && !user.is_multi_user_sign_in_allowed) {
|
||||
online_sign_in_button_->SetVisible(false);
|
||||
disabled_auth_message_->SetVisible(true);
|
||||
disabled_auth_message_->SetAuthDisabledMessage(
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_LOGIN_MULTI_PROFILES_RESTRICTED_POLICY_TITLE),
|
||||
GetMultiprofileDisableAuthMessage());
|
||||
IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_RESTRICTED_POLICY_TITLE),
|
||||
GetMultiUserSignInDisableAuthMessage());
|
||||
}
|
||||
// We do not want the online sign in button to be visible on the secondary
|
||||
// login screen since we can not call OOBE there. In such a case, we indicate
|
||||
@ -1419,16 +1420,16 @@ std::u16string LoginAuthUserView::GetPasswordViewPlaceholder() const {
|
||||
return l10n_util::GetStringUTF16(IDS_ASH_LOGIN_POD_PASSWORD_PLACEHOLDER);
|
||||
}
|
||||
|
||||
std::u16string LoginAuthUserView::GetMultiprofileDisableAuthMessage() const {
|
||||
std::u16string LoginAuthUserView::GetMultiUserSignInDisableAuthMessage() const {
|
||||
int message_id;
|
||||
switch (current_user().multiprofile_policy) {
|
||||
case MultiProfileUserBehavior::PRIMARY_ONLY:
|
||||
message_id = IDS_ASH_LOGIN_MULTI_PROFILES_PRIMARY_ONLY_POLICY_MSG;
|
||||
switch (current_user().multi_user_sign_in_policy) {
|
||||
case user_manager::MultiUserSignInPolicy::kPrimaryOnly:
|
||||
message_id = IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_PRIMARY_ONLY_POLICY_MSG;
|
||||
break;
|
||||
case MultiProfileUserBehavior::NOT_ALLOWED:
|
||||
message_id = IDS_ASH_LOGIN_MULTI_PROFILES_NOT_ALLOWED_POLICY_MSG;
|
||||
case user_manager::MultiUserSignInPolicy::kNotAllowed:
|
||||
message_id = IDS_ASH_LOGIN_MULTI_USER_SIGN_IN_NOT_ALLOWED_POLICY_MSG;
|
||||
break;
|
||||
case MultiProfileUserBehavior::UNRESTRICTED:
|
||||
case user_manager::MultiUserSignInPolicy::kUnrestricted:
|
||||
NOTREACHED();
|
||||
message_id = 0;
|
||||
break;
|
||||
|
@ -301,7 +301,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView {
|
||||
// Convenience methods to determine UI text based on the InputFieldMode.
|
||||
std::u16string GetPinPasswordToggleText() const;
|
||||
std::u16string GetPasswordViewPlaceholder() const;
|
||||
std::u16string GetMultiprofileDisableAuthMessage() const;
|
||||
std::u16string GetMultiUserSignInDisableAuthMessage() const;
|
||||
|
||||
// Authentication methods available and extra parameters that control the UI.
|
||||
AuthMethods auth_methods_ = AUTH_NONE;
|
||||
|
@ -17,7 +17,7 @@ UserState::UserState(const LoginUserInfo& user_info)
|
||||
force_online_sign_in = true;
|
||||
}
|
||||
show_pin_pad_for_password = user_info.show_pin_pad_for_password;
|
||||
disable_auth = !user_info.is_multiprofile_allowed &&
|
||||
disable_auth = !user_info.is_multi_user_sign_in_allowed &&
|
||||
Shell::Get()->session_controller()->GetSessionState() ==
|
||||
session_manager::SessionState::LOGIN_SECONDARY;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "chromeos/ash/components/proximity_auth/public/mojom/auth_type.mojom-forward.h"
|
||||
#include "chromeos/components/security_token_pin/constants.h"
|
||||
#include "components/account_id/account_id.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
@ -107,14 +108,6 @@ enum class ManagementDeviceMode {
|
||||
kMaxValue = kOther,
|
||||
};
|
||||
|
||||
// Supported multi-profile user behavior values.
|
||||
// TODO(estade): change all the enums to use kCamelCase.
|
||||
enum class MultiProfileUserBehavior {
|
||||
UNRESTRICTED = 0,
|
||||
PRIMARY_ONLY = 1,
|
||||
NOT_ALLOWED = 2,
|
||||
};
|
||||
|
||||
// The status of fingerprint availability.
|
||||
enum class FingerprintState {
|
||||
// The user cannot use fingerprint. This may be because:
|
||||
@ -267,12 +260,12 @@ struct ASH_PUBLIC_EXPORT LoginUserInfo {
|
||||
// LoginScreenModel::SetSmartLockState) which update the current state.
|
||||
SmartLockState smart_lock_state = SmartLockState::kDisabled;
|
||||
|
||||
// True if multi-profiles sign in is allowed for this user.
|
||||
bool is_multiprofile_allowed = false;
|
||||
// True if multi-user-sign-in is allowed for this user.
|
||||
bool is_multi_user_sign_in_allowed = false;
|
||||
|
||||
// Enforced policy for multi-profiles sign in.
|
||||
MultiProfileUserBehavior multiprofile_policy =
|
||||
MultiProfileUserBehavior::UNRESTRICTED;
|
||||
// Enforced policy for multi-user-sign-in.
|
||||
user_manager::MultiUserSignInPolicy multi_user_sign_in_policy =
|
||||
user_manager::MultiUserSignInPolicy::kUnrestricted;
|
||||
|
||||
// True if this user can be removed.
|
||||
bool can_remove = false;
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/signin/public/identity_manager/account_managed_status_finder.h"
|
||||
#include "components/user_manager/known_user.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
#include "components/user_manager/user_manager.h"
|
||||
#include "components/user_manager/user_type.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
@ -186,9 +187,9 @@ bool CanRemoveUser(const user_manager::User* user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetMultiProfilePolicy(const user_manager::User* user,
|
||||
bool* out_is_allowed,
|
||||
MultiProfileUserBehavior* out_policy) {
|
||||
void GetMultiUserSignInPolicy(const user_manager::User* user,
|
||||
bool* out_is_allowed,
|
||||
user_manager::MultiUserSignInPolicy* out_policy) {
|
||||
const std::string& user_id = user->GetAccountId().GetUserEmail();
|
||||
MultiProfileUserController* multi_profile_user_controller =
|
||||
ChromeUserManager::Get()->GetMultiProfileUserController();
|
||||
@ -878,10 +879,10 @@ UserSelectionScreen::UpdateAndReturnUserListForAsh() {
|
||||
|
||||
// Fill multi-profile data.
|
||||
if (!is_signin_to_add) {
|
||||
user_info.is_multiprofile_allowed = true;
|
||||
user_info.is_multi_user_sign_in_allowed = true;
|
||||
} else {
|
||||
GetMultiProfilePolicy(user, &user_info.is_multiprofile_allowed,
|
||||
&user_info.multiprofile_policy);
|
||||
GetMultiUserSignInPolicy(user, &user_info.is_multi_user_sign_in_allowed,
|
||||
&user_info.multi_user_sign_in_policy);
|
||||
}
|
||||
|
||||
// Fill public session data.
|
||||
|
@ -102,16 +102,17 @@ MultiProfileUserController::GetPrimaryUserPolicy() const {
|
||||
}
|
||||
|
||||
// static
|
||||
MultiProfileUserBehavior MultiProfileUserController::UserBehaviorStringToEnum(
|
||||
user_manager::MultiUserSignInPolicy
|
||||
MultiProfileUserController::UserBehaviorStringToEnum(
|
||||
const std::string& behavior) {
|
||||
if (behavior == kBehaviorPrimaryOnly) {
|
||||
return MultiProfileUserBehavior::PRIMARY_ONLY;
|
||||
return user_manager::MultiUserSignInPolicy::kPrimaryOnly;
|
||||
}
|
||||
if (behavior == kBehaviorNotAllowed) {
|
||||
return MultiProfileUserBehavior::NOT_ALLOWED;
|
||||
return user_manager::MultiUserSignInPolicy::kNotAllowed;
|
||||
}
|
||||
|
||||
return MultiProfileUserBehavior::UNRESTRICTED;
|
||||
return user_manager::MultiUserSignInPolicy::kUnrestricted;
|
||||
}
|
||||
|
||||
bool MultiProfileUserController::IsUserAllowedInSession(
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "components/user_manager/multi_user/multi_user_sign_in_policy.h"
|
||||
|
||||
class PrefChangeRegistrar;
|
||||
class PrefRegistrySimple;
|
||||
@ -26,8 +27,6 @@ class PrefRegistrySyncable;
|
||||
|
||||
namespace ash {
|
||||
|
||||
enum class MultiProfileUserBehavior;
|
||||
|
||||
// MultiProfileUserController decides whether a user is allowed to be in a
|
||||
// multi-profiles session. It caches the multi-profile user behavior pref backed
|
||||
// by user policy into local state so that the value is available before the
|
||||
@ -71,8 +70,8 @@ class MultiProfileUserController {
|
||||
// NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS)
|
||||
UserAllowedInSessionReason GetPrimaryUserPolicy() const;
|
||||
|
||||
// Returns the user behavior in MultiProfileUserBehavior enum.
|
||||
static MultiProfileUserBehavior UserBehaviorStringToEnum(
|
||||
// Returns the user behavior in MultiUserSignInPolicy enum.
|
||||
static user_manager::MultiUserSignInPolicy UserBehaviorStringToEnum(
|
||||
const std::string& behavior);
|
||||
|
||||
// Returns true if user allowed to be in the current session. If `reason` not
|
||||
|
@ -6,6 +6,7 @@ import("//build/config/chromeos/ui_mode.gni")
|
||||
|
||||
component("user_manager") {
|
||||
sources = [
|
||||
"multi_user/multi_user_sign_in_policy.h",
|
||||
"user_info.cc",
|
||||
"user_info.h",
|
||||
"user_info_impl.cc",
|
||||
|
@ -0,0 +1,18 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_USER_MANAGER_MULTI_USER_MULTI_USER_SIGN_IN_POLICY_H_
|
||||
#define COMPONENTS_USER_MANAGER_MULTI_USER_MULTI_USER_SIGN_IN_POLICY_H_
|
||||
|
||||
namespace user_manager {
|
||||
|
||||
enum class MultiUserSignInPolicy {
|
||||
kUnrestricted = 0,
|
||||
kPrimaryOnly = 1,
|
||||
kNotAllowed = 2,
|
||||
};
|
||||
|
||||
} // namespace user_manager
|
||||
|
||||
#endif // COMPONENTS_USER_MANAGER_MULTI_USER_MULTI_USER_SIGN_IN_POLICY_H_
|
Reference in New Issue
Block a user