Commit c8fe3f19 authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

[Full extensions] Make invalid password error accessible

Bug: 1062074
Change-Id: I82b8b2f01fbb319e8a7008c13b0b932ebc214564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128375
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755148}
parent c9f32ab3
...@@ -59,6 +59,29 @@ ...@@ -59,6 +59,29 @@
namespace { namespace {
constexpr int kSectionPaddingTop = 20; constexpr int kSectionPaddingTop = 20;
// Label that may contain empty text.
// Override is needed to configure accessibility node for an empty name.
class MaybeEmptyLabel : public views::Label {
public:
explicit MaybeEmptyLabel(const std::string& text)
: views::Label(base::UTF8ToUTF16(text),
CONTEXT_BODY_TEXT_LARGE,
views::style::STYLE_SECONDARY) {}
MaybeEmptyLabel& operator=(const MaybeEmptyLabel&) = delete;
MaybeEmptyLabel(const MaybeEmptyLabel&) = delete;
~MaybeEmptyLabel() override = default;
// views::Label:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
views::Label::GetAccessibleNodeData(node_data);
if (!GetText().empty())
node_data->SetName(GetText());
else
node_data->SetNameExplicitlyEmpty();
}
};
// Returns bitmap for the default icon with size equal to the default icon's // Returns bitmap for the default icon with size equal to the default icon's
// pixel size under maximal supported scale factor. // pixel size under maximal supported scale factor.
const gfx::ImageSkia& GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { const gfx::ImageSkia& GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
...@@ -435,9 +458,7 @@ void ParentPermissionDialogView::CreateContents() { ...@@ -435,9 +458,7 @@ void ParentPermissionDialogView::CreateContents() {
// Add the invalid credential label, which is initially empty, // Add the invalid credential label, which is initially empty,
// and hence invisible. It will be updated if the user enters // and hence invisible. It will be updated if the user enters
// an incorrect password. // an incorrect password.
auto invalid_credential_label = std::make_unique<views::Label>( auto invalid_credential_label = std::make_unique<MaybeEmptyLabel>("");
base::UTF8ToUTF16(""), CONTEXT_BODY_TEXT_LARGE,
views::style::STYLE_SECONDARY);
invalid_credential_label->SetBorder(views::CreateEmptyBorder( invalid_credential_label->SetBorder(views::CreateEmptyBorder(
0, content_insets.left(), 0, content_insets.right())); 0, content_insets.left(), 0, content_insets.right()));
invalid_credential_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); invalid_credential_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
...@@ -651,6 +672,8 @@ void ParentPermissionDialogView::OnReAuthProofTokenFailure( ...@@ -651,6 +672,8 @@ void ParentPermissionDialogView::OnReAuthProofTokenFailure(
SetEnabled(true); SetEnabled(true);
invalid_credential_label_->SetText(l10n_util::GetStringUTF16( invalid_credential_label_->SetText(l10n_util::GetStringUTF16(
IDS_PARENT_PERMISSION_PROMPT_PASSWORD_INCORRECT_LABEL)); IDS_PARENT_PERMISSION_PROMPT_PASSWORD_INCORRECT_LABEL));
invalid_credential_label_->NotifyAccessibilityEvent(
ax::mojom::Event::kAlert, true);
return; return;
} }
} }
......
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