Commit 40fda92a authored by David Tseng's avatar David Tseng Committed by Commit Bot

Revert: defer ChromeVox load, play progress tones natively

This reverts changes:
4fe3a6a4 Ensure AccessibilityManager::ChromeVoxDeferredLoader's warmup utterance targets Googletts
8df286c2 Moves load progress tones from js to native

which were mainly workarounds for slow Google tts during the web assembly porteffort.

This revert removes now unnecessary complexity around ChromeVox's load path now that text to speech is native.

R=dmazzoni@chromium.org

TBR=dmazzoni@chromium.org

Change-Id: I8cdc9a946b1c112011aabfd3babd533aff03ed2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264193Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782002}
parent ad2a02df
...@@ -188,78 +188,6 @@ class AccessibilityPanelWidgetObserver : public views::WidgetObserver { ...@@ -188,78 +188,6 @@ class AccessibilityPanelWidgetObserver : public views::WidgetObserver {
DISALLOW_COPY_AND_ASSIGN(AccessibilityPanelWidgetObserver); DISALLOW_COPY_AND_ASSIGN(AccessibilityPanelWidgetObserver);
}; };
// Responsible for deferring ChromeVox load until a text-to-speech voice is
// ready to be used. Plays progress tones while waiting.
class ChromeVoxDeferredLoader : public content::UtteranceEventDelegate,
public content::VoicesChangedDelegate {
public:
explicit ChromeVoxDeferredLoader(AccessibilityManager* manager)
: manager_(manager) {
timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(500), this,
&ChromeVoxDeferredLoader::OnTimer);
if (IsGoogleTtsVoiceAvailable())
SendWarmupUtterance();
else
content::TtsController::GetInstance()->AddVoicesChangedDelegate(this);
}
~ChromeVoxDeferredLoader() override {
content::TtsController::GetInstance()->RemoveVoicesChangedDelegate(this);
content::TtsController::GetInstance()->RemoveUtteranceEventDelegate(this);
manager_->UnloadChromeVox();
}
private:
// content::UtteranceEventDelegate:
void OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) override {
utterance->SetEventDelegate(nullptr);
timer_.Stop();
manager_->LoadChromeVox();
}
// content::VoicesChangedDelegate:
void OnVoicesChanged() override {
if (IsGoogleTtsVoiceAvailable()) {
content::TtsController::GetInstance()->RemoveVoicesChangedDelegate(this);
SendWarmupUtterance();
}
}
void SendWarmupUtterance() {
Profile* profile = manager_->profile();
if (profile->HasPrimaryOTRProfile())
profile = profile->GetPrimaryOTRProfile();
std::unique_ptr<content::TtsUtterance> utterance =
content::TtsUtterance::Create(profile);
utterance->SetEventDelegate(this);
utterance->SetEngineId(extension_misc::kGoogleSpeechSynthesisExtensionId);
content::TtsController::GetInstance()->SpeakOrEnqueue(std::move(utterance));
}
void OnTimer() { manager_->PlaySpokenFeedbackToggleCountdown(tick_count_++); }
bool IsGoogleTtsVoiceAvailable() const {
Profile* profile = manager_->profile();
if (profile->HasPrimaryOTRProfile())
profile = profile->GetPrimaryOTRProfile();
std::vector<content::VoiceData> voices;
content::TtsController::GetInstance()->GetVoices(profile, &voices);
return std::any_of(voices.begin(), voices.end(), [](const auto& voice) {
return voice.engine_id ==
extension_misc::kGoogleSpeechSynthesisExtensionId;
});
}
AccessibilityManager* manager_;
int tick_count_ = 0;
base::RepeatingTimer timer_;
};
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// AccessibilityStatusEventDetails // AccessibilityStatusEventDetails
...@@ -531,10 +459,11 @@ void AccessibilityManager::OnSpokenFeedbackChanged() { ...@@ -531,10 +459,11 @@ void AccessibilityManager::OnSpokenFeedbackChanged() {
NotifyAccessibilityStatusChanged(details); NotifyAccessibilityStatusChanged(details);
if (enabled) { if (enabled) {
chromevox_deferred_loader_ = chromevox_loader_->Load(
std::make_unique<ChromeVoxDeferredLoader>(this); profile_, base::BindRepeating(&AccessibilityManager::PostLoadChromeVox,
weak_ptr_factory_.GetWeakPtr()));
} else { } else {
chromevox_deferred_loader_.reset(); chromevox_loader_->Unload();
} }
UpdateBrailleImeState(); UpdateBrailleImeState();
} }
...@@ -1378,21 +1307,6 @@ void AccessibilityManager::OnShutdown(extensions::ExtensionRegistry* registry) { ...@@ -1378,21 +1307,6 @@ void AccessibilityManager::OnShutdown(extensions::ExtensionRegistry* registry) {
extension_registry_observer_.Remove(registry); extension_registry_observer_.Remove(registry);
} }
void AccessibilityManager::LoadChromeVox() {
chromevox_loader_->Load(
profile_, base::BindRepeating(&AccessibilityManager::PostLoadChromeVox,
weak_ptr_factory_.GetWeakPtr()));
}
void AccessibilityManager::UnloadChromeVox() {
// In browser_tests unloading the ChromeVox extension can race with shutdown.
// http://crbug.com/801700
if (app_terminating_)
return;
chromevox_loader_->Unload();
}
void AccessibilityManager::PostLoadChromeVox() { void AccessibilityManager::PostLoadChromeVox() {
// In browser_tests loading the ChromeVox extension can race with shutdown. // In browser_tests loading the ChromeVox extension can race with shutdown.
// http://crbug.com/801700 // http://crbug.com/801700
......
...@@ -90,7 +90,6 @@ typedef AccessibilityStatusCallbackList::Subscription ...@@ -90,7 +90,6 @@ typedef AccessibilityStatusCallbackList::Subscription
AccessibilityStatusSubscription; AccessibilityStatusSubscription;
class AccessibilityPanelWidgetObserver; class AccessibilityPanelWidgetObserver;
class ChromeVoxDeferredLoader;
enum class PlaySoundOption { enum class PlaySoundOption {
// The sound is always played. // The sound is always played.
...@@ -356,8 +355,6 @@ class AccessibilityManager ...@@ -356,8 +355,6 @@ class AccessibilityManager
~AccessibilityManager() override; ~AccessibilityManager() override;
private: private:
void LoadChromeVox();
void UnloadChromeVox();
void PostLoadChromeVox(); void PostLoadChromeVox();
void PostUnloadChromeVox(); void PostUnloadChromeVox();
void PostSwitchChromeVoxProfile(); void PostSwitchChromeVoxProfile();
...@@ -494,14 +491,10 @@ class AccessibilityManager ...@@ -494,14 +491,10 @@ class AccessibilityManager
// Used to set the audio focus enforcement type for ChromeVox. // Used to set the audio focus enforcement type for ChromeVox.
mojo::Remote<media_session::mojom::AudioFocusManager> audio_focus_manager_; mojo::Remote<media_session::mojom::AudioFocusManager> audio_focus_manager_;
// Handles deferred ChromeVox load.
std::unique_ptr<ChromeVoxDeferredLoader> chromevox_deferred_loader_;
base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_{this}; base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_{this};
friend class DictationTest; friend class DictationTest;
friend class SwitchAccessTest; friend class SwitchAccessTest;
friend class ChromeVoxDeferredLoader;
DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); DISALLOW_COPY_AND_ASSIGN(AccessibilityManager);
}; };
......
...@@ -147,15 +147,7 @@ void LoggedInSpokenFeedbackTest::EnableChromeVox() { ...@@ -147,15 +147,7 @@ void LoggedInSpokenFeedbackTest::EnableChromeVox() {
ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
AccessibilityManager::Get()->EnableSpokenFeedback(true); AccessibilityManager::Get()->EnableSpokenFeedback(true);
// AccessibilityManager sends a warmup utterance prior to actually loading
// ChromeVox.
sm_.ExpectSpeech("");
// The next utterance comes from ChromeVox signaling it is ready.
sm_.ExpectSpeechPattern("*"); sm_.ExpectSpeechPattern("*");
// Injects js to disable earcons.
sm_.Call([this]() { DisableEarcons(); }); sm_.Call([this]() { DisableEarcons(); });
} }
......
...@@ -169,6 +169,29 @@ Background = class extends ChromeVoxState { ...@@ -169,6 +169,29 @@ Background = class extends ChromeVoxState {
// Set the darkScreen state to false, since the display will be on whenever // Set the darkScreen state to false, since the display will be on whenever
// ChromeVox starts. // ChromeVox starts.
sessionStorage.setItem('darkScreen', 'false'); sessionStorage.setItem('darkScreen', 'false');
// A self-contained class to start and stop progress sounds before any
// speech has been generated on startup. This is important in cases where
// speech is severely delayed.
/** @implements {TtsCapturingEventListener} */
const ProgressPlayer = class {
constructor() {
ChromeVox.tts.addCapturingEventListener(this);
ChromeVox.earcons.playEarcon(Earcon.CHROMEVOX_LOADING);
}
/** @override */
onTtsStart() {
ChromeVox.earcons.playEarcon(Earcon.CHROMEVOX_LOADED);
ChromeVox.tts.removeCapturingEventListener(this);
}
/** @override */
onTtsEnd() {}
/** @override */
onTtsInterrupted() {}
};
new ProgressPlayer();
} }
/** /**
......
...@@ -26,7 +26,6 @@ ChromeVoxE2ETest = class extends testing.Test { ...@@ -26,7 +26,6 @@ ChromeVoxE2ETest = class extends testing.Test {
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/speech_monitor.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "extensions/common/extension_l10n_util.h" #include "extensions/common/extension_l10n_util.h"
...@@ -36,11 +35,6 @@ ChromeVoxE2ETest = class extends testing.Test { ...@@ -36,11 +35,6 @@ ChromeVoxE2ETest = class extends testing.Test {
/** @override */ /** @override */
testGenPreamble() { testGenPreamble() {
GEN(` GEN(`
// SpeechMonitor swaps in a custom TtsPlatform to mock out events and
// voices. Do this for the current call stack to catch deferred load.
chromeos::SpeechMonitor speech_monitor;
auto allow = extension_l10n_util::AllowGzippedMessagesAllowedForTest(); auto allow = extension_l10n_util::AllowGzippedMessagesAllowedForTest();
base::Closure load_cb = base::Closure load_cb =
base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback,
......
...@@ -2521,9 +2521,6 @@ IN_PROC_BROWSER_TEST_F(HotseatShelfAppBrowserTest, EnableChromeVox) { ...@@ -2521,9 +2521,6 @@ IN_PROC_BROWSER_TEST_F(HotseatShelfAppBrowserTest, EnableChromeVox) {
chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true); chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(true);
// AccessibilityManager sends an empty warmup utterance first.
speech_monitor.ExpectSpeech("");
// Wait for ChromeVox to start reading anything. // Wait for ChromeVox to start reading anything.
speech_monitor.ExpectSpeechPattern("*"); speech_monitor.ExpectSpeechPattern("*");
speech_monitor.Call([this]() { speech_monitor.Call([this]() {
......
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