Commit 0fc4807b authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Apply background blur to public session.

Also polish shelf item background color.

Bug: 839604
Change-Id: I85f3762ff2a8073a71b72e1478a2a36898f6142e
Reviewed-on: https://chromium-review.googlesource.com/1180270
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarWenzhao (Colin) Zang <wzang@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584796}
parent 62284ba7
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "ui/gfx/color_analysis.h" #include "ui/gfx/color_analysis.h"
#include "ui/gfx/interpolated_transform.h" #include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -487,10 +486,6 @@ LoginAuthUserView::LoginAuthUserView(const mojom::LoginUserInfoPtr& user, ...@@ -487,10 +486,6 @@ LoginAuthUserView::LoginAuthUserView(const mojom::LoginUserInfoPtr& user,
// Update authentication UI. // Update authentication UI.
SetAuthMethods(auth_methods_, false /*can_use_pin*/); SetAuthMethods(auth_methods_, false /*can_use_pin*/);
user_view_->UpdateForUser(user, false /*animate*/); user_view_->UpdateForUser(user, false /*animate*/);
observer_.Add(Shell::Get()->wallpaper_controller());
// Ensure initial blur state is set correctly.
OnWallpaperBlurChanged();
} }
LoginAuthUserView::~LoginAuthUserView() = default; LoginAuthUserView::~LoginAuthUserView() = default;
...@@ -727,21 +722,6 @@ void LoginAuthUserView::ButtonPressed(views::Button* sender, ...@@ -727,21 +722,6 @@ void LoginAuthUserView::ButtonPressed(views::Button* sender,
OnOnlineSignInMessageTap(); OnOnlineSignInMessageTap();
} }
void LoginAuthUserView::OnWallpaperBlurChanged() {
if (Shell::Get()->wallpaper_controller()->IsWallpaperBlurred()) {
SetPaintToLayer(ui::LayerType::LAYER_NOT_DRAWN);
SetBackground(nullptr);
} else {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetBackground(views::CreateBackgroundFromPainter(
views::Painter::CreateSolidRoundRectPainter(
SkColorSetA(login_constants::kDefaultBaseColor,
login_constants::kNonBlurredWallpaperBackgroundAlpha),
login_constants::kNonBlurredWallpaperBackgroundRadiusDp)));
}
}
void LoginAuthUserView::OnAuthSubmit(const base::string16& password) { void LoginAuthUserView::OnAuthSubmit(const base::string16& password) {
// Pressing enter when the password field is empty and tap-to-unlock is // Pressing enter when the password field is empty and tap-to-unlock is
// enabled should attempt unlock. // enabled should attempt unlock.
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/public/interfaces/user_info.mojom.h" #include "ash/public/interfaces/user_info.mojom.h"
#include "ash/wallpaper/wallpaper_controller_observer.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
...@@ -27,7 +26,6 @@ namespace ash { ...@@ -27,7 +26,6 @@ namespace ash {
class LoginPasswordView; class LoginPasswordView;
class LoginPinView; class LoginPinView;
class WallpaperController;
// Wraps a UserView which also has authentication available. Adds additional // Wraps a UserView which also has authentication available. Adds additional
// views below the UserView instance which show authentication UIs. // views below the UserView instance which show authentication UIs.
...@@ -36,8 +34,7 @@ class WallpaperController; ...@@ -36,8 +34,7 @@ class WallpaperController;
// receive some events about the results of those mojo // receive some events about the results of those mojo
// authentication attempts (ie, success/failure). // authentication attempts (ie, success/failure).
class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
public views::ButtonListener, public views::ButtonListener {
public WallpaperControllerObserver {
public: public:
// TestApi is used for tests to get internal implementation details. // TestApi is used for tests to get internal implementation details.
class ASH_EXPORT TestApi { class ASH_EXPORT TestApi {
...@@ -134,9 +131,6 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -134,9 +131,6 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// WallpaperControllerObserver:
void OnWallpaperBlurChanged() override;
private: private:
struct AnimationState; struct AnimationState;
class FingerprintView; class FingerprintView;
...@@ -187,8 +181,6 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView, ...@@ -187,8 +181,6 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView,
// |ApplyAnimationPostLayout|. // |ApplyAnimationPostLayout|.
std::unique_ptr<AnimationState> cached_animation_state_; std::unique_ptr<AnimationState> cached_animation_state_;
ScopedObserver<WallpaperController, LoginAuthUserView> observer_{this};
base::WeakPtrFactory<LoginAuthUserView> weak_factory_{this}; base::WeakPtrFactory<LoginAuthUserView> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(LoginAuthUserView); DISALLOW_COPY_AND_ASSIGN(LoginAuthUserView);
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/login/ui/login_big_user_view.h" #include "ash/login/ui/login_big_user_view.h"
#include "ash/public/cpp/login_constants.h"
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ui/views/background.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
namespace ash { namespace ash {
...@@ -29,6 +33,11 @@ LoginBigUserView::LoginBigUserView( ...@@ -29,6 +33,11 @@ LoginBigUserView::LoginBigUserView(
public_account_callbacks_(public_account_callbacks) { public_account_callbacks_(public_account_callbacks) {
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
CreateChildView(user); CreateChildView(user);
observer_.Add(Shell::Get()->wallpaper_controller());
// Adding the observer will not run OnWallpaperBlurChanged; run it now to set
// the initial state.
OnWallpaperBlurChanged();
} }
LoginBigUserView::~LoginBigUserView() = default; LoginBigUserView::~LoginBigUserView() = default;
...@@ -82,6 +91,21 @@ void LoginBigUserView::RequestFocus() { ...@@ -82,6 +91,21 @@ void LoginBigUserView::RequestFocus() {
return auth_user_->RequestFocus(); return auth_user_->RequestFocus();
} }
void LoginBigUserView::OnWallpaperBlurChanged() {
if (Shell::Get()->wallpaper_controller()->IsWallpaperBlurred()) {
SetPaintToLayer(ui::LayerType::LAYER_NOT_DRAWN);
SetBackground(nullptr);
} else {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetBackground(views::CreateBackgroundFromPainter(
views::Painter::CreateSolidRoundRectPainter(
SkColorSetA(login_constants::kDefaultBaseColor,
login_constants::kNonBlurredWallpaperBackgroundAlpha),
login_constants::kNonBlurredWallpaperBackgroundRadiusDp)));
}
}
void LoginBigUserView::CreateAuthUser(const mojom::LoginUserInfoPtr& user) { void LoginBigUserView::CreateAuthUser(const mojom::LoginUserInfoPtr& user) {
DCHECK(!IsPublicAccountUser(user)); DCHECK(!IsPublicAccountUser(user));
DCHECK(!auth_user_); DCHECK(!auth_user_);
......
...@@ -11,14 +11,18 @@ ...@@ -11,14 +11,18 @@
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/public/interfaces/user_info.mojom.h" #include "ash/public/interfaces/user_info.mojom.h"
#include "ash/wallpaper/wallpaper_controller_observer.h"
namespace ash { namespace ash {
class WallpaperController;
// Displays the big user view in the login screen. This is a container view // Displays the big user view in the login screen. This is a container view
// which has one of the following views as its only child: // which has one of the following views as its only child:
// - LoginAuthUserView: for regular user. // - LoginAuthUserView: for regular user.
// - LoginPublicAccountUserView: for public account user. // - LoginPublicAccountUserView: for public account user.
class ASH_EXPORT LoginBigUserView : public NonAccessibleView { class ASH_EXPORT LoginBigUserView : public NonAccessibleView,
public WallpaperControllerObserver {
public: public:
LoginBigUserView( LoginBigUserView(
const mojom::LoginUserInfoPtr& user, const mojom::LoginUserInfoPtr& user,
...@@ -43,6 +47,9 @@ class ASH_EXPORT LoginBigUserView : public NonAccessibleView { ...@@ -43,6 +47,9 @@ class ASH_EXPORT LoginBigUserView : public NonAccessibleView {
// views::View: // views::View:
void RequestFocus() override; void RequestFocus() override;
// WallpaperControllerObserver:
void OnWallpaperBlurChanged() override;
private: private:
// Create LoginAuthUserView and add it as child view. // Create LoginAuthUserView and add it as child view.
// |public_account_| will be deleted if exists to ensure the single child. // |public_account_| will be deleted if exists to ensure the single child.
...@@ -59,6 +66,8 @@ class ASH_EXPORT LoginBigUserView : public NonAccessibleView { ...@@ -59,6 +66,8 @@ class ASH_EXPORT LoginBigUserView : public NonAccessibleView {
LoginAuthUserView::Callbacks auth_user_callbacks_; LoginAuthUserView::Callbacks auth_user_callbacks_;
LoginPublicAccountUserView::Callbacks public_account_callbacks_; LoginPublicAccountUserView::Callbacks public_account_callbacks_;
ScopedObserver<WallpaperController, LoginBigUserView> observer_{this};
DISALLOW_COPY_AND_ASSIGN(LoginBigUserView); DISALLOW_COPY_AND_ASSIGN(LoginBigUserView);
}; };
......
...@@ -141,7 +141,7 @@ class SelectionButtonView : public LoginButton { ...@@ -141,7 +141,7 @@ class SelectionButtonView : public LoginButton {
~SelectionButtonView() override = default; ~SelectionButtonView() override = default;
// Return the preferred height of this view. This overrides the default // Return the preferred height of this view. This overrides the default
// behavior in FillLayout::GetPreferredHeightForWidth which caluculates the // behavior in FillLayout::GetPreferredHeightForWidth which calculates the
// height based on its child height. // height based on its child height.
int GetHeightForWidth(int w) const override { int GetHeightForWidth(int w) const override {
return GetPreferredSize().height(); return GetPreferredSize().height();
......
...@@ -19,7 +19,7 @@ class LoginUserView; ...@@ -19,7 +19,7 @@ class LoginUserView;
class RightPaneView; class RightPaneView;
class PublicAccountWarningDialog; class PublicAccountWarningDialog;
// Implements an expanded view for the public acount user to select language // Implements an expanded view for the public account user to select language
// and keyboard options. // and keyboard options.
class ASH_EXPORT LoginExpandedPublicAccountView : public NonAccessibleView { class ASH_EXPORT LoginExpandedPublicAccountView : public NonAccessibleView {
public: public:
......
...@@ -103,8 +103,7 @@ std::pair<int, int> GetTargetColorAlphaValues( ...@@ -103,8 +103,7 @@ std::pair<int, int> GetTargetColorAlphaValues(
case SHELF_BACKGROUND_LOGIN_NONBLURRED_WALLPAPER: case SHELF_BACKGROUND_LOGIN_NONBLURRED_WALLPAPER:
target_shelf_color_alpha = target_shelf_color_alpha =
login_constants::kNonBlurredWallpaperBackgroundAlpha; login_constants::kNonBlurredWallpaperBackgroundAlpha;
target_item_color_alpha = target_item_color_alpha = SK_AlphaTRANSPARENT;
login_constants::kNonBlurredWallpaperBackgroundAlpha;
break; break;
} }
return std::pair<int, int>(target_shelf_color_alpha, target_item_color_alpha); return std::pair<int, int>(target_shelf_color_alpha, target_item_color_alpha);
......
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