Skip to content

Commit

Permalink
[DownloadBubble] Add unique a11y name for main buttons
Browse files Browse the repository at this point in the history
Bug: 1394250
Change-Id: Ic9b9061d07fb74fee1bf68b5b731b04f24335873
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4112769
Reviewed-by: Daniel Rubery <drubery@chromium.org>
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084512}
  • Loading branch information
Xinghui Lu authored and Chromium LUCI CQ committed Dec 16, 2022
1 parent 9b1a7df commit 18466ed
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 16 deletions.
32 changes: 32 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,38 @@ are declared in tools/grit/grit_rule.gni.
Back to Recent Downloads
</message>
</if>
<message name="IDS_DOWNLOAD_BUBBLE_CANCEL_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for cancel button.">
Cancel <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_DELETE_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for delete button.">
Delete <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_KEEP_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for keep button.">
Keep <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_SCAN_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for scan button.">
Scan <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_OPEN_NOW_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for open now button.">
Open <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph> now
</message>
<message name="IDS_DOWNLOAD_BUBBLE_RESUME_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for resume button.">
Resume <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_REVIEW_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for review button.">
Review <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>
<message name="IDS_DOWNLOAD_BUBBLE_RETRY_MAIN_BUTTON_ACCESSIBILITY"
desc="Accessibility label for retry button.">
Retry <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>
</message>

<!-- Tailored Warning in Download Bubble -->
<message name="IDS_DOWNLOAD_BUBBLE_SUBPAGE_SUMMARY_COOKIE_THEFT"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85833f68866598c780af2e23bf1356beeec38be1
97 changes: 81 additions & 16 deletions chrome/browser/ui/views/download/bubble/download_bubble_row_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ void DownloadBubbleRowView::UpdateButtons() {
cancel_action_->SetVisible(false);
show_in_folder_action_->SetVisible(false);
open_when_complete_action_->SetVisible(false);

for (const auto& action : ui_info_.quick_actions) {
views::ImageButton* action_button =
GetActionButtonForCommand(action.command);
Expand All @@ -616,22 +617,21 @@ void DownloadBubbleRowView::UpdateButtons() {
action_button->SetVisible(true);
}

cancel_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::CANCEL);
discard_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::DISCARD);
keep_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::KEEP);
scan_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::DEEP_SCAN);
open_now_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::BYPASS_DEEP_SCANNING);
resume_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::RESUME);
review_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::REVIEW);
retry_button_->SetVisible(ui_info_.primary_button_command ==
DownloadCommands::RETRY);
cancel_button_->SetVisible(false);
discard_button_->SetVisible(false);
keep_button_->SetVisible(false);
scan_button_->SetVisible(false);
open_now_button_->SetVisible(false);
resume_button_->SetVisible(false);
review_button_->SetVisible(false);
retry_button_->SetVisible(false);
if (ui_info_.primary_button_command) {
views::MdTextButton* main_button =
GetMainPageButton(ui_info_.primary_button_command.value());
main_button->SetAccessibleName(GetAccessibleNameForMainPageButton(
ui_info_.primary_button_command.value()));
main_button->SetVisible(true);
}

subpage_icon_->SetVisible(ui_info_.has_subpage);
}
Expand Down Expand Up @@ -819,6 +819,71 @@ std::u16string DownloadBubbleRowView::GetAccessibleNameForQuickAction(
}
}

views::MdTextButton* DownloadBubbleRowView::GetMainPageButton(
DownloadCommands::Command command) {
switch (command) {
case DownloadCommands::CANCEL:
return cancel_button_;
case DownloadCommands::RESUME:
return resume_button_;
case DownloadCommands::DISCARD:
return discard_button_;
case DownloadCommands::KEEP:
return keep_button_;
case DownloadCommands::DEEP_SCAN:
return scan_button_;
case DownloadCommands::BYPASS_DEEP_SCANNING:
return open_now_button_;
case DownloadCommands::REVIEW:
return review_button_;
case DownloadCommands::RETRY:
return retry_button_;
default:
return nullptr;
}
}

std::u16string DownloadBubbleRowView::GetAccessibleNameForMainPageButton(
DownloadCommands::Command command) {
switch (command) {
case DownloadCommands::CANCEL:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_CANCEL_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::RESUME:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_RESUME_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::DISCARD:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_DELETE_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::KEEP:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_KEEP_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::DEEP_SCAN:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_SCAN_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::BYPASS_DEEP_SCANNING:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_OPEN_NOW_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::REVIEW:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_REVIEW_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
case DownloadCommands::RETRY:
return l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_BUBBLE_RETRY_MAIN_BUTTON_ACCESSIBILITY,
model_->GetFileNameToReportUser().LossyDisplayName());
default:
NOTREACHED();
return u"";
}
}

void DownloadBubbleRowView::ShowContextMenuForViewImpl(
View* source,
const gfx::Point& point,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class DownloadBubbleRowView : public views::View,
DownloadCommands::Command command);
std::u16string GetAccessibleNameForQuickAction(
DownloadCommands::Command command);
views::MdTextButton* GetMainPageButton(DownloadCommands::Command command);
std::u16string GetAccessibleNameForMainPageButton(
DownloadCommands::Command command);

// If there is any change in state, update UI info.
// Returns whether the ui info was changed.
Expand Down

0 comments on commit 18466ed

Please sign in to comment.