0

[CrOS] Move ash login constants into ash/login/ui

This CL move the ash login constants to ash/login/ui, cleanup some
useless includes and move some constants to the only file there are
used.

Bug: 1148231
Change-Id: If9edccba8bd2031e2164627b561ee21740066db0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2910358
Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Commit-Queue: Thomas Tellier <tellier@google.com>
Cr-Commit-Position: refs/heads/master@{#886245}
This commit is contained in:
Thomas Tellier
2021-05-25 11:25:31 +00:00
committed by Chromium LUCI CQ
parent fb9d5c9627
commit 75c8459ef0
19 changed files with 35 additions and 54 deletions

@ -630,6 +630,7 @@ component("ash") {
"login/ui/login_big_user_view.h",
"login/ui/login_button.cc",
"login/ui/login_button.h",
"login/ui/login_constants.h",
"login/ui/login_data_dispatcher.cc",
"login/ui/login_data_dispatcher.h",
"login/ui/login_detachable_base_model.cc",

@ -6,7 +6,6 @@
#include <string>
#include "ash/public/cpp/login_constants.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "base/strings/strcat.h"

@ -13,6 +13,7 @@
#include "ash/login/ui/arrow_button_view.h"
#include "ash/login/ui/horizontal_image_sequence_animation_decoder.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_constants.h"
#include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_password_view.h"
#include "ash/login/ui/login_pin_input_view.h"
@ -23,7 +24,6 @@
#include "ash/login/ui/pin_request_view.h"
#include "ash/login/ui/system_label_button.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
@ -1371,7 +1371,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
std::move(move_to_center),
base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs));
login::kChangeUserAnimationDurationMs));
transition->set_tween_type(gfx::Tween::Type::FAST_OUT_SLOW_IN);
auto* sequence = new ui::LayerAnimationSequence(std::move(transition));
auto* observer = BuildObserverToNotifyA11yLocationChanged(this);
@ -1394,7 +1394,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
ui::ScopedLayerAnimationSettings settings(
password_view_->layer()->GetAnimator());
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs));
login::kChangeUserAnimationDurationMs));
settings.SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
if (previous_state_->has_password && !current_state.has_password) {
settings.AddObserver(
@ -1418,7 +1418,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
ui::ScopedLayerAnimationSettings settings(
pin_password_toggle_->layer()->GetAnimator());
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs));
login::kChangeUserAnimationDurationMs));
settings.SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
pin_password_toggle_->layer()->SetOpacity(opacity_end);
}
@ -1446,7 +1446,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
current_state.has_pinpad /*grow*/, pin_view_->height(),
// TODO(https://crbug.com/955119): Implement proper animation.
base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs / 2.0f),
login::kChangeUserAnimationDurationMs / 2.0f),
gfx::Tween::FAST_OUT_SLOW_IN);
auto* sequence = new ui::LayerAnimationSequence(std::move(transition));
@ -1476,7 +1476,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
ui::ScopedLayerAnimationSettings settings(
fingerprint_view_->layer()->GetAnimator());
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs));
login::kChangeUserAnimationDurationMs));
settings.SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
fingerprint_view_->layer()->SetOpacity(opacity_end);
}
@ -1496,7 +1496,7 @@ void LoginAuthUserView::ApplyAnimationPostLayout(bool animate) {
ui::ScopedLayerAnimationSettings settings(
challenge_response_view_->layer()->GetAnimator());
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs));
login::kChangeUserAnimationDurationMs));
settings.SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
challenge_response_view_->layer()->SetOpacity(opacity_end);
}

@ -4,7 +4,7 @@
#include "ash/login/ui/login_big_user_view.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/login/ui/login_constants.h"
#include "ash/shell.h"
#include "ash/style/default_color_constants.h"
#include "ash/wallpaper/wallpaper_controller_impl.h"
@ -122,7 +122,7 @@ void LoginBigUserView::OnWallpaperBlurChanged() {
views::Painter::CreateSolidRoundRectPainter(
AshColorProvider::Get()->GetShieldLayerColor(
AshColorProvider::ShieldLayerType::kShield80),
login_constants::kNonBlurredWallpaperBackgroundRadiusDp)));
login::kNonBlurredWallpaperBackgroundRadiusDp)));
}
}

