Commit 818a443d authored by Thomas Tellier's avatar Thomas Tellier Committed by Commit Bot

Migrate user adding screen to view-based implementation

Bug: 1066489
Change-Id: Ic997e1b8de256ab66ef28710ff41c2ff9299a378
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219889
Commit-Queue: Thomas Tellier <tellier@google.com>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784827}
parent f011a309
......@@ -399,11 +399,12 @@ void LoginScreenController::ShowLockScreen() {
void LoginScreenController::ShowLoginScreen() {
// Login screen can only be used during login.
CHECK_EQ(session_manager::SessionState::LOGIN_PRIMARY,
Shell::Get()->session_controller()->GetSessionState())
session_manager::SessionState session_state =
Shell::Get()->session_controller()->GetSessionState();
CHECK(session_state == session_manager::SessionState::LOGIN_PRIMARY ||
session_state == session_manager::SessionState::LOGIN_SECONDARY)
<< "Not showing login screen since session state is "
<< static_cast<int>(
Shell::Get()->session_controller()->GetSessionState());
<< static_cast<int>(session_state);
OnShow();
// TODO(jdufault): rename LockScreen to LoginScreen.
......
......@@ -131,7 +131,6 @@ class ExistingUserController : public LoginDisplay::Delegate,
const content::NotificationDetails& details) override;
// Set a delegate that we will pass AuthStatusConsumer events to.
// Used for testing.
void set_login_status_consumer(AuthStatusConsumer* consumer) {
auth_status_consumer_ = consumer;
}
......
......@@ -15,4 +15,7 @@ specific_include_rules = {
"+ash/accessibility/focus_ring_controller.h",
"+ash/shell.h",
],
"login_display_host_mojo\.cc": [
"+ash/shell.h",
],
}
......@@ -7,6 +7,8 @@
#include <utility>
#include "ash/public/cpp/login_screen.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
......@@ -39,6 +41,7 @@
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_names.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/aura/window.h"
namespace chromeos {
......@@ -63,28 +66,33 @@ LoginDisplayHostMojo::AuthState::AuthState(
LoginDisplayHostMojo::AuthState::~AuthState() = default;
LoginDisplayHostMojo::LoginDisplayHostMojo()
LoginDisplayHostMojo::LoginDisplayHostMojo(DisplayedScreen displayed_screen)
: login_display_(std::make_unique<LoginDisplayMojo>(this)),
user_board_view_mojo_(std::make_unique<UserBoardViewMojo>()),
user_selection_screen_(
std::make_unique<ChromeUserSelectionScreen>(kLoginDisplay)),
system_info_updater_(std::make_unique<MojoSystemInfoDispatcher>()) {
system_info_updater_(std::make_unique<MojoSystemInfoDispatcher>()),
displayed_screen_(displayed_screen) {
user_selection_screen_->SetView(user_board_view_mojo_.get());
// Preload webui-based OOBE for add user, kiosk apps, etc.
LoadOobeDialog();
if (displayed_screen == DisplayedScreen::SIGN_IN_SCREEN) {
// Preload webui-based OOBE for add user, kiosk apps, etc.
LoadOobeDialog();
// Should be created after OobeUI loaded with the dialog.
wizard_controller_ = std::make_unique<WizardController>();
// Should be created after OobeUI loaded with the dialog.
wizard_controller_ = std::make_unique<WizardController>();
GetLoginScreenCertProviderService()->pin_dialog_manager()->AddPinDialogHost(
&security_token_pin_dialog_host_ash_impl_);
GetLoginScreenCertProviderService()->pin_dialog_manager()->AddPinDialogHost(
&security_token_pin_dialog_host_ash_impl_);
}
}
LoginDisplayHostMojo::~LoginDisplayHostMojo() {
GetLoginScreenCertProviderService()
->pin_dialog_manager()
->RemovePinDialogHost(&security_token_pin_dialog_host_ash_impl_);
if (displayed_screen_ == DisplayedScreen::SIGN_IN_SCREEN) {
GetLoginScreenCertProviderService()
->pin_dialog_manager()
->RemovePinDialogHost(&security_token_pin_dialog_host_ash_impl_);
}
LoginScreenClient::Get()->SetDelegate(nullptr);
if (dialog_) {
dialog_->GetOobeUI()->signin_screen_handler()->SetDelegate(nullptr);
......@@ -213,11 +221,23 @@ WizardController* LoginDisplayHostMojo::GetWizardController() {
}
void LoginDisplayHostMojo::OnStartUserAdding() {
NOTIMPLEMENTED();
VLOG(1) << "Login Mojo >> user adding";
// Lock container can be transparent after lock screen animation.
aura::Window* lock_container = ash::Shell::GetContainer(
ash::Shell::GetPrimaryRootWindow(),
ash::kShellWindowId_LockScreenContainersContainer);
lock_container->layer()->SetOpacity(1.0);
CreateExistingUserController();
SetStatusAreaVisible(true);
existing_user_controller_->Init(
user_manager::UserManager::Get()->GetUsersAllowedForMultiProfile());
}
void LoginDisplayHostMojo::CancelUserAdding() {
NOTIMPLEMENTED();
Finalize(base::OnceClosure());
}
void LoginDisplayHostMojo::OnStartSignInScreen() {
......@@ -242,11 +262,7 @@ void LoginDisplayHostMojo::OnStartSignInScreen() {
signin_screen_started_ = true;
existing_user_controller_ = std::make_unique<ExistingUserController>();
login_display_->set_delegate(existing_user_controller_.get());
// We need auth attempt results to notify views-based lock screen.
existing_user_controller_->set_login_status_consumer(this);
CreateExistingUserController();
// Load the UI.
existing_user_controller_->Init(user_manager::UserManager::Get()->GetUsers());
......@@ -559,4 +575,12 @@ void LoginDisplayHostMojo::StopObservingOobeUI() {
oobe_ui->RemoveObserver(this);
}
void LoginDisplayHostMojo::CreateExistingUserController() {
existing_user_controller_ = std::make_unique<ExistingUserController>();
login_display_->set_delegate(existing_user_controller_.get());
// We need auth attempt results to notify views-based login screen.
existing_user_controller_->set_login_status_consumer(this);
}
} // namespace chromeos
......@@ -38,7 +38,9 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
public AuthStatusConsumer,
public OobeUI::Observer {
public:
LoginDisplayHostMojo();
enum class DisplayedScreen { SIGN_IN_SCREEN, USER_ADDING_SCREEN };
explicit LoginDisplayHostMojo(DisplayedScreen displayed_screen);
~LoginDisplayHostMojo() override;
// Called when the gaia dialog is destroyed.
......@@ -143,6 +145,10 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
// Removes this as a |OobeUI::Observer| if it has been added as an observer.
void StopObservingOobeUI();
// Create ExistingUserController and link it to LoginDisplayHostMojo so we can
// consume auth status events.
void CreateExistingUserController();
// State associated with a pending authentication attempt.
struct AuthState {
AuthState(AccountId account_id, base::OnceCallback<void(bool)> callback);
......@@ -191,6 +197,9 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
// Set if Gaia dialog is shown with prefilled email.
base::Optional<AccountId> gaia_reauth_account_id_;
// Store which screen is currently displayed.
DisplayedScreen displayed_screen_ = DisplayedScreen::SIGN_IN_SCREEN;
base::WeakPtrFactory<LoginDisplayHostMojo> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostMojo);
......
......@@ -232,7 +232,8 @@ void ShowLoginWizardFinish(
// Tests may have already allocated an instance for us to use.
display_host = chromeos::LoginDisplayHost::default_host();
} else if (ShouldShowSigninScreen(first_screen)) {
display_host = new chromeos::LoginDisplayHostMojo();
display_host = new chromeos::LoginDisplayHostMojo(
LoginDisplayHostMojo::DisplayedScreen::SIGN_IN_SCREEN);
} else {
display_host = new chromeos::LoginDisplayHostWebUI();
}
......
......@@ -137,8 +137,10 @@ void LoginDisplayMojo::OnPreferencesChanged() {
}
void LoginDisplayMojo::SetUIEnabled(bool is_enabled) {
if (is_enabled)
// OOBE UI is null iff we display the user adding screen.
if (is_enabled && host_->GetOobeUI() != nullptr) {
host_->GetOobeUI()->ShowOobeUI(false);
}
}
void LoginDisplayMojo::ShowError(int error_msg_id,
......
......@@ -10,9 +10,11 @@
#include "base/observer_list.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_mojo.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen_input_methods_controller.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "ui/gfx/geometry/rect.h"
......@@ -54,6 +56,7 @@ class UserAddingScreenImpl : public UserAddingScreen {
}
private:
// OobeUI::Observer:
void OnCurrentScreenChanged(OobeScreenId current_screen,
OobeScreenId new_screen) override {
if (new_screen != OobeScreen::SCREEN_ACCOUNT_PICKER)
......@@ -86,14 +89,22 @@ class UserAddingScreenImpl : public UserAddingScreen {
void UserAddingScreenImpl::Start() {
CHECK(!IsRunning());
reporter_ = std::make_unique<LoadTimeReporter>();
display_host_ = new chromeos::LoginDisplayHostWebUI();
bool viewBasedEnabled =
chromeos::features::IsViewBasedMultiprofileLoginEnabled();
if (viewBasedEnabled) {
display_host_ = new chromeos::LoginDisplayHostMojo(
LoginDisplayHostMojo::DisplayedScreen::USER_ADDING_SCREEN);
} else {
display_host_ = new chromeos::LoginDisplayHostWebUI();
reporter_ = std::make_unique<LoadTimeReporter>();
}
session_manager::SessionManager::Get()->SetSessionState(
session_manager::SessionState::LOGIN_SECONDARY);
display_host_->StartUserAdding(base::BindOnce(
&UserAddingScreenImpl::OnDisplayHostCompletion, base::Unretained(this)));
reporter_->Observe(display_host_->GetOobeUI());
if (!viewBasedEnabled)
reporter_->Observe(display_host_->GetOobeUI());
session_manager::SessionManager::Get()->SetSessionState(
session_manager::SessionState::LOGIN_SECONDARY);
for (auto& observer : observers_)
observer.OnUserAddingStarted();
}
......
......@@ -246,6 +246,10 @@ const base::Feature kImeInputLogicFst{"ImeInputLogicFst",
const base::Feature kImeInputLogicMozc{"ImeInputLogicMozc",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables view-based version of multiprofile login, as opposed to Web UI one.
const base::Feature kViewBasedMultiprofileLogin{
"ViewBasedMultiprofileLogin", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable or disable using the floating virtual keyboard as the default option
// on Chrome OS.
const base::Feature kVirtualKeyboardFloatingDefault{
......@@ -544,6 +548,10 @@ bool IsSplitSettingsSyncEnabled() {
return base::FeatureList::IsEnabled(kSplitSettingsSync);
}
bool IsViewBasedMultiprofileLoginEnabled() {
return base::FeatureList::IsEnabled(kViewBasedMultiprofileLogin);
}
bool ShouldShowPlayStoreInDemoMode() {
return base::FeatureList::IsEnabled(kShowPlayInDemoMode);
}
......
......@@ -197,6 +197,8 @@ extern const base::Feature kUserActivityPrediction;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kUseSearchClickForRightClick;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kViewBasedMultiprofileLogin;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kVirtualKeyboardBorderedKey;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kVirtualKeyboardFloatingResizable;
......@@ -226,6 +228,7 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool IsQuickAnswersTextAnnotatorEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsQuickAnswersTranslationEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsSyncEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsViewBasedMultiprofileLoginEnabled();
// TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default.
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldShowPlayStoreInDemoMode();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldUseBrowserSyncConsent();
......
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