Skip to content

Commit 902f23d

Browse files
jacobdufault-googleJacob Dufault
authored and
Jacob Dufault
committed
cros: Accessibility fixes for removing users on views-login
- Fix the label for the remove user button so it reads "Remove user" - After hitting remove user read the warning message - Increase the contrast for the remove user button. [email protected] (cherry picked from commit 7984efe) Bug: 787489 Change-Id: I2003aaa0b63cda33e1a23ceb4b4d2bd55fbd531f Reviewed-on: https://chromium-review.googlesource.com/c/1278140 Commit-Queue: Jacob Dufault <[email protected]> Reviewed-by: Michael Wasserman <[email protected]> Reviewed-by: Wenzhao (Colin) Zang <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#599403} Reviewed-on: https://chromium-review.googlesource.com/c/1284061 Reviewed-by: Jacob Dufault <[email protected]> Cr-Commit-Position: refs/branch-heads/3578@{#50} Cr-Branched-From: 4226ddf-refs/heads/master@{#599034}
1 parent dd1dbd9 commit 902f23d

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

ash/login/ui/login_bubble.cc

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ constexpr int kAlertIconSizeDp = 20;
5353
constexpr SkAlpha kSubMessageColorAlpha = 0x89;
5454

5555
// Color of the "Remove user" text.
56-
constexpr SkColor kRemoveUserInitialColor = SkColorSetRGB(0x7B, 0xAA, 0xF7);
57-
constexpr SkColor kRemoveUserConfirmColor = SkColorSetRGB(0xE6, 0x7C, 0x73);
56+
constexpr SkColor kRemoveUserInitialColor = gfx::kGoogleBlueDark400;
57+
constexpr SkColor kRemoveUserConfirmColor = gfx::kGoogleRedDark500;
5858

5959
// Margin/inset of the entries for the user menu.
6060
constexpr int kUserMenuMarginWidth = 14;
@@ -155,6 +155,24 @@ class ButtonWithContent : public views::Button {
155155
DISALLOW_COPY_AND_ASSIGN(ButtonWithContent);
156156
};
157157

158+
// A view that has a customizable accessible name.
159+
class ViewWithAccessibleName : public views::View {
160+
public:
161+
ViewWithAccessibleName(const base::string16& accessible_name)
162+
: accessible_name_(accessible_name) {}
163+
~ViewWithAccessibleName() override = default;
164+
165+
// views::View:
166+
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
167+
node_data->role = ax::mojom::Role::kStaticText;
168+
node_data->SetName(accessible_name_);
169+
}
170+
171+
private:
172+
const base::string16 accessible_name_;
173+
DISALLOW_COPY_AND_ASSIGN(ViewWithAccessibleName);
174+
};
175+
158176
class LoginUserMenuView : public LoginBaseBubbleView,
159177
public views::ButtonListener {
160178
public:
@@ -187,8 +205,7 @@ class LoginUserMenuView : public LoginBaseBubbleView,
187205
kUserMenuMarginHeight, kUserMenuMarginWidth,
188206
kUserMenuMarginHeight - kUserMenuMarginAroundRemoveUserButtonDp,
189207
kUserMenuMarginWidth);
190-
auto create_and_add_horizontal_margin_container = [&]() {
191-
auto* container = new NonAccessibleView("MarginContainer");
208+
auto setup_horizontal_margin_container = [&](views::View* container) {
192209
container->SetLayoutManager(std::make_unique<views::BoxLayout>(
193210
views::BoxLayout::kVertical,
194211
gfx::Insets(0, margins.left(), 0, margins.right())));
@@ -214,7 +231,8 @@ class LoginUserMenuView : public LoginBaseBubbleView,
214231
username)
215232
: username;
216233

217-
views::View* container = create_and_add_horizontal_margin_container();
234+
views::View* container = setup_horizontal_margin_container(
235+
new NonAccessibleView("UsernameLabel MarginContainer"));
218236
username_label_ = CreateLabel(display_username, SK_ColorWHITE);
219237
// Do not change these two lines. Without them, the remove user button
220238
// will be pushed out of the box when the user has a long name.
@@ -251,15 +269,19 @@ class LoginUserMenuView : public LoginBaseBubbleView,
251269
return label;
252270
};
253271

254-
remove_user_confirm_data_ = create_and_add_horizontal_margin_container();
255-
remove_user_confirm_data_->SetVisible(false);
256272
base::string16 part1 = l10n_util::GetStringUTF16(
257273
IDS_ASH_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING_PART_1);
258274
if (type == user_manager::UserType::USER_TYPE_SUPERVISED) {
259275
part1 = l10n_util::GetStringFUTF16(
260276
IDS_ASH_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
261277
base::UTF8ToUTF16(ash::kLegacySupervisedUserManagementDisplayURL));
262278
}
279+
base::string16 part2 = l10n_util::GetStringFUTF16(
280+
IDS_ASH_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING_PART_2, email);
281+
282+
remove_user_confirm_data_ = setup_horizontal_margin_container(
283+
new ViewWithAccessibleName(part1 + base::ASCIIToUTF16(" ") + part2));
284+
remove_user_confirm_data_->SetVisible(false);
263285

