@@ -53,8 +53,8 @@ constexpr int kAlertIconSizeDp = 20;
53
53
constexpr SkAlpha kSubMessageColorAlpha = 0x89 ;
54
54
55
55
// 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 ;
58
58
59
59
// Margin/inset of the entries for the user menu.
60
60
constexpr int kUserMenuMarginWidth = 14 ;
@@ -155,6 +155,24 @@ class ButtonWithContent : public views::Button {
155
155
DISALLOW_COPY_AND_ASSIGN (ButtonWithContent);
156
156
};
157
157
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
+
158
176
class LoginUserMenuView : public LoginBaseBubbleView ,
159
177
public views::ButtonListener {
160
178
public:
@@ -187,8 +205,7 @@ class LoginUserMenuView : public LoginBaseBubbleView,
187
205
kUserMenuMarginHeight , kUserMenuMarginWidth ,
188
206
kUserMenuMarginHeight - kUserMenuMarginAroundRemoveUserButtonDp ,
189
207
kUserMenuMarginWidth );
190
- auto create_and_add_horizontal_margin_container = [&]() {
191
- auto * container = new NonAccessibleView (" MarginContainer" );
208
+ auto setup_horizontal_margin_container = [&](views::View* container) {
192
209
container->SetLayoutManager (std::make_unique<views::BoxLayout>(
193
210
views::BoxLayout::kVertical ,
194
211
gfx::Insets (0 , margins.left (), 0 , margins.right ())));
@@ -214,7 +231,8 @@ class LoginUserMenuView : public LoginBaseBubbleView,
214
231
username)
215
232
: username;
216
233
217
- views::View* container = create_and_add_horizontal_margin_container ();
234
+ views::View* container = setup_horizontal_margin_container (
235
+ new NonAccessibleView (" UsernameLabel MarginContainer" ));
218
236
username_label_ = CreateLabel (display_username, SK_ColorWHITE);
219
237
// Do not change these two lines. Without them, the remove user button
220
238
// will be pushed out of the box when the user has a long name.
@@ -251,15 +269,19 @@ class LoginUserMenuView : public LoginBaseBubbleView,
251
269
return label;
252
270
};
253
271
254
- remove_user_confirm_data_ = create_and_add_horizontal_margin_container ();
255
- remove_user_confirm_data_->SetVisible (false );
256
272
base::string16 part1 = l10n_util::GetStringUTF16 (
257
273
IDS_ASH_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING_PART_1);
258
274
if (type == user_manager::UserType::USER_TYPE_SUPERVISED) {
259
275
part1 = l10n_util::GetStringFUTF16 (
260
276
IDS_ASH_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
261
277
base::UTF8ToUTF16 (ash::kLegacySupervisedUserManagementDisplayURL ));
262
278
}
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 );
263
285
264
286
// Account for margin that was removed below the separator for the add
265
287
// user button.
@@ -268,15 +290,14 @@ class LoginUserMenuView : public LoginBaseBubbleView,
268
290
remove_user_confirm_data_->AddChildView (make_label (part1));
269
291
add_space (remove_user_confirm_data_,
270
292
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));
274
294
// Reduce margin since the remove user button comes next.
275
295
add_space (remove_user_confirm_data_,
276
296
kUserMenuVerticalDistanceBetweenLabelsDp -
277
297
kUserMenuMarginAroundRemoveUserButtonDp );
278
298
279
- auto * container = create_and_add_horizontal_margin_container ();
299
+ auto * container = setup_horizontal_margin_container (
300
+ new NonAccessibleView (" RemoveUserButton MarginContainer" ));
280
301
remove_user_label_ =
281
302
CreateLabel (l10n_util::GetStringUTF16 (
282
303
IDS_ASH_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME),
@@ -285,6 +306,7 @@ class LoginUserMenuView : public LoginBaseBubbleView,
285
306
remove_user_button_->SetFocusBehavior (views::View::FocusBehavior::ALWAYS);
286
307
remove_user_button_->set_id (
287
308
LoginBubble::kUserMenuRemoveUserButtonIdForTest );
309
+ remove_user_button_->SetAccessibleName (remove_user_label_->text ());
288
310
container->AddChildView (remove_user_button_);
289
311
}
290
312
@@ -326,6 +348,14 @@ class LoginUserMenuView : public LoginBaseBubbleView,
326
348
SetSize (GetPreferredSize ());
327
349
SizeToContents ();
328
350
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
+
329
359
if (on_remove_user_warning_shown_)
330
360
std::move (on_remove_user_warning_shown_).Run ();
331
361
return ;
@@ -568,7 +598,8 @@ void LoginBubble::Show() {
568
598
ScheduleAnimation (true /* visible*/ );
569
599
570
600
// 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*/ );
572
603
}
573
604
574
605
void LoginBubble::ProcessPressedEvent (const ui::LocatedEvent* event) {
0 commit comments