Commit 2508937a authored by Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez Committed by Chromium LUCI CQ

Accounts & sync: include title/subtitle in accessible name.

The dialog has the accessible name "accounts and sync". It also has a
visible title and subtitle which indicate the user account name and
email or login status.

Making these title/subtitle part of the accessible name, we expect them
to be properly announced when the dialog is open, in particular, on Mac
OS X where previous workarounds did not work.

We partially undo the previous workaround, with a specific provision
for crbug.com/1161166. Still, some double-speech happens due to the
existing crbug.com/1161135.

Behavior on Mac:

* Reads "accounts and sync" plus title and subtitle twice due to
  crbug.com/1161135.

Behavior on Linux:

* Reads "accounts and sync" plus title and subtitle once thanks to a
  workaround for crbug.com/1161166.

Behavior on Windows, NVDA:

* Reads "accounts and sync" plus title and subtitle once.

Behavior on Windows, JAWS:

* Reads "accounts and sync" plus title and subtitle once when open,
  then twice when tabbing into the dialog due to crbug.com/1161135.

Bug: 1078580, 1161166
Change-Id: I483645ea482ef5101d8f9515027ea3129f46aad6
AX-relnotes: Mac, accounts & sync: announce dialog title and subtitle.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600976
Commit-Queue: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839090}
parent 28e64f1f
......@@ -61,6 +61,7 @@
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/native_theme/native_theme.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
namespace {
......@@ -255,8 +256,18 @@ gfx::ImageSkia ProfileMenuView::GetSyncIcon() const {
}
base::string16 ProfileMenuView::GetAccessibleWindowTitle() const {
return l10n_util::GetStringUTF16(
IDS_PROFILES_PROFILE_BUBBLE_ACCESSIBLE_TITLE);
base::string16 title =
l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_BUBBLE_ACCESSIBLE_TITLE);
if (!menu_title_.empty()) {
title = l10n_util::GetStringFUTF16(IDS_CONCAT_TWO_STRINGS_WITH_COMMA, title,
menu_title_);
}
if (!menu_subtitle_.empty()) {
title = l10n_util::GetStringFUTF16(IDS_CONCAT_TWO_STRINGS_WITH_COMMA, title,
menu_subtitle_);
}
return title;
}
void ProfileMenuView::OnManageGoogleAccountButtonClicked() {
......@@ -492,31 +503,36 @@ void ProfileMenuView::BuildIdentity() {
SkColor background_color =
profile_attributes->GetProfileThemeColors().profile_highlight_color;
if (account_info.has_value()) {
menu_title_ = base::UTF8ToUTF16(account_info.value().full_name);
menu_subtitle_ =
IsSyncPaused(profile)
? l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE)
: base::UTF8ToUTF16(account_info.value().email);
SetProfileIdentityInfo(
profile_name, background_color, edit_button_params,
ui::ImageModel::FromImage(account_info.value().account_image),
base::UTF8ToUTF16(account_info.value().full_name),
IsSyncPaused(profile)
? l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE)
: base::UTF8ToUTF16(account_info.value().email));
menu_title_, menu_subtitle_);
} else {
menu_title_ = base::string16();
menu_subtitle_ =
l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE);
SetProfileIdentityInfo(
profile_name, background_color, edit_button_params,
ui::ImageModel::FromImage(
profile_attributes->GetAvatarIcon(kIdentityImageSize)),
/*title=*/base::string16(),
l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE));
menu_title_, menu_subtitle_);
}
}
void ProfileMenuView::BuildGuestIdentity() {
int guest_window_count = BrowserList::GetGuestBrowserCount();
base::string16 subtitle;
menu_title_ = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
menu_subtitle_ = base::string16();
if (guest_window_count > 1 &&
base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
subtitle = l10n_util::GetPluralStringFUTF16(IDS_GUEST_WINDOW_COUNT_MESSAGE,
guest_window_count);
menu_subtitle_ = l10n_util::GetPluralStringFUTF16(
IDS_GUEST_WINDOW_COUNT_MESSAGE, guest_window_count);
}
ui::ThemedVectorIcon header_art_icon(
......@@ -524,9 +540,8 @@ void ProfileMenuView::BuildGuestIdentity() {
SetProfileIdentityInfo(
/*profile_name=*/base::string16(),
/*background_color=*/SK_ColorTRANSPARENT,
/*edit_button=*/base::nullopt, profiles::GetGuestAvatar(),
l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), subtitle,
header_art_icon);
/*edit_button=*/base::nullopt, profiles::GetGuestAvatar(), menu_title_,
menu_subtitle_, header_art_icon);
}
void ProfileMenuView::BuildAutofillButtons() {
......
......@@ -36,6 +36,9 @@ class ProfileMenuView : public ProfileMenuViewBase {
ProfileMenuView(views::Button* anchor_button, Browser* browser);
~ProfileMenuView() override;
ProfileMenuView(const ProfileMenuView&) = delete;
ProfileMenuView& operator=(const ProfileMenuView&) = delete;
// ProfileMenuViewBase:
void BuildMenu() override;
gfx::ImageSkia GetSyncIcon() const override;
......@@ -84,7 +87,8 @@ class ProfileMenuView : public ProfileMenuViewBase {
void BuildProfileManagementFeatureButtons();
#endif
DISALLOW_COPY_AND_ASSIGN(ProfileMenuView);
base::string16 menu_title_;
base::string16 menu_subtitle_;
};
#endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_MENU_VIEW_H_
......@@ -548,23 +548,6 @@ gfx::ImageSkia ProfileMenuViewBase::GetSyncIcon() const {
return gfx::ImageSkia();
}
const base::string16 ProfileMenuViewBase::GetAccessibleMenuName(
const base::string16& title,
const base::string16& subtitle) {
if (title.empty()) {
if (subtitle.empty())
return GetAccessibleWindowTitle();
return subtitle;
} else {
if (subtitle.empty())
return title;
return l10n_util::GetStringFUTF16(IDS_CONCAT_TWO_STRINGS_WITH_COMMA, title,
subtitle);
}
}
void ProfileMenuViewBase::SetProfileIdentityInfo(
const base::string16& profile_name,
SkColor profile_background_color,
......@@ -590,9 +573,12 @@ void ProfileMenuViewBase::SetProfileIdentityInfo(
auto avatar_image_view = std::make_unique<AvatarImageView>(image_model, this);
// Use the profile identity info to label the entire menu, for accessibility
// users to get the user account as context information when they open it.
GetViewAccessibility().OverrideName(GetAccessibleMenuName(title, subtitle));
#if defined(OS_LINUX)
// crbug.com/1161166: Orca does not read the accessible window title of the
// bubble, so we duplicate it in the top-level menu item. To be revisited
// after considering other options, including fixes on the AT side.
GetViewAccessibility().OverrideName(GetAccessibleWindowTitle());
#endif
if (!new_design) {
if (!profile_name.empty()) {
......
......@@ -111,6 +111,9 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
Browser* browser);
~ProfileMenuViewBase() override;
ProfileMenuViewBase(const ProfileMenuViewBase&) = delete;
ProfileMenuViewBase& operator=(const ProfileMenuViewBase&) = delete;
// This method is called once to add all menu items.
virtual void BuildMenu() = 0;
......@@ -190,9 +193,6 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
void UpdateSyncInfoContainerBackground();
const base::string16 GetAccessibleMenuName(const base::string16& title,
const base::string16& subtitle);
Browser* const browser_;
views::Button* const anchor_button_;
......@@ -226,8 +226,6 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
base::string16 profile_mgmt_heading_;
std::unique_ptr<AXMenuWidgetObserver> ax_widget_observer_;
DISALLOW_COPY_AND_ASSIGN(ProfileMenuViewBase);
};
#endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_MENU_VIEW_BASE_H_
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