Commit e2bbff4a authored by David Tseng's avatar David Tseng Committed by Commit Bot

Play startup sound if any user has ChromeVox enabled

Bug: 862419
Change-Id: Icbf4fd7664324c25099f3125076b793fd8846ba2
Reviewed-on: https://chromium-review.googlesource.com/1150832Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579890}
parent f83d1138
......@@ -45,6 +45,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/api/accessibility_private.h"
......@@ -59,6 +60,7 @@
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/known_user.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/focused_node_details.h"
......@@ -99,6 +101,9 @@ namespace {
// When this flag is set, system sounds will not be played.
constexpr char kAshDisableSystemSounds[] = "ash-disable-system-sounds";
// A key for the spoken feedback enabled boolean state for a known user.
const char kUserSpokenFeedbackEnabled[] = "UserSpokenFeedbackEnabled";
static chromeos::AccessibilityManager* g_accessibility_manager = nullptr;
static BrailleController* g_braille_controller_for_test = nullptr;
......@@ -241,6 +246,8 @@ AccessibilityManager::AccessibilityManager()
manager->Initialize(
SOUND_DICTATION_CANCEL,
bundle.GetRawDataResource(IDR_SOUND_DICTATION_CANCEL_WAV));
manager->Initialize(SOUND_STARTUP,
bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV));
base::FilePath resources_path;
if (!base::PathService::Get(chrome::DIR_RESOURCES, &resources_path))
......@@ -271,6 +278,8 @@ AccessibilityManager::AccessibilityManager()
->GetConnector()
->BindInterface(ash::mojom::kServiceName,
&accessibility_focus_ring_controller_);
CrasAudioHandler::Get()->AddAudioObserver(this);
}
AccessibilityManager::~AccessibilityManager() {
......@@ -278,6 +287,7 @@ AccessibilityManager::~AccessibilityManager() {
AccessibilityStatusEventDetails details(ACCESSIBILITY_MANAGER_SHUTDOWN,
false);
NotifyAccessibilityStatusChanged(details);
CrasAudioHandler::Get()->RemoveAudioObserver(this);
input_method::InputMethodManager::Get()->RemoveObserver(this);
if (chromevox_panel_) {
......@@ -390,6 +400,10 @@ void AccessibilityManager::OnSpokenFeedbackChanged() {
const bool enabled = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilitySpokenFeedbackEnabled);
user_manager::known_user::SetBooleanPref(
multi_user_util::GetAccountIdFromProfile(profile_),
kUserSpokenFeedbackEnabled, enabled);
if (enabled) {
chromevox_loader_->SetProfile(
profile_, base::Bind(&AccessibilityManager::PostSwitchChromeVoxProfile,
......@@ -879,6 +893,28 @@ void AccessibilityManager::InputMethodChanged(
(descriptor.id() == extension_ime_util::kBrailleImeEngineId);
}
void AccessibilityManager::OnActiveOutputNodeChanged() {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kFirstExecAfterBoot))
return;
AudioDevice device;
CrasAudioHandler::Get()->GetPrimaryActiveOutputDevice(&device);
if (device.type == AudioDeviceType::AUDIO_TYPE_OTHER)
return;
const auto& account_ids = user_manager::known_user::GetKnownAccountIds();
for (size_t i = 0; i < account_ids.size(); ++i) {
bool val;
if (user_manager::known_user::GetBooleanPref(
account_ids[i], kUserSpokenFeedbackEnabled, &val) &&
val) {
PlayEarcon(SOUND_STARTUP, PlaySoundOption::ALWAYS);
break;
}
}
}
void AccessibilityManager::SetProfile(Profile* profile) {
// Do nothing if this is called for the current profile. This can happen. For
// example, ChromeSessionManager fires both
......
......@@ -20,6 +20,7 @@
#include "base/time/time.h"
#include "chrome/browser/chromeos/accessibility/chromevox_panel.h"
#include "chrome/browser/extensions/api/braille_display_private/braille_controller.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
......@@ -96,7 +97,8 @@ class AccessibilityManager
public extensions::api::braille_display_private::BrailleObserver,
public extensions::ExtensionRegistryObserver,
public user_manager::UserManager::UserSessionStateObserver,
public input_method::InputMethodManager::Observer {
public input_method::InputMethodManager::Observer,
public CrasAudioHandler::AudioObserver {
public:
// Creates an instance of AccessibilityManager, this should be called once,
// because only one instance should exist at the same time.
......@@ -373,6 +375,9 @@ class AccessibilityManager
Profile* profile,
bool show_message) override;
// CrasAudioHandler::AudioObserver:
void OnActiveOutputNodeChanged() override;
// Profile which has the current a11y context.
Profile* profile_;
......
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