@ -2,34 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_LOGIN_CONSTANTS_H_
#define ASH_PUBLIC_CPP_LOGIN_CONSTANTS_H_
#include "third_party/skia/include/core/SkColor.h"
// TODO(crbug/1148231): Move this file to ash/login/ui/login_constant.h.
#ifndef ASH_LOGIN_UI_LOGIN_CONSTANTS_H_
#define ASH_LOGIN_UI_LOGIN_CONSTANTS_H_
namespace ash {
namespace login_constants {
namespace login {
// Per above, the background should be a rounded rect with this corner radius.
constexpr int kNonBlurredWallpaperBackgroundRadiusDp = 4;
// The blur sigma for login/lock screen.
constexpr float kBlurSigma = 30.0f;
// How long should animations that change the layout of the user run for? For
// example, this includes the user switch animation as well as the PIN keyboard
// show/hide animation.
constexpr int kChangeUserAnimationDurationMs = 300;
// The most used font size on login/lock screen.
constexpr int kDefaultFontSize = 13;
// The most used font on login/lock screen.
constexpr char kDefaultFontName[] = "Roboto";
} // namespace login_constants
} // namespace login
} // namespace ash
#endif // ASH_PUBLIC_CPP_LOGIN_CONSTANTS_H_
#endif // ASH_LOGIN_UI_LOGIN_CONSTANTS_H_

@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "ash/login/ui/login_palette.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/style/ash_color_provider.h"
#include "ui/gfx/color_palette.h"

@ -10,7 +10,6 @@
#include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/login_types.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/resources/vector_icons/vector_icons.h"

@ -9,7 +9,6 @@
#include "ash/login/ui/login_button.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/bind.h"

@ -10,11 +10,11 @@
#include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/image_parser.h"
#include "ash/login/ui/login_button.h"
#include "ash/login/ui/login_constants.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/user_switch_flip_animation.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/session/user_info.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
@ -499,7 +499,7 @@ void LoginUserView::UpdateForUser(const LoginUserInfo& user, bool animate) {
user_image_->width(), 0 /*start_degrees*/, 90 /*midpoint_degrees*/,
180 /*end_degrees*/,
base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs),
login::kChangeUserAnimationDurationMs),
gfx::Tween::Type::EASE_OUT,
base::BindOnce(&LoginUserView::UpdateCurrentUserState,
base::Unretained(this)));
@ -512,9 +512,8 @@ void LoginUserView::UpdateForUser(const LoginUserInfo& user, bool animate) {
auto make_opacity_sequence = [is_opaque]() {
auto make_opacity_element = [](float target_opacity) {
auto element = ui::LayerAnimationElement::CreateOpacityElement(
target_opacity,
base::TimeDelta::FromMilliseconds(
login_constants::kChangeUserAnimationDurationMs / 2.0f));
target_opacity, base::TimeDelta::FromMilliseconds(
login::kChangeUserAnimationDurationMs / 2.0f));
element->set_tween_type(gfx::Tween::Type::EASE_OUT);
return element;
};

@ -7,11 +7,11 @@
#include <limits>
#include <memory>
#include "ash/login/ui/login_constants.h"
#include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/shell.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
@ -430,9 +430,8 @@ void ScrollableUsersListView::OnPaintBackground(gfx::Canvas* canvas) {
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(AshColorProvider::Get()->GetShieldLayerColor(
AshColorProvider::ShieldLayerType::kShield80));
canvas->DrawRoundRect(
render_bounds, login_constants::kNonBlurredWallpaperBackgroundRadiusDp,
flags);
canvas->DrawRoundRect(render_bounds,
login::kNonBlurredWallpaperBackgroundRadiusDp, flags);
}
}

