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() { ...@@ -206,6 +206,11 @@ bool LoginScreenTestApi::IsParentAccessButtonShown() {
return IsLoginShelfViewButtonShown(LoginShelfView::kParentAccess); return IsLoginShelfViewButtonShown(LoginShelfView::kParentAccess);
} }
// static
bool LoginScreenTestApi::IsEnterpriseEnrollmentButtonShown() {
return IsLoginShelfViewButtonShown(LoginShelfView::kEnterpriseEnrollment);
}
// static // static
bool LoginScreenTestApi::IsWarningBubbleShown() { bool LoginScreenTestApi::IsWarningBubbleShown() {
LockScreen::TestApi lock_screen_test(LockScreen::Get()); LockScreen::TestApi lock_screen_test(LockScreen::Get());
......
...@@ -80,6 +80,11 @@ const ShelfButtonClickMapping kShelfTargets[] = { ...@@ -80,6 +80,11 @@ const ShelfButtonClickMapping kShelfTargets[] = {
LoginMetricsRecorder::LockScreenUserClickTarget::kParentAccessButton, LoginMetricsRecorder::LockScreenUserClickTarget::kParentAccessButton,
LoginMetricsRecorder::LoginScreenUserClickTarget::kTargetCount, LoginMetricsRecorder::LoginScreenUserClickTarget::kTargetCount,
LoginMetricsRecorder::OobeUserClickTarget::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 // Defines mapping of TrayClickTarget |original| to different UMA target in
......
...@@ -53,6 +53,7 @@ class ASH_EXPORT LoginMetricsRecorder { ...@@ -53,6 +53,7 @@ class ASH_EXPORT LoginMetricsRecorder {
kSystemTray, kSystemTray,
kVirtualKeyboardTray, kVirtualKeyboardTray,
kImeTray, kImeTray,
kEnterpriseEnrollmentButton,
kTargetCount, kTargetCount,
}; };
...@@ -78,6 +79,7 @@ class ASH_EXPORT LoginMetricsRecorder { ...@@ -78,6 +79,7 @@ class ASH_EXPORT LoginMetricsRecorder {
kCloseNoteButton, kCloseNoteButton,
kCancelButton, kCancelButton,
kParentAccessButton, kParentAccessButton,
kEnterpriseEnrollmentButton,
kTargetCount, kTargetCount,
}; };
......
...@@ -34,6 +34,7 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi { ...@@ -34,6 +34,7 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
static bool IsAddUserButtonShown(); static bool IsAddUserButtonShown();
static bool IsCancelButtonShown(); static bool IsCancelButtonShown();
static bool IsParentAccessButtonShown(); static bool IsParentAccessButtonShown();
static bool IsEnterpriseEnrollmentButtonShown();
static bool IsWarningBubbleShown(); static bool IsWarningBubbleShown();
static bool IsSystemInfoShown(); static bool IsSystemInfoShown();
static bool IsPasswordFieldShown(const AccountId& account_id); static bool IsPasswordFieldShown(const AccountId& account_id);
......
...@@ -66,6 +66,9 @@ enum class OobeDialogState { ...@@ -66,6 +66,9 @@ enum class OobeDialogState {
// Showing login UI provided by a Chrome extension using chrome.loginScreenUi // Showing login UI provided by a Chrome extension using chrome.loginScreenUi
// API. // API.
EXTENSION_LOGIN = 14, EXTENSION_LOGIN = 14,
// Showing user creation screen.
USER_CREATION = 15,
}; };
// Supported multi-profile user behavior values. // Supported multi-profile user behavior values.
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/login/login_screen_controller.h" #include "ash/login/login_screen_controller.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/public/cpp/ash_constants.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/login_constants.h"
#include "ash/public/cpp/shelf_config.h" #include "ash/public/cpp/shelf_config.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -89,6 +90,9 @@ LoginMetricsRecorder::ShelfButtonClickTarget GetUserClickTarget(int button_id) { ...@@ -89,6 +90,9 @@ LoginMetricsRecorder::ShelfButtonClickTarget GetUserClickTarget(int button_id) {
return LoginMetricsRecorder::ShelfButtonClickTarget::kCancelButton; return LoginMetricsRecorder::ShelfButtonClickTarget::kCancelButton;
case LoginShelfView::kParentAccess: case LoginShelfView::kParentAccess:
return LoginMetricsRecorder::ShelfButtonClickTarget::kParentAccessButton; return LoginMetricsRecorder::ShelfButtonClickTarget::kParentAccessButton;
case LoginShelfView::kEnterpriseEnrollment:
return LoginMetricsRecorder::ShelfButtonClickTarget::
kEnterpriseEnrollmentButton;
} }
return LoginMetricsRecorder::ShelfButtonClickTarget::kTargetCount; return LoginMetricsRecorder::ShelfButtonClickTarget::kTargetCount;
} }
...@@ -481,6 +485,8 @@ LoginShelfView::LoginShelfView( ...@@ -481,6 +485,8 @@ LoginShelfView::LoginShelfView(
kShelfBrowseAsGuestButtonIcon); kShelfBrowseAsGuestButtonIcon);
add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon); add_button(kAddUser, IDS_ASH_ADD_USER_BUTTON, kShelfAddPersonButtonIcon);
add_button(kParentAccess, IDS_ASH_PARENT_ACCESS_BUTTON, kPinRequestLockIcon); 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. // Adds observers for states that affect the visiblity of different buttons.
tray_action_observer_.Add(Shell::Get()->tray_action()); tray_action_observer_.Add(Shell::Get()->tray_action());
...@@ -579,6 +585,10 @@ void LoginShelfView::ButtonPressed(views::Button* sender, ...@@ -579,6 +585,10 @@ void LoginShelfView::ButtonPressed(views::Button* sender,
LockScreen::Get()->ShowParentAccessDialog(); LockScreen::Get()->ShowParentAccessDialog();
})); }));
break; break;
case kEnterpriseEnrollment:
Shell::Get()->login_screen_controller()->HandleAccelerator(
ash::LoginAcceleratorAction::kStartEnrollment);
break;
default: default:
NOTREACHED(); NOTREACHED();
} }
...@@ -644,8 +654,16 @@ void LoginShelfView::SetShutdownButtonEnabled(bool enable_shutdown_button) { ...@@ -644,8 +654,16 @@ void LoginShelfView::SetShutdownButtonEnabled(bool enable_shutdown_button) {
} }
void LoginShelfView::SetButtonOpacity(float target_opacity) { void LoginShelfView::SetButtonOpacity(float target_opacity) {
static constexpr ButtonId kButtonIds[] = { static constexpr ButtonId kButtonIds[] = {
kShutdown, kRestart, kSignOut, kCloseNote, kShutdown,
kCancel, kParentAccess, kBrowseAsGuest, kAddUser}; kRestart,
kSignOut,
kCloseNote,
kCancel,
kParentAccess,
kBrowseAsGuest,
kAddUser,
kEnterpriseEnrollment
};
for (const auto& button_id : kButtonIds) { for (const auto& button_id : kButtonIds) {
AnimateButtonOpacity(GetViewByID(button_id)->layer(), target_opacity, AnimateButtonOpacity(GetViewByID(button_id)->layer(), target_opacity,
ShelfConfig::Get()->DimAnimationDuration(), ShelfConfig::Get()->DimAnimationDuration(),
...@@ -749,6 +767,8 @@ void LoginShelfView::UpdateUi() { ...@@ -749,6 +767,8 @@ void LoginShelfView::UpdateUi() {
bool is_oobe = (session_state == SessionState::OOBE); bool is_oobe = (session_state == SessionState::OOBE);
GetViewByID(kBrowseAsGuest)->SetVisible(ShouldShowGuestButton()); GetViewByID(kBrowseAsGuest)->SetVisible(ShouldShowGuestButton());
GetViewByID(kEnterpriseEnrollment)
->SetVisible(ShouldShowEnterpriseEnrollmentButton());
// Show add user button when it's in login screen and Oobe UI dialog is not // 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 // 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) { ...@@ -776,6 +796,8 @@ void LoginShelfView::UpdateButtonColors(bool use_dark_colors) {
static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest)) static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest))
->PaintDarkColors(); ->PaintDarkColors();
static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintDarkColors(); static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintDarkColors();
static_cast<LoginShelfButton*>(GetViewByID(kEnterpriseEnrollment))
->PaintDarkColors();
kiosk_apps_button_->PaintDarkColors(); kiosk_apps_button_->PaintDarkColors();
} else { } else {
static_cast<LoginShelfButton*>(GetViewByID(kShutdown))->PaintLightColors(); static_cast<LoginShelfButton*>(GetViewByID(kShutdown))->PaintLightColors();
...@@ -788,6 +810,8 @@ void LoginShelfView::UpdateButtonColors(bool use_dark_colors) { ...@@ -788,6 +810,8 @@ void LoginShelfView::UpdateButtonColors(bool use_dark_colors) {
static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest)) static_cast<LoginShelfButton*>(GetViewByID(kBrowseAsGuest))
->PaintLightColors(); ->PaintLightColors();
static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintLightColors(); static_cast<LoginShelfButton*>(GetViewByID(kAddUser))->PaintLightColors();
static_cast<LoginShelfButton*>(GetViewByID(kEnterpriseEnrollment))
->PaintLightColors();
kiosk_apps_button_->PaintLightColors(); kiosk_apps_button_->PaintLightColors();
} }
} }
...@@ -843,4 +867,11 @@ bool LoginShelfView::ShouldShowGuestButton() const { ...@@ -843,4 +867,11 @@ bool LoginShelfView::ShouldShowGuestButton() const {
return true; 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 } // namespace ash
...@@ -56,7 +56,8 @@ class ASH_EXPORT LoginShelfView : public views::View, ...@@ -56,7 +56,8 @@ class ASH_EXPORT LoginShelfView : public views::View,
kBrowseAsGuest, // Use in guest mode. kBrowseAsGuest, // Use in guest mode.
kAddUser, // Add a new user. kAddUser, // Add a new user.
kApps, // Show list of available kiosk apps. kApps, // Show list of available kiosk apps.
kParentAccess // Unlock child device with Parent Access Code. kParentAccess, // Unlock child device with Parent Access Code.
kEnterpriseEnrollment, // Start enterprise enrollment flow.
}; };
// Stores and notifies UiUpdate test callbacks. // Stores and notifies UiUpdate test callbacks.
...@@ -169,6 +170,8 @@ class ASH_EXPORT LoginShelfView : public views::View, ...@@ -169,6 +170,8 @@ class ASH_EXPORT LoginShelfView : public views::View,
bool ShouldShowGuestButton() const; bool ShouldShowGuestButton() const;
bool ShouldShowEnterpriseEnrollmentButton() const;
OobeDialogState dialog_state_ = OobeDialogState::HIDDEN; OobeDialogState dialog_state_ = OobeDialogState::HIDDEN;
bool allow_guest_ = true; bool allow_guest_ = true;
bool allow_guest_in_oobe_ = false; bool allow_guest_in_oobe_ = false;
......
...@@ -501,6 +501,15 @@ TEST_F(LoginShelfViewTest, ClickBrowseAsGuestButton) { ...@@ -501,6 +501,15 @@ TEST_F(LoginShelfViewTest, ClickBrowseAsGuestButton) {
Click(LoginShelfView::kBrowseAsGuest); 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) { TEST_F(LoginShelfViewTest, TabGoesFromShelfToStatusAreaAndBackToShelf) {
CreateUserSessions(1); CreateUserSessions(1);
NotifySessionStateChanged(SessionState::LOCKED); NotifySessionStateChanged(SessionState::LOCKED);
...@@ -678,6 +687,33 @@ TEST_F(LoginShelfViewTest, ParentAccessButtonVisibilityChangeOnLockScreen) { ...@@ -678,6 +687,33 @@ TEST_F(LoginShelfViewTest, ParentAccessButtonVisibilityChangeOnLockScreen) {
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut})); 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) { TEST_F(LoginShelfViewTest, TapShutdownWithSwipeDetectionEnabledOnLogin) {
NotifySessionStateChanged(session_manager::SessionState::LOGIN_PRIMARY); NotifySessionStateChanged(session_manager::SessionState::LOGIN_PRIMARY);
TabletModeControllerTestApi().EnterTabletMode(); TabletModeControllerTestApi().EnterTabletMode();
......
...@@ -54,13 +54,14 @@ IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, DefaultVisibility) { ...@@ -54,13 +54,14 @@ IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, DefaultVisibility) {
EXPECT_TRUE(ash::LoginScreenTestApi::IsAddUserButtonShown()); EXPECT_TRUE(ash::LoginScreenTestApi::IsAddUserButtonShown());
} }
// Verifies that guest button and add user button are hidden when Gaia // Verifies that guest button, add user button and enterprise enrollment button
// dialog is shown. // are hidden when Gaia dialog is shown.
IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, GaiaDialogOpen) { IN_PROC_BROWSER_TEST_F(LoginUIShelfVisibilityTest, GaiaDialogOpen) {
EXPECT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton()); EXPECT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton());
test::OobeGaiaPageWaiter().WaitUntilReady(); test::OobeGaiaPageWaiter().WaitUntilReady();
EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsGuestButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown()); EXPECT_FALSE(ash::LoginScreenTestApi::IsAddUserButtonShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsEnterpriseEnrollmentButtonShown());
} }
// Verifies that guest button and add user button are hidden on post-login // 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. ...@@ -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."> <message name="IDS_ASH_SHELF_APPS_BUTTON" desc="Text shown on apps button on login screen.">
Apps Apps
</message> </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)."> <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 Launcher
......
6a94df80daac9ae3c3d49e3b75079d2b29c4ab0d
\ No newline at end of file
...@@ -76,4 +76,5 @@ var OOBE_UI_STATE = { ...@@ -76,4 +76,5 @@ var OOBE_UI_STATE = {
BLOCKING: 10, BLOCKING: 10,
KIOSK: 11, KIOSK: 11,
MIGRATION: 12, 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