Commit 5d13c2e9 authored by Melissa Zhang's avatar Melissa Zhang Committed by Commit Bot

[Sharesheet] Add ActivityName to AccessibleName.

Add ActivityName to AccessibleName for screenreaders.

Bug: 1131296
Change-Id: I5f01a14f8113cd00cfb3bda526da5975f7ceeb5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440226Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Melissa Zhang <melzhang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812550}
parent d6010a57
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/ui/views/sharesheet/sharesheet_target_button.h" #include "chrome/browser/ui/views/sharesheet/sharesheet_target_button.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
...@@ -64,6 +66,7 @@ SharesheetTargetButton::SharesheetTargetButton( ...@@ -64,6 +66,7 @@ SharesheetTargetButton::SharesheetTargetButton(
label->SetEnabledColor(kShareTargetTitleColor); label->SetEnabledColor(kShareTargetTitleColor);
SetLabelProperties(label); SetLabelProperties(label);
base::string16 accessible_name = display_name;
if (secondary_display_name != base::string16() && if (secondary_display_name != base::string16() &&
secondary_display_name != display_name) { secondary_display_name != display_name) {
auto* secondary_label = label_view->AddChildView( auto* secondary_label = label_view->AddChildView(
...@@ -71,6 +74,8 @@ SharesheetTargetButton::SharesheetTargetButton( ...@@ -71,6 +74,8 @@ SharesheetTargetButton::SharesheetTargetButton(
secondary_label->SetFontList(gfx::FontList(kButtonSecondaryLabelFont)); secondary_label->SetFontList(gfx::FontList(kButtonSecondaryLabelFont));
secondary_label->SetEnabledColor(kShareTargetSecondaryTitleColor); secondary_label->SetEnabledColor(kShareTargetSecondaryTitleColor);
SetLabelProperties(secondary_label); SetLabelProperties(secondary_label);
accessible_name = base::StrCat(
{display_name, base::ASCIIToUTF16(" "), secondary_display_name});
} else { } else {
// If there is no secondary label, let the initial label stretch across // If there is no secondary label, let the initial label stretch across
// multiple lines. // multiple lines.
...@@ -79,7 +84,7 @@ SharesheetTargetButton::SharesheetTargetButton( ...@@ -79,7 +84,7 @@ SharesheetTargetButton::SharesheetTargetButton(
} }
AddChildView(std::move(label_view)); AddChildView(std::move(label_view));
SetAccessibleName(display_name); SetAccessibleName(accessible_name);
SetFocusForPlatform(); SetFocusForPlatform();
} }
......
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