0

scanner: Set window title for action button container.

The window title will be read by screen readers when the user navigates
to the action button container.

Bug: b:401570359, b:401571204
Change-Id: I1535647e51af0236a3873e46af383d22a95d8096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6347540
Commit-Queue: Michelle Chen <michellegc@google.com>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1433305}
This commit is contained in:
Michelle Chen
2025-03-16 17:40:38 -07:00
committed by Chromium LUCI CQ
parent c34489beec
commit fc09bc2c31
7 changed files with 80 additions and 0 deletions

@ -6859,6 +6859,12 @@ Here are some things you can try to get started.
<message name="IDS_ASH_SCREEN_CAPTURE_SEARCH_RESULTS_PANEL_TITLE" desc="The title of the panel that shows Google Search results when the user searches a selected region on their screen.">
Google Search
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_DEFAULT_ACTION_BUTTON_WINDOW_TITLE" desc="The title of the window that contains available action buttons for the screen capture tool other than capture image, e.g. copy text or search image.">
Other actions
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_SUNFISH_ACTION_BUTTON_WINDOW_TITLE" desc="The title of the window that contains available action buttons after the user has selected a region on their screen of interest. Example actions include copy text or create a Google Doc.">
Actions
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_COPY_TEXT_BUTTON_LABEL" desc="The label on a button that can be clicked to copy text from the contents of a screenshot into the user's clipboard.">
Copy text
</message>

@ -0,0 +1 @@
cdf8389e6687883f4e570b2ea45170e1ec00293c

@ -0,0 +1 @@
1909761c4f37e56bc6de103491440e305f1a3e17

@ -394,6 +394,10 @@ class SunfishBehavior : public CaptureModeBehavior {
const std::u16string GetCaptureLabelRegionText() const override {
return l10n_util::GetStringUTF16(IDS_ASH_SUNFISH_CAPTURE_LABEL);
}
const std::u16string GetActionButtonContainerTitle() const override {
return l10n_util::GetStringUTF16(
IDS_ASH_SCREEN_CAPTURE_SUNFISH_ACTION_BUTTON_WINDOW_TITLE);
}
const std::string GetCaptureModeOpenAnnouncement() const override {
return l10n_util::GetStringUTF8(IDS_ASH_SUNFISH_MODE_ALERT_OPEN);
}
@ -643,6 +647,12 @@ const std::u16string CaptureModeBehavior::GetCaptureLabelRegionText() const {
: IDS_ASH_SCREEN_CAPTURE_LABEL_REGION_VIDEO_RECORD);
}
const std::u16string CaptureModeBehavior::GetActionButtonContainerTitle()
const {
return l10n_util::GetStringUTF16(
IDS_ASH_SCREEN_CAPTURE_DEFAULT_ACTION_BUTTON_WINDOW_TITLE);
}
const std::string CaptureModeBehavior::GetCaptureModeOpenAnnouncement() const {
CaptureModeController* controller = CaptureModeController::Get();
int capture_source_id;

@ -139,6 +139,11 @@ class CaptureModeBehavior {
// a capture region phase.
virtual const std::u16string GetCaptureLabelRegionText() const;
// Returns the title to use for the action button container window. This will
// be announced by a screen reader when the user navigates to the action
// button container.
virtual const std::u16string GetActionButtonContainerTitle() const;
// Returns the text to be announced by a screen reader when capture mode is
// opened with this behavior.
virtual const std::string GetCaptureModeOpenAnnouncement() const;

@ -3635,6 +3635,8 @@ void CaptureModeSession::UpdateActionContainerWidget() {
auto* parent = GetParentContainer(current_root_);
action_container_widget_->Init(
CreateWidgetParams(parent, gfx::Rect(), "ActionButtonsContainer"));
action_container_widget_->widget_delegate()->SetTitle(
active_behavior_->GetActionButtonContainerTitle());
action_container_view_ = action_container_widget_->SetContentsView(
std::make_unique<ActionButtonContainerView>());

@ -54,6 +54,7 @@
#include "ash/shelf/home_button.h"
#include "ash/shelf/shelf_navigation_widget.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/icon_button.h"
#include "ash/style/pill_button.h"
#include "ash/style/tab_slider_button.h"
@ -83,6 +84,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h"
@ -95,6 +97,7 @@
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/window_util.h"
#include "url/gurl.h"
@ -1238,6 +1241,58 @@ TEST_F(SunfishTest, CaptureRegionOverlay) {
EXPECT_FALSE(session->active_behavior()->CanPaintRegionOverlay());
}
// Tests that the action container window has a title and accessible title in
// default capture mode.
TEST_F(SunfishTest, ActionContainerWindowTitleDefaultMode) {
auto* controller =
StartCaptureSession(CaptureModeSource::kRegion, CaptureModeType::kImage);
SelectCaptureModeRegion(GetEventGenerator(), gfx::Rect(10, 10, 50, 50),
/*release_mouse=*/true, /*verify_region=*/true);
capture_mode_util::AddActionButton(
views::Button::PressedCallback(), u"Copy Text", &kCaptureModeImageIcon,
ActionButtonRank(ActionButtonType::kCopyText, 0),
ActionButtonViewID::kCopyTextButton);
views::Widget* action_container_widget =
CaptureModeSessionTestApi(controller->capture_mode_session())
.GetActionContainerWidget();
ASSERT_TRUE(action_container_widget);
const std::u16string kActionContainerWindowTitle = l10n_util::GetStringUTF16(
IDS_ASH_SCREEN_CAPTURE_DEFAULT_ACTION_BUTTON_WINDOW_TITLE);
EXPECT_EQ(action_container_widget->widget_delegate()->GetWindowTitle(),
kActionContainerWindowTitle);
EXPECT_EQ(
action_container_widget->widget_delegate()->GetAccessibleWindowTitle(),
kActionContainerWindowTitle);
}
// Tests that the action container window has a title and accessible title in
// Sunfish mode.
TEST_F(SunfishTest, ActionContainerWindowTitleSunfishMode) {
auto* controller = CaptureModeController::Get();
controller->StartSunfishSession();
SelectCaptureModeRegion(GetEventGenerator(), gfx::Rect(10, 10, 50, 50),
/*release_mouse=*/true, /*verify_region=*/true);
capture_mode_util::AddActionButton(
views::Button::PressedCallback(), u"Copy Text", &kCaptureModeImageIcon,
ActionButtonRank(ActionButtonType::kCopyText, 0),
ActionButtonViewID::kCopyTextButton);
views::Widget* action_container_widget =
CaptureModeSessionTestApi(controller->capture_mode_session())
.GetActionContainerWidget();
ASSERT_TRUE(action_container_widget);
const std::u16string kActionContainerWindowTitle = l10n_util::GetStringUTF16(
IDS_ASH_SCREEN_CAPTURE_SUNFISH_ACTION_BUTTON_WINDOW_TITLE);
EXPECT_EQ(action_container_widget->widget_delegate()->GetWindowTitle(),
kActionContainerWindowTitle);
EXPECT_EQ(
action_container_widget->widget_delegate()->GetAccessibleWindowTitle(),
kActionContainerWindowTitle);
}
// Tests that the action container widget's opacity is updated properly before a
// region is selected, while a region is selected, and while the region is being
// adjusted.