Commit edffb527 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Add ChromeVox support for Virtual Desks.

Bug: 987003
Change-Id: If690111289c7ab6f03c94c7363e488641b8743dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1716957Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681082}
parent 5b38b177
......@@ -641,6 +641,12 @@ void AccessibilityControllerImpl::TriggerAccessibilityAlert(
client_->TriggerAccessibilityAlert(alert);
}
void AccessibilityControllerImpl::TriggerAccessibilityAlertWithMessage(
const std::string& message) {
if (client_)
client_->TriggerAccessibilityAlertWithMessage(message);
}
void AccessibilityControllerImpl::PlayEarcon(int32_t sound_key) {
if (client_)
client_->PlayEarcon(sound_key);
......
......@@ -135,6 +135,9 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
// Triggers an accessibility alert to give the user feedback.
void TriggerAccessibilityAlert(AccessibilityAlert alert);
// Triggers an accessibility alert with the given |message|.
void TriggerAccessibilityAlertWithMessage(const std::string& message);
// Plays an earcon. Earcons are brief and distinctive sounds that indicate
// that their mapped event has occurred. The |sound_key| enums can be found in
// chromeos/audio/chromeos_sounds.h.
......
......@@ -24,6 +24,9 @@ void TestAccessibilityControllerClient::TriggerAccessibilityAlert(
last_a11y_alert_ = alert;
}
void TestAccessibilityControllerClient::TriggerAccessibilityAlertWithMessage(
const std::string& message) {}
void TestAccessibilityControllerClient::PlayEarcon(int32_t sound_key) {
sound_key_ = sound_key;
}
......
......@@ -23,8 +23,10 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient {
static constexpr base::TimeDelta kShutdownSoundDuration =
base::TimeDelta::FromMilliseconds(1000);
// mojom::AccessibilityControllerClient:
// AccessibilityControllerClient:
void TriggerAccessibilityAlert(AccessibilityAlert alert) override;
void TriggerAccessibilityAlertWithMessage(
const std::string& message) override;
void PlayEarcon(int32_t sound_key) override;
base::TimeDelta PlayShutdownSound() override;
void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override;
......
......@@ -1993,6 +1993,20 @@ This file contains the strings for ash.
<message name="IDS_ASH_LOCK_SCREEN_MEDIA_CONTROLS_CLOSE" desc="The button to dismiss the media controls and pause playback.">
Close
</message>
<!-- Virtual desks -->
<message name="IDS_ASH_VIRTUAL_DESKS_ALERT_NEW_DESK_CREATED" desc="A new desk is created in virtual desks.">
Desk <ph name="DESK_TITILE">$1<ex>1</ex></ph> created
</message>
<message name="IDS_ASH_VIRTUAL_DESKS_ALERT_DESK_REMOVED" desc="A desk is removed in virtual desks.">
Desk <ph name="REMOVED_DESK">$1</ph> removed and merged with Desk <ph name="RECEIVE_DESK">$2</ph>
</message>
<message name="IDS_ASH_VIRTUAL_DESKS_ALERT_DESK_ACTIVATED" desc="A desk in virtual desks is activated.">
Desk <ph name="DESK_TITILE">$1<ex>1</ex></ph> activated
</message>
<message name="IDS_ASH_VIRTUAL_DESKS_ALERT_WINDOW_MOVED_FROM_ACTIVE_DESK" desc="A window in active desk got be moved to another virtual desk.">
Window <ph name="WINDOW_TITLE">$1<ex>Files</ex></ph> moved from Desk <ph name="ACTIVE_DESK">$2</ph> to Desk <ph name="TARGET_DESK">$3</ph>
</message>
</messages>
</release>
</grit>
8f947c92a5b23810ff5cd966d12aed537a18aed2
\ No newline at end of file
d60dbf64ba69bf06c2e14938aca74aa7d1de9f59
\ No newline at end of file
45b46f0e5040d9cf871a398d350e59daf2cc8bd2
\ No newline at end of file
84e439c808c3505a80cb16d9c06aecb49074992a
\ No newline at end of file
......@@ -28,6 +28,10 @@ class ASH_PUBLIC_EXPORT AccessibilityControllerClient {
// Triggers an accessibility alert to give the user feedback.
virtual void TriggerAccessibilityAlert(AccessibilityAlert alert) = 0;
// Triggers an accessibility alert with the given |message|.
virtual void TriggerAccessibilityAlertWithMessage(
const std::string& message) = 0;
// Plays an earcon. Earcons are brief and distinctive sounds that indicate
// that their mapped event has occurred. The |sound_key| enums can be found in
// chromeos/audio/chromeos_sounds.h. This method exists because the browser
......
......@@ -6,8 +6,10 @@
#include <utility>
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wm/desks/desk.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/desks/root_window_desk_switch_animator.h"
......@@ -22,6 +24,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/compositor.h"
#include "ui/wm/public/activation_client.h"
......@@ -146,6 +149,11 @@ void DesksController::NewDesk(DesksCreationRemovalSource source) {
UMA_HISTOGRAM_ENUMERATION(kNewDeskHistogramName, source);
ReportDesksCountHistogram();
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(l10n_util::GetStringFUTF8(
IDS_ASH_VIRTUAL_DESKS_ALERT_NEW_DESK_CREATED,
base::NumberToString16(desks_.size())));
for (auto& observer : observers_)
observer.OnDeskAdded(desks_.back().get());
......@@ -162,6 +170,9 @@ void DesksController::RemoveDesk(const Desk* desk,
[desk](const std::unique_ptr<Desk>& d) { return d.get() == desk; });
DCHECK(iter != desks_.end());
// Used by accessibility to indicate the desk that has been removed.
const int removed_desk_number = std::distance(desks_.begin(), iter) + 1;
// Keep the removed desk alive until the end of this function.
std::unique_ptr<Desk> removed_desk = std::move(*iter);
DCHECK_EQ(removed_desk.get(), desk);
......@@ -269,6 +280,16 @@ void DesksController::RemoveDesk(const Desk* desk,
ReportDesksCountHistogram();
ReportNumberOfWindowsPerDeskHistogram();
int active_desk_number = GetDeskIndex(active_desk_) + 1;
if (active_desk_number == removed_desk_number)
active_desk_number++;
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(l10n_util::GetStringFUTF8(
IDS_ASH_VIRTUAL_DESKS_ALERT_DESK_REMOVED,
base::NumberToString16(removed_desk_number),
base::NumberToString16(active_desk_number)));
DCHECK_LE(available_container_ids_.size(), desks_util::kMaxNumberOfDesks);
}
......@@ -293,6 +314,12 @@ void DesksController::ActivateDesk(const Desk* desk, DesksSwitchSource source) {
return;
}
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(l10n_util::GetStringFUTF8(
IDS_ASH_VIRTUAL_DESKS_ALERT_DESK_ACTIVATED,
base::NumberToString16(GetDeskIndex(desk) + 1)));
// New desks are always added at the end of the list to the right of existing
// desks. Therefore, desks at lower indices are located on the left of desks
// with higher indices.
......@@ -324,6 +351,14 @@ void DesksController::MoveWindowFromActiveDeskTo(
active_desk_->MoveWindowToDesk(window, target_desk);
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(l10n_util::GetStringFUTF8(
IDS_ASH_VIRTUAL_DESKS_ALERT_WINDOW_MOVED_FROM_ACTIVE_DESK,
window->GetTitle(),
base::NumberToString16(GetDeskIndex(active_desk_) + 1),
base::NumberToString16(GetDeskIndex(target_desk) + 1)));
if (in_overview) {
DCHECK(overview_controller->InOverviewSession());
auto* overview_session = overview_controller->overview_session();
......
......@@ -88,6 +88,15 @@ void AccessibilityControllerClient::TriggerAccessibilityAlert(
}
}
void AccessibilityControllerClient::TriggerAccessibilityAlertWithMessage(
const std::string& message) {
Profile* profile = ProfileManager::GetActiveUserProfile();
if (!profile)
return;
AutomationManagerAura::GetInstance()->HandleAlert(message);
}
void AccessibilityControllerClient::PlayEarcon(int32_t sound_key) {
chromeos::AccessibilityManager::Get()->PlayEarcon(
sound_key, chromeos::PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED);
......
......@@ -17,6 +17,8 @@ class AccessibilityControllerClient
// ash::AccessibilityControllerClient:
void TriggerAccessibilityAlert(ash::AccessibilityAlert alert) override;
void TriggerAccessibilityAlertWithMessage(
const std::string& message) override;
void PlayEarcon(int sound_key) override;
base::TimeDelta PlayShutdownSound() override;
void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override;
......
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