264286
// Account for margin that was removed below the separator for the add
265287
// user button.
@@ -268,15 +290,14 @@ class LoginUserMenuView : public LoginBaseBubbleView,
268290
remove_user_confirm_data_->AddChildView(make_label(part1));
269291
add_space(remove_user_confirm_data_,
270292
kUserMenuVerticalDistanceBetweenLabelsDp);
271-
remove_user_confirm_data_->AddChildView(
272-
make_label(l10n_util::GetStringFUTF16(
273-
IDS_ASH_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING_PART_2, email)));
293+
remove_user_confirm_data_->AddChildView(make_label(part2));
274294
// Reduce margin since the remove user button comes next.
275295
add_space(remove_user_confirm_data_,
276296
kUserMenuVerticalDistanceBetweenLabelsDp -
277297
kUserMenuMarginAroundRemoveUserButtonDp);
278298

279-
auto* container = create_and_add_horizontal_margin_container();
299+
auto* container = setup_horizontal_margin_container(
300+
new NonAccessibleView("RemoveUserButton MarginContainer"));
280301
remove_user_label_ =
281302
CreateLabel(l10n_util::GetStringUTF16(
282303
IDS_ASH_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME),
@@ -285,6 +306,7 @@ class LoginUserMenuView : public LoginBaseBubbleView,
285306
remove_user_button_->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
286307
remove_user_button_->set_id(
287308
LoginBubble::kUserMenuRemoveUserButtonIdForTest);
309+
remove_user_button_->SetAccessibleName(remove_user_label_->text());
288310
container->AddChildView(remove_user_button_);
289311
}
290312

@@ -326,6 +348,14 @@ class LoginUserMenuView : public LoginBaseBubbleView,
326348
SetSize(GetPreferredSize());
327349
SizeToContents();
328350
Layout();
351+
352+
// Fire an accessibility alert to make ChromeVox read the warning message
353+
// and remove button.
354+
remove_user_confirm_data_->NotifyAccessibilityEvent(
355+
ax::mojom::Event::kAlert, true /*send_native_event*/);
356+
remove_user_button_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
357+
true /*send_native_event*/);
358+
329359
if (on_remove_user_warning_shown_)
330360
std::move(on_remove_user_warning_shown_).Run();
331361
return;
@@ -568,7 +598,8 @@ void LoginBubble::Show() {
568598
ScheduleAnimation(true /*visible*/);
569599

570600
// Fire an alert so ChromeVox will read the contents of the bubble.
571-
bubble_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
601+
bubble_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
602+
true /*send_native_event*/);
572603
}
573604

574605
void LoginBubble::ProcessPressedEvent(const ui::LocatedEvent* event) {

ui/gfx/color_palette.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ constexpr SkColor kGoogleBlue500 = SkColorSetRGB(0x42, 0x85, 0xF4);
2020
constexpr SkColor kGoogleBlue600 = SkColorSetRGB(0x1A, 0x73, 0xE8);
2121
constexpr SkColor kGoogleBlue700 = SkColorSetRGB(0x19, 0x67, 0xD2);
2222
constexpr SkColor kGoogleBlue900 = SkColorSetRGB(0x17, 0x4E, 0xA6);
23+
constexpr SkColor kGoogleBlueDark400 = SkColorSetRGB(0x6B, 0xA5, 0xED);
2324
constexpr SkColor kGoogleBlueDark600 = SkColorSetRGB(0x25, 0x81, 0xDF);
2425
constexpr SkColor kGoogleRed300 = SkColorSetRGB(0xF2, 0x8B, 0xB2);
2526
constexpr SkColor kGoogleRed500 = SkColorSetRGB(0xEA, 0x43, 0x35);
2627
constexpr SkColor kGoogleRed600 = SkColorSetRGB(0xD9, 0x30, 0x25);
2728
constexpr SkColor kGoogleRed700 = SkColorSetRGB(0xC5, 0x22, 0x1F);
2829
constexpr SkColor kGoogleRed800 = SkColorSetRGB(0xB3, 0x14, 0x12);
30+
constexpr SkColor kGoogleRedDark500 = SkColorSetRGB(0xE6, 0x6A, 0x5E);
2931
constexpr SkColor kGoogleRedDark600 = SkColorSetRGB(0xD3, 0x3B, 0x30);
3032
constexpr SkColor kGoogleRedDark800 = SkColorSetRGB(0xB4, 0x1B, 0x1A);
3133
constexpr SkColor kGoogleGreen300 = SkColorSetRGB(0x81, 0xC9, 0x95);

0 commit comments

Comments
 (0)