@ -6,7 +6,6 @@
#define ASH_LOGIN_UI_VIEWS_UTILS_H_
#include "ash/ash_export.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/style/ash_color_provider.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/views/controls/label.h"
@ -22,15 +21,21 @@ namespace ash {
namespace login_views_utils {
namespace {
// The most used font size on login/lock screen.
constexpr int kLoginDefaultFontSize = 13;
// The most used font on login/lock screen.
constexpr char kLoginDefaultFontName[] = "Roboto";
constexpr int kDefaultLineHeight = 20;
// Helper function to get default font list for login/lock screen text label.
// It is slightly different from views::Label::GetDefaultFontList since the
// font size returned is 13 pt instead of 12 pt.
const gfx::FontList GetLoginDefaultFontList() {
return gfx::FontList(
{login_constants::kDefaultFontName}, gfx::Font::FontStyle::NORMAL,
login_constants::kDefaultFontSize, gfx::Font::Weight::NORMAL);
return gfx::FontList({kLoginDefaultFontName}, gfx::Font::FontStyle::NORMAL,
kLoginDefaultFontSize, gfx::Font::Weight::NORMAL);
}
} // namespace

@ -169,7 +169,6 @@ component("cpp") {
"lock_screen_widget_factory.h",
"login_accelerators.cc",
"login_accelerators.h",
"login_constants.h",
"login_screen.cc",
"login_screen.h",
"login_screen_client.h",

@ -16,7 +16,6 @@
#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"
#include "ash/root_window_controller.h"

@ -8,7 +8,6 @@
#include <memory>
#include "ash/animation/animation_change_type.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/wallpaper_types.h"

@ -5,7 +5,7 @@
#ifndef ASH_WALLPAPER_WALLPAPER_CONSTANTS_H_
#define ASH_WALLPAPER_WALLPAPER_CONSTANTS_H_
#include "ash/public/cpp/login_constants.h"
#include "ash/login/ui/login_constants.h"
#include "ash/style/ash_color_provider.h"
namespace ash {
@ -18,7 +18,7 @@ constexpr float kClear = 0.f;
constexpr float kOverviewBlur =
static_cast<float>(AshColorProvider::LayerBlurSigma::kBlurDefault);
// Blur sigma in lock/login screen.
constexpr float kLockLoginBlur = login_constants::kBlurSigma;
constexpr float kLockLoginBlur = 30.0f;
} // namespace wallpaper_constants

@ -12,10 +12,10 @@
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/login/ui/login_constants.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/image_downloader.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/wallpaper_controller_client.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"

@ -8,7 +8,6 @@
#include <utility>
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/shutdown_controller.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
@ -738,7 +737,7 @@ TEST_P(LockStateControllerAnimationTest, CancelShouldResetWallpaperBlur) {
// Start lock animation and verify wallpaper properties.
PressLockButton();
ExpectPreLockAnimationStarted("2");
EXPECT_EQ(login_constants::kBlurSigma, wallpaper_view->blur_sigma());
EXPECT_EQ(wallpaper_constants::kLockLoginBlur, wallpaper_view->blur_sigma());
// Cancel lock animation.
AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f);

@ -1489,7 +1489,6 @@ source_set("chromeos") {
"../ash/login/login_auth_recorder.h",
"../ash/login/login_client_cert_usage_observer.cc",
"../ash/login/login_client_cert_usage_observer.h",
"../ash/login/login_constants.h",
"../ash/login/login_pref_names.cc",
"../ash/login/login_pref_names.h",
"../ash/login/login_screen_extensions_lifetime_manager.cc",

@ -11,7 +11,6 @@
#include <utility>
#include <vector>
#include "ash/public/cpp/login_constants.h"
#include "ash/public/mojom/tray_action.mojom.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"