Commit 204e5eb7 authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

Update parent access code view background color

Using extracted color occasionally causes a11y problems: contrast
between background and text is not sufficient (especially error view).
New background color is a combination of extracted dark muted color
and black. When in session blur is applied.

Bug: 999390
Change-Id: Id805a359d76acb9e09ae1c0ad2c392de0d16523c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930107Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718262}
parent f175c439
......@@ -19,6 +19,7 @@
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/wallpaper/wallpaper_controller_impl.h"
#include "base/bind.h"
#include "base/logging.h"
......@@ -39,6 +40,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_analysis.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/size.h"
......@@ -91,8 +93,11 @@ constexpr int kAccessCodeBetweenInputFieldsGapDp = 4;
constexpr int kArrowButtonSizeDp = 40;
constexpr int kArrowSizeDp = 20;
constexpr int kAlpha70Percent = 178;
constexpr int kAlpha74Percent = 189;
constexpr SkColor kTextColor = SK_ColorWHITE;
constexpr SkColor kErrorColor = SkColorSetARGB(0xFF, 0xF2, 0x8B, 0x82);
constexpr SkColor kErrorColor = gfx::kGoogleRed300;
constexpr SkColor kArrowButtonColor = SkColorSetARGB(0x2B, 0xFF, 0xFF, 0xFF);
bool IsTabletMode() {
......@@ -110,6 +115,28 @@ gfx::Size GetParentAccessViewSize() {
: kParentAccessViewHeightDp);
}
// Returns background color for parent access dialog. |using_blur| should be
// true if the dialog is using background blur (color transparency depends on
// it).
SkColor GetBackgroundColor(bool using_blur) {
SkColor color = AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kOpaque,
AshColorProvider::AshColorMode::kDark);
SkColor extracted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor(
color_utils::ColorProfile(color_utils::LumaRange::DARK,
color_utils::SaturationRange::MUTED));
if (extracted_color != kInvalidWallpaperColor &&
extracted_color != SK_ColorTRANSPARENT) {
color = color_utils::GetResultingPaintColor(
SkColorSetA(SK_ColorBLACK, kAlpha70Percent), extracted_color);
}
return using_blur ? SkColorSetA(color, kAlpha74Percent) : color;
}
base::string16 GetTitle(ParentAccessRequestReason reason) {
int title_id;
switch (reason) {
......@@ -555,7 +582,9 @@ ParentAccessView::ParentAccessView(const AccountId& account_id,
: callbacks_(callbacks),
account_id_(account_id),
request_reason_(reason),
validation_time_(validation_time) {
validation_time_(validation_time),
blur_background_(Shell::Get()->session_controller()->GetSessionState() ==
session_manager::SessionState::ACTIVE) {
DCHECK(callbacks.on_finished);
// Main view contains all other views aligned vertically and centered.
auto layout = std::make_unique<views::BoxLayout>(
......@@ -571,6 +600,10 @@ ParentAccessView::ParentAccessView(const AccountId& account_id,
SetPreferredSize(GetParentAccessViewSize());
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
layer()->SetRoundedCornerRadius(
gfx::RoundedCornersF(kParentAccessViewRoundedCornerRadiusDp));
if (blur_background_)
layer()->SetBackgroundBlur(ShelfConfig::Get()->shelf_blur_radius());
const int child_view_width =
kParentAccessViewWidthDp - 2 * kParentAccessViewHorizontalInsetDp;
......@@ -727,22 +760,9 @@ ParentAccessView::~ParentAccessView() = default;
void ParentAccessView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
SkColor color = gfx::kGoogleGrey900;
if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::ACTIVE) {
SkColor extracted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor(
color_utils::ColorProfile(color_utils::LumaRange::NORMAL,
color_utils::SaturationRange::MUTED));
if (extracted_color != kInvalidWallpaperColor &&
extracted_color != SK_ColorTRANSPARENT) {
color = extracted_color;
}
}
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(color);
flags.setColor(GetBackgroundColor(blur_background_));
canvas->DrawRoundRect(GetContentsBounds(),
kParentAccessViewRoundedCornerRadiusDp, flags);
}
......
......@@ -187,6 +187,9 @@ class ASH_EXPORT ParentAccessView : public views::DialogDelegateView,
// Auto submit code when the last input has been inserted.
bool auto_submit_enabled_ = true;
// Whether view background should be blurred.
bool blur_background_ = false;
views::Label* title_label_ = nullptr;
views::Label* description_label_ = nullptr;
AccessCodeInput* access_code_view_ = nullptr;
......
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