Commit fca3c92b authored by Yunke Zhou's avatar Yunke Zhou Committed by Commit Bot

Oobe: Add enterprise enrollment shelf button

This CL is to add enterprise enrollment shelf button in the OOBE flow. This button should only be visible in UserCreationScreen.

Bug: 1101318
Change-Id: I0c68a51dc1d06a56460cef9d6096e72b8bd814c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303438Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Yunke Zhou <yunkez@google.com>
Cr-Commit-Position: refs/heads/master@{#791391}
parent 15f3966b
......@@ -206,6 +206,11 @@ bool LoginScreenTestApi::IsParentAccessButtonShown() {
return IsLoginShelfViewButtonShown(LoginShelfView::kParentAccess);
}
// static
bool LoginScreenTestApi::IsEnterpriseEnrollmentButtonShown() {
return IsLoginShelfViewButtonShown(LoginShelfView::kEnterpriseEnrollment);
}
// static
bool LoginScreenTestApi::IsWarningBubbleShown() {
LockScreen::TestApi lock_screen_test(LockScreen::Get());
......
......@@ -80,6 +80,11 @@ const ShelfButtonClickMapping kShelfTargets[] = {
LoginMetricsRecorder::LockScreenUserClickTarget::kParentAccessButton,
LoginMetricsRecorder::LoginScreenUserClickTarget::kTargetCount,
LoginMetricsRecorder::OobeUserClickTarget::kTargetCount},
// |kEnterpriseEnrollmentButton|
{LoginMetricsRecorder::ShelfButtonClickTarget::kEnterpriseEnrollmentButton,
LoginMetricsRecorder::LockScreenUserClickTarget::kTargetCount,
LoginMetricsRecorder::LoginScreenUserClickTarget::kTargetCount,
LoginMetricsRecorder::OobeUserClickTarget::kEnterpriseEnrollmentButton},
};
// Defines mapping of TrayClickTarget |original| to different UMA target in
......
......@@ -53,6 +53,7 @@ class ASH_EXPORT LoginMetricsRecorder {
kSystemTray,
kVirtualKeyboardTray,
kImeTray,
kEnterpriseEnrollmentButton,
kTargetCount,
};
......@@ -78,6 +79,7 @@ class ASH_EXPORT LoginMetricsRecorder {
kCloseNoteButton,
kCancelButton,
kParentAccessButton,
kEnterpriseEnrollmentButton,
kTargetCount,
};
......
......@@ -34,6 +34,7 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
static bool IsAddUserButtonShown();
static bool IsCancelButtonShown();
static bool IsParentAccessButtonShown();
static bool IsEnterpriseEnrollmentButtonShown();
static bool IsWarningBubbleShown();
static bool IsSystemInfoShown();
static bool IsPasswordFieldShown(const AccountId& account_id);
......
......@@ -66,6 +66,9 @@ enum class OobeDialogState {
// Showing login UI provided by a Chrome extension using chrome.loginScreenUi
// API.
EXTENSION_LOGIN = 14,
// Showing user creation screen.
USER_CREATION = 15,
};
// Supported multi-profile user behavior values.
......
......@@ -14,6 +14,7 @@
#include "ash/login/login_screen_controller.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/login_accelerators.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/resources/vector_icons/vector_icons.h"
......@@ -89,6 +90,9 @@ LoginMetricsRecorder::ShelfButtonClickTarget GetUserClickTarget(int button_id) {
return LoginMetricsRecorder::ShelfButtonClickTarget::kCancelButton;
case LoginShelfView::kParentAccess:
return LoginMetricsRecorder::ShelfButtonClickTarget::kParentAccessButton;
case LoginShelfView::kEnterpriseEnrollment:
return LoginMetricsRecorder::ShelfButtonClickTarget::
kEnterpriseEnrollmentButton;
}
return LoginMetricsRecorder::ShelfButtonClickTarget::kTargetCount;
}
......@@ -481,6 +485,8 @@ LoginShelfView::LoginShelfView(
kShelfBrowseAsGuestButtonIcon);
add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon);
add_button(kParentAccess, IDS_ASH_PARENT_ACCESS_BUTTON, kPinRequestLockIcon);
add_button(kEnterpriseEnrollment, IDS_ASH_ENTERPRISE_ENROLLMENT_BUTTON,
kLoginScreenEnterpriseIcon);
// Adds observers for states that affect the visiblity of different buttons.
tray_action_observer_.Add(Shell::Get()->tray_action());
......@@ -579,6 +585,10 @@ void LoginShelfView::ButtonPressed(views::Button* sender,
LockScreen::Get()->ShowParentAccessDialog();
}));
break;
case kEnterpriseEnrollment:
Shell::Get()->login_screen_controller()->HandleAccelerator(
ash::LoginAcceleratorAction::kStartEnrollment);
break;
default:
NOTREACHED();
}
......@@ -644,8 +654,16 @@ void LoginShelfView::SetShutdownButtonEnabled(bool enable_shutdown_button) {
}
void LoginShelfView::SetButtonOpacity(float target_opacity) {
static constexpr ButtonId kButtonIds[] = {
kShutdown, kRestart, kSignOut, kCloseNote,
kCancel, kParentAccess, kBrowseAsGuest, kAddUser};
kShutdown,
kRestart,
kSignOut,
kCloseNote,
kCancel,
kParentAccess,
kBrowseAsGuest,
kAddUser,
kEnterpriseEnrollment
};
for (const auto& button_id : kButtonIds) {
AnimateButtonOpacity(GetViewByID(button_id)->layer(), target_opacity,
ShelfConfig::Get()->DimAnimationDuration(),
......@@ -749,6 +767,8 @@ void LoginShelfView::UpdateUi() {
bool is_oobe = (session_state == SessionState::OOBE);
GetViewByID(kBrowseAsGuest)->SetVisible(ShouldShowGuestButton());
GetViewByID(kEnterpriseEnrollment)
->SetVisible(ShouldShowEnterpriseEnrollmentButton());
// Show add user button when it's in login screen and Oobe UI dialog is not
// visible. The button should not appear if the device is not connected to a
......@@ -776,6 +796,8 @@ void LoginShelfView::UpdateButtonColors(bool use_dark_colors) {
static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest))
->PaintDarkColors();
static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintDarkColors();
static_cast<LoginShelfButton*>(GetViewByID(kEnterpriseEnrollment))
->PaintDarkColors();
kiosk_apps_button_->PaintDarkColors();
} else {
static_cast<LoginShelfButton*>(GetViewByID(kShutdown))->PaintLightColors();
......@@ -788,6 +810,8 @@ void LoginShelfView::UpdateButtonColors(bool use_dark_colors) {
static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest))
->PaintLightColors();
static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintLightColors();
static_cast<LoginShelfButton*>(GetViewByID(kEnterpriseEnrollment))
->PaintLightColors();
kiosk_apps_button_->PaintLightColors();
}
}
......@@ -843,4 +867,11 @@ bool LoginShelfView::ShouldShowGuestButton() const {
return true;
}
bool LoginShelfView::ShouldShowEnterpriseEnrollmentButton() const {
const SessionState session_state =
Shell::Get()->session_controller()->GetSessionState();
return session_state == SessionState::OOBE &&
dialog_state_ == OobeDialogState::USER_CREATION;
}
} // namespace ash
......@@ -48,15 +48,16 @@ class ASH_EXPORT LoginShelfView : public views::View,
public LoginDataDispatcher::Observer {
public:
enum ButtonId {
kShutdown = 1, // Shut down the device.
kRestart, // Restart the device.
kSignOut, // Sign out the active user session.
kCloseNote, // Close the lock screen note.
kCancel, // Cancel multiple user sign-in.
kBrowseAsGuest, // Use in guest mode.
kAddUser, // Add a new user.
kApps, // Show list of available kiosk apps.
kParentAccess // Unlock child device with Parent Access Code.
kShutdown = 1, // Shut down the device.
kRestart, // Restart the device.
kSignOut, // Sign out the active user session.
kCloseNote, // Close the lock screen note.
kCancel, // Cancel multiple user sign-in.
kBrowseAsGuest, // Use in guest mode.
kAddUser, // Add a new user.
kApps, // Show list of available kiosk apps.
kParentAccess, // Unlock child device with Parent Access Code.
kEnterpriseEnrollment, // Start enterprise enrollment flow.
};
// Stores and notifies UiUpdate test callbacks.
......@@ -169,6 +170,8 @@ class ASH_EXPORT LoginShelfView : public views::View,
bool ShouldShowGuestButton() const;
bool ShouldShowEnterpriseEnrollmentButton() const;
OobeDialogState dialog_state_ = OobeDialogState::HIDDEN;
bool allow_guest_ = true;
bool allow_guest_in_oobe_ = false;
......
......@@ -501,6 +501,15 @@ TEST_F(LoginShelfViewTest, ClickBrowseAsGuestButton) {
Click(LoginShelfView::kBrowseAsGuest);
}
TEST_F(LoginShelfViewTest, ClickEnterpriseEnrollmentButton) {
auto client = std::make_unique<MockLoginScreenClient>();
EXPECT_CALL(*client,
HandleAccelerator(ash::LoginAcceleratorAction::kStartEnrollment));
login_shelf_view_->SetLoginDialogState(OobeDialogState::USER_CREATION);
Click(LoginShelfView::kEnterpriseEnrollment);
}
TEST_F(LoginShelfViewTest, TabGoesFromShelfToStatusAreaAndBackToShelf) {
CreateUserSessions(1);
NotifySessionStateChanged(SessionState::LOCKED);
......@@ -678,6 +687,33 @@ TEST_F(LoginShelfViewTest, ParentAccessButtonVisibilityChangeOnLockScreen) {
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
}
TEST_F(LoginShelfViewTest, EnterpriseEnrollmentButtonVisbility) {
// Enterprise enrollment button should only be available when user creation
// screen is shown in OOBE.
login_shelf_view_->SetLoginDialogState(OobeDialogState::USER_CREATION);
NotifySessionStateChanged(SessionState::OOBE);
EXPECT_TRUE(ShowsShelfButtons(
{LoginShelfView::kShutdown, LoginShelfView::kEnterpriseEnrollment}));
NotifySessionStateChanged(SessionState::LOGIN_PRIMARY);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
NotifySessionStateChanged(SessionState::LOGGED_IN_NOT_ACTIVE);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
NotifySessionStateChanged(SessionState::ACTIVE);
EXPECT_TRUE(ShowsShelfButtons({}));
NotifySessionStateChanged(SessionState::LOCKED);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
NotifySessionStateChanged(SessionState::LOGIN_SECONDARY);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kCancel}));
}
TEST_F(LoginShelfViewTest, TapShutdownWithSwipeDetectionEnabledOnLogin) {
NotifySessionStateChanged(session_manager::SessionState::LOGIN_PRIMARY);
TabletModeControllerTestApi().EnterTabletMode();
......
......@@ -54,13 +54,14 @@ IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, DefaultVisibility) {
EXPECT_TRUE(ash::LoginScreenTestApi::IsAddUserButtonShown());
}
// Verifies that guest button and add user button are hidden when Gaia
// dialog is shown.
// Verifies that guest button, add user button and enterprise enrollment button
// are hidden when Gaia dialog is shown.
IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, GaiaDialogOpen) {
EXPECT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton());
test::OobeGaiaPageWaiter().WaitUntilReady();
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsEnterpriseEnrollmentButtonShown());
}
// Verifies that guest button and add user button are hidden on post-login
......
......@@ -215,6 +215,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_ASH_SHELF_APPS_BUTTON" desc="Text shown on apps button on login screen.">
Apps
</message>
<message name="IDS_ASH_ENTERPRISE_ENROLLMENT_BUTTON" desc="Text shown on enterprise enrollment button on oobe screen.">
Enterprise enrollment
</message>
<message name="IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE" desc="The title used for the Ash Launcher in the Shelf (not mentioning 'Apps' since this is a general launcher).">
Launcher
......
6a94df80daac9ae3c3d49e3b75079d2b29c4ab0d
\ No newline at end of file
......@@ -76,4 +76,5 @@ var OOBE_UI_STATE = {
BLOCKING: 10,
KIOSK: 11,
MIGRATION: 12,
USER_CREATION: 15,
};
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