Commit 7c12bdb5 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Make TtsEngineExtensionObserver Chrome OS only

R=dmazzoni@chromium.org

Test: compiles, passes existing tests.
Change-Id: I543899d7cc231df8b1748b1d614e36d482acf789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2520802Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825031}
parent c0b8e067
...@@ -5431,8 +5431,6 @@ static_library("browser") { ...@@ -5431,8 +5431,6 @@ static_library("browser") {
"renderer_host/chrome_extension_message_filter.h", "renderer_host/chrome_extension_message_filter.h",
"speech/extension_api/tts_engine_extension_api.cc", "speech/extension_api/tts_engine_extension_api.cc",
"speech/extension_api/tts_engine_extension_api.h", "speech/extension_api/tts_engine_extension_api.h",
"speech/extension_api/tts_engine_extension_observer.cc",
"speech/extension_api/tts_engine_extension_observer.h",
"speech/extension_api/tts_extension_api.cc", "speech/extension_api/tts_extension_api.cc",
"speech/extension_api/tts_extension_api.h", "speech/extension_api/tts_extension_api.h",
"sync_file_system/conflict_resolution_policy.h", "sync_file_system/conflict_resolution_policy.h",
...@@ -5599,6 +5597,10 @@ static_library("browser") { ...@@ -5599,6 +5597,10 @@ static_library("browser") {
"//services/device/public/mojom", "//services/device/public/mojom",
] ]
if (is_chromeos) { if (is_chromeos) {
sources += [
"speech/extension_api/tts_engine_extension_observer_chromeos.cc",
"speech/extension_api/tts_engine_extension_observer_chromeos.h",
]
deps += [ "//chromeos/services/tts/public/mojom" ] deps += [ "//chromeos/services/tts/public/mojom" ]
} }
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "chrome/browser/chromeos/remote_apps/remote_apps_manager.h" #include "chrome/browser/chromeos/remote_apps/remote_apps_manager.h"
#include "chrome/browser/chromeos/remote_apps/remote_apps_manager_factory.h" #include "chrome/browser/chromeos/remote_apps/remote_apps_manager_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chromeos/components/camera_app_ui/camera_app_ui.h" #include "chromeos/components/camera_app_ui/camera_app_ui.h"
#include "chromeos/components/chromebox_for_meetings/buildflags/buildflags.h" #include "chromeos/components/chromebox_for_meetings/buildflags/buildflags.h"
...@@ -79,7 +79,7 @@ void BindHandwritingRecognizerRequestor( ...@@ -79,7 +79,7 @@ void BindHandwritingRecognizerRequestor(
void BindTtsStream( void BindTtsStream(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver) { mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver) {
TtsEngineExtensionObserver::GetInstance( TtsEngineExtensionObserverChromeOS::GetInstance(
Profile::FromBrowserContext(render_frame_host->GetBrowserContext())) Profile::FromBrowserContext(render_frame_host->GetBrowserContext()))
->BindTtsStream(std::move(receiver)); ->BindTtsStream(std::move(receiver));
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "chrome/browser/extensions/component_loader.h" #include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h" #include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h" #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "base/check.h" #include "base/check.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "chrome/browser/chromeos/service_sandbox_type.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -21,9 +22,6 @@ ...@@ -21,9 +22,6 @@
#include "extensions/browser/event_router_factory.h" #include "extensions/browser/event_router_factory.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/service_sandbox_type.h"
namespace { namespace {
void UpdateGoogleSpeechSynthesisKeepAliveCountHelper( void UpdateGoogleSpeechSynthesisKeepAliveCountHelper(
...@@ -77,32 +75,32 @@ void UpdateGoogleSpeechSynthesisKeepAliveCountOnReload( ...@@ -77,32 +75,32 @@ void UpdateGoogleSpeechSynthesisKeepAliveCountOnReload(
} }
} // namespace } // namespace
#endif // defined(OS_CHROMEOS)
// Factory to load one instance of TtsExtensionLoaderChromeOs per profile. // Factory to load one instance of TtsExtensionLoaderChromeOs per profile.
class TtsEngineExtensionObserverFactory class TtsEngineExtensionObserverChromeOSFactory
: public BrowserContextKeyedServiceFactory { : public BrowserContextKeyedServiceFactory {
public: public:
static TtsEngineExtensionObserver* GetForProfile(Profile* profile) { static TtsEngineExtensionObserverChromeOS* GetForProfile(Profile* profile) {
return static_cast<TtsEngineExtensionObserver*>( return static_cast<TtsEngineExtensionObserverChromeOS*>(
GetInstance()->GetServiceForBrowserContext(profile, true)); GetInstance()->GetServiceForBrowserContext(profile, true));
} }
static TtsEngineExtensionObserverFactory* GetInstance() { static TtsEngineExtensionObserverChromeOSFactory* GetInstance() {
return base::Singleton<TtsEngineExtensionObserverFactory>::get(); return base::Singleton<TtsEngineExtensionObserverChromeOSFactory>::get();
} }
private: private:
friend struct base::DefaultSingletonTraits<TtsEngineExtensionObserverFactory>; friend struct base::DefaultSingletonTraits<
TtsEngineExtensionObserverChromeOSFactory>;
TtsEngineExtensionObserverFactory() TtsEngineExtensionObserverChromeOSFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"TtsEngineExtensionObserver", "TtsEngineExtensionObserverChromeOS",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::EventRouterFactory::GetInstance()); DependsOn(extensions::EventRouterFactory::GetInstance());
} }
~TtsEngineExtensionObserverFactory() override {} ~TtsEngineExtensionObserverChromeOSFactory() override {}
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override { content::BrowserContext* context) const override {
...@@ -113,17 +111,19 @@ class TtsEngineExtensionObserverFactory ...@@ -113,17 +111,19 @@ class TtsEngineExtensionObserverFactory
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override { content::BrowserContext* profile) const override {
return new TtsEngineExtensionObserver(static_cast<Profile*>(profile)); return new TtsEngineExtensionObserverChromeOS(
static_cast<Profile*>(profile));
} }
}; };
TtsEngineExtensionObserver* TtsEngineExtensionObserver::GetInstance( TtsEngineExtensionObserverChromeOS*
Profile* profile) { TtsEngineExtensionObserverChromeOS::GetInstance(Profile* profile) {
return TtsEngineExtensionObserverFactory::GetInstance()->GetForProfile( return TtsEngineExtensionObserverChromeOSFactory::GetInstance()
profile); ->GetForProfile(profile);
} }
TtsEngineExtensionObserver::TtsEngineExtensionObserver(Profile* profile) TtsEngineExtensionObserverChromeOS::TtsEngineExtensionObserverChromeOS(
Profile* profile)
: extension_registry_observer_(this), profile_(profile) { : extension_registry_observer_(this), profile_(profile) {
extension_registry_observer_.Add( extension_registry_observer_.Add(
extensions::ExtensionRegistry::Get(profile_)); extensions::ExtensionRegistry::Get(profile_));
...@@ -134,23 +134,17 @@ TtsEngineExtensionObserver::TtsEngineExtensionObserver(Profile* profile) ...@@ -134,23 +134,17 @@ TtsEngineExtensionObserver::TtsEngineExtensionObserver(Profile* profile)
event_router->RegisterObserver(this, tts_engine_events::kOnSpeak); event_router->RegisterObserver(this, tts_engine_events::kOnSpeak);
event_router->RegisterObserver(this, tts_engine_events::kOnStop); event_router->RegisterObserver(this, tts_engine_events::kOnStop);
#if defined(OS_CHROMEOS)
accessibility_status_subscription_ = accessibility_status_subscription_ =
chromeos::AccessibilityManager::Get()->RegisterCallback( chromeos::AccessibilityManager::Get()->RegisterCallback(
base::BindRepeating( base::BindRepeating(
&TtsEngineExtensionObserver::OnAccessibilityStatusChanged, &TtsEngineExtensionObserverChromeOS::OnAccessibilityStatusChanged,
base::Unretained(this))); base::Unretained(this)));
#endif
} }
TtsEngineExtensionObserver::~TtsEngineExtensionObserver() = default; TtsEngineExtensionObserverChromeOS::~TtsEngineExtensionObserverChromeOS() =
default;
const std::set<std::string> TtsEngineExtensionObserver::GetTtsExtensions() {
return engine_extension_ids_;
}
#if defined(OS_CHROMEOS) void TtsEngineExtensionObserverChromeOS::BindTtsStream(
void TtsEngineExtensionObserver::BindTtsStream(
mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver) { mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver) {
// At this point, the component extension has loaded, and the js has requested // At this point, the component extension has loaded, and the js has requested
// a TtsStream be bound. It's safe now to update the keep alive count for // a TtsStream be bound. It's safe now to update the keep alive count for
...@@ -172,13 +166,12 @@ void TtsEngineExtensionObserver::BindTtsStream( ...@@ -172,13 +166,12 @@ void TtsEngineExtensionObserver::BindTtsStream(
content::GetAudioService().BindStreamFactory(std::move(factory_receiver)); content::GetAudioService().BindStreamFactory(std::move(factory_receiver));
tts_service_->BindTtsStream(std::move(receiver), std::move(factory_remote)); tts_service_->BindTtsStream(std::move(receiver), std::move(factory_remote));
} }
#endif // defined(OS_CHROMEOS)
void TtsEngineExtensionObserver::Shutdown() { void TtsEngineExtensionObserverChromeOS::Shutdown() {
extensions::EventRouter::Get(profile_)->UnregisterObserver(this); extensions::EventRouter::Get(profile_)->UnregisterObserver(this);
} }
bool TtsEngineExtensionObserver::IsLoadedTtsEngine( bool TtsEngineExtensionObserverChromeOS::IsLoadedTtsEngine(
const std::string& extension_id) { const std::string& extension_id) {
extensions::EventRouter* event_router = extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile_); extensions::EventRouter::Get(profile_);
...@@ -193,7 +186,7 @@ bool TtsEngineExtensionObserver::IsLoadedTtsEngine( ...@@ -193,7 +186,7 @@ bool TtsEngineExtensionObserver::IsLoadedTtsEngine(
return false; return false;
} }
void TtsEngineExtensionObserver::OnListenerAdded( void TtsEngineExtensionObserverChromeOS::OnListenerAdded(
const extensions::EventListenerInfo& details) { const extensions::EventListenerInfo& details) {
if (!IsLoadedTtsEngine(details.extension_id)) if (!IsLoadedTtsEngine(details.extension_id))
return; return;
...@@ -201,7 +194,7 @@ void TtsEngineExtensionObserver::OnListenerAdded( ...@@ -201,7 +194,7 @@ void TtsEngineExtensionObserver::OnListenerAdded(
content::TtsController::GetInstance()->VoicesChanged(); content::TtsController::GetInstance()->VoicesChanged();
} }
void TtsEngineExtensionObserver::OnExtensionLoaded( void TtsEngineExtensionObserverChromeOS::OnExtensionLoaded(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const extensions::Extension* extension) { const extensions::Extension* extension) {
if (extension->permissions_data()->HasAPIPermission( if (extension->permissions_data()->HasAPIPermission(
...@@ -210,7 +203,7 @@ void TtsEngineExtensionObserver::OnExtensionLoaded( ...@@ -210,7 +203,7 @@ void TtsEngineExtensionObserver::OnExtensionLoaded(
} }
} }
void TtsEngineExtensionObserver::OnExtensionUnloaded( void TtsEngineExtensionObserverChromeOS::OnExtensionUnloaded(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const extensions::Extension* extension, const extensions::Extension* extension,
extensions::UnloadedExtensionReason reason) { extensions::UnloadedExtensionReason reason) {
...@@ -219,15 +212,12 @@ void TtsEngineExtensionObserver::OnExtensionUnloaded( ...@@ -219,15 +212,12 @@ void TtsEngineExtensionObserver::OnExtensionUnloaded(
if (erase_count > 0) if (erase_count > 0)
content::TtsController::GetInstance()->VoicesChanged(); content::TtsController::GetInstance()->VoicesChanged();
#if defined(OS_CHROMEOS)
if (tts_service_ && if (tts_service_ &&
extension->id() == extension_misc::kGoogleSpeechSynthesisExtensionId) extension->id() == extension_misc::kGoogleSpeechSynthesisExtensionId)
tts_service_.reset(); tts_service_.reset();
#endif // defined(OS_CHROMEOS)
} }
#if defined(OS_CHROMEOS) void TtsEngineExtensionObserverChromeOS::OnAccessibilityStatusChanged(
void TtsEngineExtensionObserver::OnAccessibilityStatusChanged(
const chromeos::AccessibilityStatusEventDetails& details) { const chromeos::AccessibilityStatusEventDetails& details) {
if (details.notification_type != chromeos::AccessibilityNotificationType:: if (details.notification_type != chromeos::AccessibilityNotificationType::
ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK && ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK &&
...@@ -240,4 +230,3 @@ void TtsEngineExtensionObserver::OnAccessibilityStatusChanged( ...@@ -240,4 +230,3 @@ void TtsEngineExtensionObserver::OnAccessibilityStatusChanged(
// increment. Decrements only occur when toggling off here. // increment. Decrements only occur when toggling off here.
UpdateGoogleSpeechSynthesisKeepAliveCount(profile(), details.enabled); UpdateGoogleSpeechSynthesisKeepAliveCount(profile(), details.enabled);
} }
#endif
...@@ -2,42 +2,39 @@ ...@@ -2,42 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_CHROMEOS_H_
#define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_CHROMEOS_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chromeos/services/tts/public/mojom/tts_service.mojom.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/audio_service.h" #include "content/public/browser/audio_service.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_registry_observer.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chromeos/services/tts/public/mojom/tts_service.mojom.h"
#endif
class Profile; class Profile;
// Profile-keyed class that observes the extension registry to determine load of // Profile-keyed class that observes the extension registry to determine load of
// extension-based tts engines. // extension-based tts engines.
class TtsEngineExtensionObserver class TtsEngineExtensionObserverChromeOS
: public KeyedService, : public KeyedService,
public extensions::EventRouter::Observer, public extensions::EventRouter::Observer,
public extensions::ExtensionRegistryObserver { public extensions::ExtensionRegistryObserver {
public: public:
static TtsEngineExtensionObserver* GetInstance(Profile* profile); static TtsEngineExtensionObserverChromeOS* GetInstance(Profile* profile);
// Gets the currently loaded TTS extension ids. // Gets the currently loaded TTS extension ids.
const std::set<std::string> GetTtsExtensions(); const std::set<std::string>& engine_extension_ids() {
return engine_extension_ids_;
}
Profile* profile() { return profile_; } Profile* profile() { return profile_; }
#if defined(OS_CHROMEOS)
void BindTtsStream( void BindTtsStream(
mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver); mojo::PendingReceiver<chromeos::tts::mojom::TtsStream> receiver);
#endif // defined(OS_CHROMEOS)
// Implementation of KeyedService. // Implementation of KeyedService.
void Shutdown() override; void Shutdown() override;
...@@ -53,15 +50,13 @@ class TtsEngineExtensionObserver ...@@ -53,15 +50,13 @@ class TtsEngineExtensionObserver
extensions::UnloadedExtensionReason reason) override; extensions::UnloadedExtensionReason reason) override;
private: private:
explicit TtsEngineExtensionObserver(Profile* profile); explicit TtsEngineExtensionObserverChromeOS(Profile* profile);
~TtsEngineExtensionObserver() override; ~TtsEngineExtensionObserverChromeOS() override;
bool IsLoadedTtsEngine(const std::string& extension_id); bool IsLoadedTtsEngine(const std::string& extension_id);
#if defined(OS_CHROMEOS)
void OnAccessibilityStatusChanged( void OnAccessibilityStatusChanged(
const chromeos::AccessibilityStatusEventDetails& details); const chromeos::AccessibilityStatusEventDetails& details);
#endif
ScopedObserver<extensions::ExtensionRegistry, ScopedObserver<extensions::ExtensionRegistry,
extensions::ExtensionRegistryObserver> extensions::ExtensionRegistryObserver>
...@@ -71,16 +66,14 @@ class TtsEngineExtensionObserver ...@@ -71,16 +66,14 @@ class TtsEngineExtensionObserver
std::set<std::string> engine_extension_ids_; std::set<std::string> engine_extension_ids_;
#if defined(OS_CHROMEOS)
std::unique_ptr<chromeos::AccessibilityStatusSubscription> std::unique_ptr<chromeos::AccessibilityStatusSubscription>
accessibility_status_subscription_; accessibility_status_subscription_;
mojo::Remote<chromeos::tts::mojom::TtsService> tts_service_; mojo::Remote<chromeos::tts::mojom::TtsService> tts_service_;
#endif
friend class TtsEngineExtensionObserverFactory; friend class TtsEngineExtensionObserverChromeOSFactory;
DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver); DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserverChromeOS);
}; };
#endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_CHROMEOS_H_
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "content/public/browser/tts_controller.h" #include "content/public/browser/tts_controller.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
...@@ -24,6 +23,10 @@ ...@@ -24,6 +23,10 @@
#include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h" #include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#endif // defined(OS_CHROMEOS)
namespace constants = tts_extension_api_constants; namespace constants = tts_extension_api_constants;
namespace events { namespace events {
...@@ -349,8 +352,11 @@ TtsAPI::TtsAPI(content::BrowserContext* context) { ...@@ -349,8 +352,11 @@ TtsAPI::TtsAPI(content::BrowserContext* context) {
registry.RegisterFunction<TtsPauseFunction>(); registry.RegisterFunction<TtsPauseFunction>();
registry.RegisterFunction<TtsResumeFunction>(); registry.RegisterFunction<TtsResumeFunction>();
#if defined(OS_CHROMEOS)
// Ensure we're observing newly added engines for the given context. // Ensure we're observing newly added engines for the given context.
TtsEngineExtensionObserver::GetInstance(Profile::FromBrowserContext(context)); TtsEngineExtensionObserverChromeOS::GetInstance(
Profile::FromBrowserContext(context));
#endif // defined(OS_CHROMEOS)
} }
TtsAPI::~TtsAPI() { TtsAPI::~TtsAPI() {
......
...@@ -2541,10 +2541,10 @@ static_library("ui") { ...@@ -2541,10 +2541,10 @@ static_library("ui") {
"webui/settings/chromeos/settings_user_action_tracker.h", "webui/settings/chromeos/settings_user_action_tracker.h",
"webui/settings/chromeos/switch_access_handler.cc", "webui/settings/chromeos/switch_access_handler.cc",
"webui/settings/chromeos/switch_access_handler.h", "webui/settings/chromeos/switch_access_handler.h",
"webui/settings/chromeos/tts_handler.cc",
"webui/settings/chromeos/tts_handler.h",
"webui/settings/chromeos/wallpaper_handler.cc", "webui/settings/chromeos/wallpaper_handler.cc",
"webui/settings/chromeos/wallpaper_handler.h", "webui/settings/chromeos/wallpaper_handler.h",
"webui/settings/tts_handler.cc",
"webui/settings/tts_handler.h",
"webui/signin/inline_login_dialog_chromeos.cc", "webui/signin/inline_login_dialog_chromeos.cc",
"webui/signin/inline_login_dialog_chromeos.h", "webui/signin/inline_login_dialog_chromeos.h",
"webui/signin/inline_login_dialog_chromeos_onboarding.cc", "webui/signin/inline_login_dialog_chromeos_onboarding.cc",
......
...@@ -13,15 +13,15 @@ ...@@ -13,15 +13,15 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "chrome/browser/accessibility/accessibility_state_utils.h" #include "chrome/browser/accessibility/accessibility_state_utils.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h" #include "chrome/browser/ui/webui/settings/accessibility_main_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/captions_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/captions_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h" #include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/tts_handler.h"
#include "chrome/browser/ui/webui/settings/font_handler.h" #include "chrome/browser/ui/webui/settings/font_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h" #include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/tts_handler.h"
#include "chrome/browser/ui/webui/webui_util.h" #include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -756,8 +756,9 @@ void AccessibilitySection::UpdateTextToSpeechEnginesSearchTags() { ...@@ -756,8 +756,9 @@ void AccessibilitySection::UpdateTextToSpeechEnginesSearchTags() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetTextToSpeechEnginesSearchConcepts()); updater.RemoveSearchTags(GetTextToSpeechEnginesSearchConcepts());
const std::set<std::string> extensions = const std::set<std::string>& extensions =
TtsEngineExtensionObserver::GetInstance(profile())->GetTtsExtensions(); TtsEngineExtensionObserverChromeOS::GetInstance(profile())
->engine_extension_ids();
if (!extensions.empty()) { if (!extensions.empty()) {
updater.AddSearchTags(GetTextToSpeechEnginesSearchConcepts()); updater.AddSearchTags(GetTextToSpeechEnginesSearchConcepts());
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/webui/settings/tts_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/tts_handler.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -45,7 +45,8 @@ void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) { ...@@ -45,7 +45,8 @@ void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) {
extensions::ExtensionRegistry::Get(profile); extensions::ExtensionRegistry::Get(profile);
const std::set<std::string> extensions = const std::set<std::string> extensions =
TtsEngineExtensionObserver::GetInstance(profile)->GetTtsExtensions(); TtsEngineExtensionObserverChromeOS::GetInstance(profile)
->engine_extension_ids();
std::set<std::string>::const_iterator iter; std::set<std::string>::const_iterator iter;
for (iter = extensions.begin(); iter != extensions.end(); ++iter) { for (iter = extensions.begin(); iter != extensions.end(); ++iter) {
const std::string extension_id = *iter; const std::string extension_id = *iter;
......
...@@ -2,15 +2,13 @@ ...@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_ #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_TTS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_TTS_HANDLER_H_
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "content/public/browser/tts_controller.h" #include "content/public/browser/tts_controller.h"
class Profile;
namespace settings { namespace settings {
// Chrome "/manageAccessibility/tts/*" settings page UI handler. // Chrome "/manageAccessibility/tts/*" settings page UI handler.
...@@ -54,4 +52,4 @@ class TtsHandler : public SettingsPageUIHandler, ...@@ -54,4 +52,4 @@ class TtsHandler : public SettingsPageUIHandler,
} // namespace settings } // namespace settings
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_ #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_TTS_HANDLER_H_
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