Commit 21a06d72 authored by Abhijeet Singh's avatar Abhijeet Singh Committed by Commit Bot

Add accessibility for Quick-Answers UserConsentView

Announce the user-consent notice for Quick Answers when screen-reader is
enabled. The accessibility name for the view is composed of all of its
text content concatenated, by default. The accessible name and
description are overridden for the view, and the announcement is made
when the user-consent view is displayed.

Bug: b:152059023
Test: Tested on Chrome OS Atlas test device.
Change-Id: I222b139263ea748293112c26df37c226b0e43634
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2222126
Commit-Queue: Abhijeet Singh <siabhijeet@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773968}
parent 2c999662
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/events/event_handler.h" #include "ui/events/event_handler.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -71,6 +72,10 @@ constexpr int kDogfoodButtonMarginDip = 4; ...@@ -71,6 +72,10 @@ constexpr int kDogfoodButtonMarginDip = 4;
constexpr int kDogfoodButtonSizeDip = 20; constexpr int kDogfoodButtonSizeDip = 20;
constexpr SkColor kDogfoodButtonColor = gfx::kGoogleGrey500; constexpr SkColor kDogfoodButtonColor = gfx::kGoogleGrey500;
// Accessibility.
// TODO(siabhijeet): Move to grd after finalizing with UX.
constexpr char kA11yInfoNameTemplate[] = "New feature: %s";
// Create and return a simple label with provided specs. // Create and return a simple label with provided specs.
std::unique_ptr<views::Label> CreateLabel(const base::string16& text, std::unique_ptr<views::Label> CreateLabel(const base::string16& text,
const SkColor color, const SkColor color,
...@@ -126,6 +131,17 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds, ...@@ -126,6 +131,17 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds,
GetWidget()->SetNativeWindowProperty( GetWidget()->SetNativeWindowProperty(
views::TooltipManager::kGroupingPropertyKey, views::TooltipManager::kGroupingPropertyKey,
reinterpret_cast<void*>(views::MenuConfig::kMenuControllerGroupingId)); reinterpret_cast<void*>(views::MenuConfig::kMenuControllerGroupingId));
// Read out user-consent notice if screen-reader is active.
GetViewAccessibility().OverrideRole(ax::mojom::Role::kAlert);
GetViewAccessibility().OverrideName(
base::StringPrintf(kA11yInfoNameTemplate,
l10n_util::GetStringUTF8(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT)
.c_str()));
GetViewAccessibility().OverrideDescription(l10n_util::GetStringUTF8(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_DESC_TEXT));
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
} }
UserConsentView::~UserConsentView() = default; UserConsentView::~UserConsentView() = default;
......
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