Commit 09b4a197 authored by Renato Silva's avatar Renato Silva Committed by Commit Bot

Reland: CrOS - Login Screen - Minor cleanup

Reverted due to a merge conflict with another CL.

Original change's description:
> CrOS - Login Screen - Minor cleanup
>
> Rename AnimationState to UiState and use it to determine the
> visibility of elements. Remove multiple variables in favor of
> UiState.
>
> Bug: 1075994
> Change-Id: I0d7413fb173dadbff22cde0eb3af6f43586bdee2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352883
> Commit-Queue: Renato Silva <rrsilva@google.com>
> Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#798780}

Bug: 1075994
Change-Id: I0e2c05b692ddb807930455fca6b5a2216c0a16e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362183Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Commit-Queue: Renato Silva <rrsilva@google.com>
Cr-Commit-Position: refs/heads/master@{#799680}
parent 0ad9a3ec
...@@ -1763,7 +1763,7 @@ void LockContentsView::LayoutAuth(LoginBigUserView* to_update, ...@@ -1763,7 +1763,7 @@ void LockContentsView::LayoutAuth(LoginBigUserView* to_update,
DCHECK(to_update); DCHECK(to_update);
auto capture_animation_state_pre_layout = [&](LoginBigUserView* view) { auto capture_animation_state_pre_layout = [&](LoginBigUserView* view) {
if (!animate || !view) if (!view)
return; return;
if (view->auth_user()) if (view->auth_user())
view->auth_user()->CaptureStateForAnimationPreLayout(); view->auth_user()->CaptureStateForAnimationPreLayout();
...@@ -1818,10 +1818,10 @@ void LockContentsView::LayoutAuth(LoginBigUserView* to_update, ...@@ -1818,10 +1818,10 @@ void LockContentsView::LayoutAuth(LoginBigUserView* to_update,
}; };
auto apply_animation_post_layout = [&](LoginBigUserView* view) { auto apply_animation_post_layout = [&](LoginBigUserView* view) {
if (!animate || !view) if (!view)
return; return;
if (view->auth_user()) if (view->auth_user())
view->auth_user()->ApplyAnimationPostLayout(); view->auth_user()->ApplyAnimationPostLayout(animate);
}; };
// The high-level layout flow: // The high-level layout flow:
......
This diff is collapsed.
...@@ -68,7 +68,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -68,7 +68,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// This is determined by the current authentication methods // This is determined by the current authentication methods
// that a user has. // that a user has.
enum class InputFieldMode { enum class InputFieldMode {
DISABLED, // Not showing any input field. NONE, // Not showing any input field.
PASSWORD_ONLY, // No PIN set. Password only field. PASSWORD_ONLY, // No PIN set. Password only field.
PIN_AND_PASSWORD, // PIN set. PIN_AND_PASSWORD, // PIN set.
}; };
...@@ -125,7 +125,8 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -125,7 +125,8 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// Set the displayed set of auth methods. |auth_methods| contains or-ed // Set the displayed set of auth methods. |auth_methods| contains or-ed
// together AuthMethod values. |auth_metadata| provides additional control // together AuthMethod values. |auth_metadata| provides additional control
// parameters for the view. // parameters for the view. Must always be called in conjunction with
// `CaptureStateForAnimationPreLayout` and `ApplyAnimationPostLayout`.
void SetAuthMethods( void SetAuthMethods(
uint32_t auth_methods, uint32_t auth_methods,
AuthMethodsMetadata auth_metadata = AuthMethodsMetadata()); AuthMethodsMetadata auth_metadata = AuthMethodsMetadata());
...@@ -140,8 +141,9 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -140,8 +141,9 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// animation. // animation.
void CaptureStateForAnimationPreLayout(); void CaptureStateForAnimationPreLayout();
// Applies animation based on current layout state compared to the most // Applies animation based on current layout state compared to the most
// recently captured state. // recently captured state. If `animate` is false, the previous UI state
void ApplyAnimationPostLayout(); // is released and no animation is performed.
void ApplyAnimationPostLayout(bool animate);
// Update the displayed name, icon, etc to that of |user|. // Update the displayed name, icon, etc to that of |user|.
void UpdateForUser(const LoginUserInfo& user); void UpdateForUser(const LoginUserInfo& user);
...@@ -172,7 +174,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -172,7 +174,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private: private:
struct AnimationState; struct UiState;
class FingerprintView; class FingerprintView;
class ChallengeResponseView; class ChallengeResponseView;
class DisabledAuthMessageView; class DisabledAuthMessageView;
...@@ -210,6 +212,9 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -210,6 +212,9 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// starts the asynchronous authentication process against a security token. // starts the asynchronous authentication process against a security token.
void AttemptAuthenticateWithChallengeResponse(); void AttemptAuthenticateWithChallengeResponse();
// Updates the element in focus. Used in `ApplyAnimationPostLayout`.
void UpdateFocus();
// Determines the mode of the input field based on the available // Determines the mode of the input field based on the available
// authentication methods. // authentication methods.
void UpdateInputFieldMode(); void UpdateInputFieldMode();
...@@ -230,7 +235,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -230,7 +235,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
AuthMethodsMetadata auth_metadata_ = AuthMethodsMetadata(); AuthMethodsMetadata auth_metadata_ = AuthMethodsMetadata();
// Controls which input field is currently being shown. // Controls which input field is currently being shown.
InputFieldMode input_field_mode_ = InputFieldMode::DISABLED; InputFieldMode input_field_mode_ = InputFieldMode::NONE;
LoginUserView* user_view_ = nullptr; LoginUserView* user_view_ = nullptr;
LoginPasswordView* password_view_ = nullptr; LoginPasswordView* password_view_ = nullptr;
...@@ -252,10 +257,10 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -252,10 +257,10 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
const OnAuthCallback on_auth_; const OnAuthCallback on_auth_;
const LoginUserView::OnTap on_tap_; const LoginUserView::OnTap on_tap_;
// Animation state that was cached from before a layout. Generated by // UI state that was stored before setting new authentication methods.
// |CaptureStateForAnimationPreLayout| and consumed by // Generated by `CaptureStateForAnimationPreLayout` and consumed by
// |ApplyAnimationPostLayout|. // `ApplyAnimationPostLayout`.
std::unique_ptr<AnimationState> cached_animation_state_; std::unique_ptr<UiState> previous_state_;
base::WeakPtrFactory<LoginAuthUserView> weak_factory_{this}; base::WeakPtrFactory<LoginAuthUserView> weak_factory_{this};
......
...@@ -65,7 +65,9 @@ class LoginAuthUserViewUnittest : public LoginTestBase { ...@@ -65,7 +65,9 @@ class LoginAuthUserViewUnittest : public LoginTestBase {
auth_metadata.show_pinpad_for_pw = show_pinpad_for_pw; auth_metadata.show_pinpad_for_pw = show_pinpad_for_pw;
auth_metadata.virtual_keyboard_visible = virtual_keyboard_visible; auth_metadata.virtual_keyboard_visible = virtual_keyboard_visible;
auth_metadata.autosubmit_pin_length = autosubmit_pin_length; auth_metadata.autosubmit_pin_length = autosubmit_pin_length;
view_->CaptureStateForAnimationPreLayout();
view_->SetAuthMethods(auth_methods, auth_metadata); view_->SetAuthMethods(auth_methods, auth_metadata);
view_->ApplyAnimationPostLayout(true);
} }
LoginUserInfo user_; LoginUserInfo user_;
...@@ -183,18 +185,14 @@ TEST_F(LoginAuthUserViewUnittest, ...@@ -183,18 +185,14 @@ TEST_F(LoginAuthUserViewUnittest,
password_test.textfield()->SetText(base::ASCIIToUTF16("Hello")); password_test.textfield()->SetText(base::ASCIIToUTF16("Hello"));
// Enable some other auth method (PIN), password is not cleared. // Enable some other auth method (PIN), password is not cleared.
view_->CaptureStateForAnimationPreLayout(); EXPECT_TRUE(has_password());
SetAuthMethods(LoginAuthUserView::AUTH_PASSWORD | SetAuthMethods(LoginAuthUserView::AUTH_PASSWORD |
LoginAuthUserView::AUTH_PIN); LoginAuthUserView::AUTH_PIN);
EXPECT_TRUE(has_password()); EXPECT_TRUE(has_password());
view_->ApplyAnimationPostLayout();
EXPECT_TRUE(has_password());
// Disable password, password is cleared. // Disable password, password is cleared.
view_->CaptureStateForAnimationPreLayout();
SetAuthMethods(LoginAuthUserView::AUTH_NONE);
EXPECT_TRUE(has_password()); EXPECT_TRUE(has_password());
view_->ApplyAnimationPostLayout(); SetAuthMethods(LoginAuthUserView::AUTH_NONE);
EXPECT_FALSE(has_password()); EXPECT_FALSE(has_password());
} }
......
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