capture_mode: Trigger ChromeVox alert on capture type or source changed
This CL triggers ChromeVox alert on capture mode source changed, on capture mode type changed, at the end of selecting capture region and on capture window selected. Recorded video: https://drive.google.com/file/d/1aAdfCZE6wOVubXrsA_WIq3YNGHmAlb01/view?usp=sharing&resourcekey=0-ApYmdR2LC5kIVZLbLJoDdg Bug: 1237569 Change-Id: I2b09b68f249eab77d0a841316792cfc2a151b705 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3584509 Reviewed-by: Min Chen <minch@chromium.org> Reviewed-by: Connie Xu <conniekxu@chromium.org> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Commit-Queue: Hongyu Long <hongyulong@chromium.org> Cr-Commit-Position: refs/heads/main@{#1000145}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
af4dcb078a
commit
b695447b88
ash
ash_strings.grd
ash_strings_grd
IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_RECORD.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_SCREENSHOT.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_RECORD.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_SCREENSHOT.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_FULLSCREEN.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_REGION.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_WINDOW.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_RECORD.png.sha1IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_SCREENSHOT.png.sha1
capture_mode
@ -4094,21 +4094,30 @@ Here are some things you can try to get started.
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_CLOSE" desc="Alert spoken by screen readers when exiting capture mode.">
|
||||
Exit capture mode
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_SCREENSHOT" desc="Alert spoken by screen readers on capturing full screen screenshot.">
|
||||
Press enter to capture full screen screenshot
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_RECORD" desc="Alert spoken by screen readers on recording full screen.">
|
||||
Press enter to record full screen
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_SCREENSHOT" desc="Alert spoken by screen readers on capturing partial screenshot.">
|
||||
Press enter to capture partial screenshot
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_RECORD" desc="Alert spoken by screen readers on recording partial screen.">
|
||||
Press enter to record partial screen
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_SCREENSHOT" desc="Alert spoken by screen readers on capturing window screenshot.">
|
||||
Press enter to capture window screenshot
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_RECORD" desc="Alert spoken by screen readers on recording window screen.">
|
||||
Press enter to record window
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_IMAGE" desc="Alert spoken by screen readers on selecting screenshot mode.">
|
||||
Screenshot mode selected
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_VIDEO" desc="Alert spoken by screen readers on selecting screen recording mode.">
|
||||
Screen recording mode selected
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_FULLSCREEN" desc="Alert spoken by screen readers on selecting full screen as source.">
|
||||
Selection area set to full screen
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_REGION" desc="Alert spoken by screen readers on selecting partial screen as source.">
|
||||
Partial screenshot selected
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_WINDOW" desc="Alert spoken by screen readers on selecting window as source.">
|
||||
Selection area set to window
|
||||
</message>
|
||||
<message name="IDS_ASH_SCREEN_CAPTURE_ALERT_SCREENSHOT_CAPTURED" desc="Alert spoken by screen readers when screenshot captured.">
|
||||
Screenshot captured
|
||||
</message>
|
||||
|
@ -0,0 +1 @@
|
||||
10a27b4f1db496fae666b830f4303c4d69d806be
|
@ -0,0 +1 @@
|
||||
b4ca38af2f00d992bfe673d1ecd52907f753d823
|
@ -0,0 +1 @@
|
||||
427be947ae9a117cdc816b8a1882d39cdba0dce4
|
@ -0,0 +1 @@
|
||||
fd153f2acf3fe0652d9b78c34f2b5c1e72947430
|
@ -1 +0,0 @@
|
||||
f95a2a78824a8e773a1d824d2b1dc4960a718065
|
@ -1 +0,0 @@
|
||||
f593832fe7ecff335da8e567418d01826fe9d995
|
@ -1 +0,0 @@
|
||||
e4c2b9fd39522b27b0db03d35ae28a59e2ed4fc7
|
@ -0,0 +1 @@
|
||||
b0357908fdda599df487d1d951aa5b42501bff7e
|
@ -0,0 +1 @@
|
||||
dab5178273e8b8b033edfbe8f762a011d95f60aa
|
@ -327,24 +327,15 @@ void ClipRectToFit(gfx::Rect* out_bounds, const gfx::Rect& rect) {
|
||||
std::min(rect.bottom(), out_bounds->bottom()));
|
||||
}
|
||||
|
||||
// Returns the appropriate |message_id| for a chromevox alert.
|
||||
// |for_toggle_alert| helps differentiate between the session start and when a
|
||||
// user toggles the source.
|
||||
int GetMessageIdForCaptureSource(CaptureModeSource source,
|
||||
bool for_toggle_alert) {
|
||||
// Returns the `message_id` for the chromevox alert when capture session starts.
|
||||
int GetMessageIdForInitialCaptureSource(CaptureModeSource source) {
|
||||
switch (source) {
|
||||
case CaptureModeSource::kFullscreen:
|
||||
return for_toggle_alert
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_FULLSCREEN
|
||||
: IDS_ASH_SCREEN_CAPTURE_SOURCE_FULLSCREEN;
|
||||
return IDS_ASH_SCREEN_CAPTURE_SOURCE_FULLSCREEN;
|
||||
case CaptureModeSource::kRegion:
|
||||
return for_toggle_alert
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_REGION
|
||||
: IDS_ASH_SCREEN_CAPTURE_SOURCE_PARTIAL;
|
||||
return IDS_ASH_SCREEN_CAPTURE_SOURCE_PARTIAL;
|
||||
default:
|
||||
return for_toggle_alert
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_SOURCE_WINDOW
|
||||
: IDS_ASH_SCREEN_CAPTURE_SOURCE_WINDOW;
|
||||
return IDS_ASH_SCREEN_CAPTURE_SOURCE_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
@ -622,8 +613,8 @@ void CaptureModeSession::Initialize() {
|
||||
// `capture_mode_bar_widget_`.
|
||||
capture_mode_util::TriggerAccessibilityAlert(l10n_util::GetStringFUTF8(
|
||||
IDS_ASH_SCREEN_CAPTURE_ALERT_OPEN,
|
||||
l10n_util::GetStringUTF16(GetMessageIdForCaptureSource(
|
||||
controller_->source(), /*for_toggle_alert=*/false)),
|
||||
l10n_util::GetStringUTF16(
|
||||
GetMessageIdForInitialCaptureSource(controller_->source())),
|
||||
l10n_util::GetStringUTF16(
|
||||
controller_->type() == CaptureModeType::kImage
|
||||
? IDS_ASH_SCREEN_CAPTURE_TYPE_SCREENSHOT
|
||||
@ -749,6 +740,51 @@ aura::Window* CaptureModeSession::GetSelectedWindow() const {
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void CaptureModeSession::A11yAlertCaptureSource(bool trigger_now) {
|
||||
auto* controller = CaptureModeController::Get();
|
||||
const bool is_capturing_image = controller->type() == CaptureModeType::kImage;
|
||||
std::string message;
|
||||
|
||||
switch (controller->source()) {
|
||||
case CaptureModeSource::kFullscreen:
|
||||
message = l10n_util::GetStringUTF8(
|
||||
is_capturing_image
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_SCREENSHOT
|
||||
: IDS_ASH_SCREEN_CAPTURE_ALERT_FULLSCREEN_RECORD);
|
||||
break;
|
||||
case CaptureModeSource::kRegion:
|
||||
if (!controller->user_capture_region().IsEmpty()) {
|
||||
message = l10n_util::GetStringUTF8(
|
||||
is_capturing_image ? IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_SCREENSHOT
|
||||
: IDS_ASH_SCREEN_CAPTURE_ALERT_REGION_RECORD);
|
||||
}
|
||||
break;
|
||||
case CaptureModeSource::kWindow:
|
||||
// Selected window could be non-empty when switching to capture type.
|
||||
if (GetSelectedWindow()) {
|
||||
message = l10n_util::GetStringUTF8(
|
||||
is_capturing_image ? IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_SCREENSHOT
|
||||
: IDS_ASH_SCREEN_CAPTURE_ALERT_WINDOW_RECORD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!message.empty()) {
|
||||
if (trigger_now)
|
||||
capture_mode_util::TriggerAccessibilityAlert(message);
|
||||
else
|
||||
capture_mode_util::TriggerAccessibilityAlertSoon(message);
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureModeSession::A11yAlertCaptureType() {
|
||||
capture_mode_util::TriggerAccessibilityAlert(
|
||||
CaptureModeController::Get()->type() == CaptureModeType::kImage
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_IMAGE
|
||||
: IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_VIDEO);
|
||||
A11yAlertCaptureSource(/*trigger_now=*/false);
|
||||
}
|
||||
|
||||
void CaptureModeSession::OnCaptureSourceChanged(CaptureModeSource new_source) {
|
||||
capture_source_changed_ = true;
|
||||
|
||||
@ -770,8 +806,7 @@ void CaptureModeSession::OnCaptureSourceChanged(CaptureModeSource new_source) {
|
||||
if (focus_cycler_->RegionGroupFocused())
|
||||
focus_cycler_->ClearFocus();
|
||||
|
||||
capture_mode_util::TriggerAccessibilityAlert(
|
||||
GetMessageIdForCaptureSource(new_source, /*for_toggle_alert=*/true));
|
||||
A11yAlertCaptureSource(/*trigger_now=*/true);
|
||||
|
||||
MaybeReparentCameraPreviewWidget();
|
||||
}
|
||||
@ -782,10 +817,7 @@ void CaptureModeSession::OnCaptureTypeChanged(CaptureModeType new_type) {
|
||||
UpdateCursor(display::Screen::GetScreen()->GetCursorScreenPoint(),
|
||||
/*is_touch=*/false);
|
||||
|
||||
capture_mode_util::TriggerAccessibilityAlert(
|
||||
new_type == CaptureModeType::kImage
|
||||
? IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_IMAGE
|
||||
: IDS_ASH_SCREEN_CAPTURE_ALERT_SELECT_TYPE_VIDEO);
|
||||
A11yAlertCaptureType();
|
||||
}
|
||||
|
||||
void CaptureModeSession::OnWaitingForDlpConfirmationStarted() {
|
||||
@ -2119,6 +2151,8 @@ void CaptureModeSession::OnLocatedEventReleased(
|
||||
// After first release event, we advance to the next phase.
|
||||
is_selecting_region_ = false;
|
||||
UpdateCaptureLabelWidget(CaptureLabelAnimation::kRegionPhaseChange);
|
||||
|
||||
A11yAlertCaptureSource(/*trigger_now=*/true);
|
||||
}
|
||||
|
||||
void CaptureModeSession::UpdateCaptureRegion(
|
||||
|
@ -104,6 +104,15 @@ class ASH_EXPORT CaptureModeSession
|
||||
// nullptr if no window is available for selection.
|
||||
aura::Window* GetSelectedWindow() const;
|
||||
|
||||
// Called when a user toggles the capture source or capture type to announce
|
||||
// an accessibility alert. If `trigger_now` is true, it will announce
|
||||
// immediately; otherwise, it will trigger another alert asynchronously with
|
||||
// the alert.
|
||||
void A11yAlertCaptureSource(bool trigger_now);
|
||||
|
||||
// Called when switching a capture type from another capture type.
|
||||
void A11yAlertCaptureType();
|
||||
|
||||
// Called when either the capture source or type changes.
|
||||
void OnCaptureSourceChanged(CaptureModeSource new_source);
|
||||
void OnCaptureTypeChanged(CaptureModeType new_type);
|
||||
|
@ -153,13 +153,16 @@ void TriggerAccessibilityAlert(int message_id) {
|
||||
TriggerAccessibilityAlert(l10n_util::GetStringUTF8(message_id));
|
||||
}
|
||||
|
||||
void TriggerAccessibilityAlertSoon(int message_id) {
|
||||
void TriggerAccessibilityAlertSoon(const std::string& message) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
&AccessibilityControllerImpl::TriggerAccessibilityAlertWithMessage,
|
||||
Shell::Get()->accessibility_controller()->GetWeakPtr(),
|
||||
l10n_util::GetStringUTF8(message_id)));
|
||||
Shell::Get()->accessibility_controller()->GetWeakPtr(), message));
|
||||
}
|
||||
|
||||
void TriggerAccessibilityAlertSoon(int message_id) {
|
||||
TriggerAccessibilityAlertSoon(l10n_util::GetStringUTF8(message_id));
|
||||
}
|
||||
|
||||
CameraPreviewSnapPosition GetCameraNextHorizontalSnapPosition(
|
||||
|
@ -63,6 +63,7 @@ void TriggerAccessibilityAlert(int message_id);
|
||||
// asynchronously as soon as possible. This is used to make sure consecutive
|
||||
// alerts do not override one another, so all of them can be announced by
|
||||
// ChromeVox.
|
||||
void TriggerAccessibilityAlertSoon(const std::string& message);
|
||||
void TriggerAccessibilityAlertSoon(int message_id);
|
||||
|
||||
// Returns the next horizontal or vertical snap position based on the current
|
||||
|
@ -58,8 +58,10 @@ void CaptureWindowObserver::SetSelectedWindow(aura::Window* window) {
|
||||
|
||||
// Stop observing the current selected window if there is one.
|
||||
StopObserving();
|
||||
if (window)
|
||||
if (window) {
|
||||
StartObserving(window);
|
||||
capture_mode_session_->A11yAlertCaptureSource(/*trigger_now=*/true);
|
||||
}
|
||||
RepaintCaptureRegion();
|
||||
|
||||
auto* controller = CaptureModeController::Get();
|
||||
|
Reference in New Issue
Block a user