@@ -53,8 +53,8 @@ constexpr int kAlertIconSizeDp = 20;
5353constexpr 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.
6060constexpr 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+
158176class 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
574605void LoginBubble::ProcessPressedEvent (const ui::LocatedEvent* event) {
0 commit comments