Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: chrome/browser/speech/tts_controller.cc

Issue 181123004: Eliminate the dependence of tts extension API for tts_controller.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile issue for mac. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/speech/tts_controller.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/tts_controller.cc
diff --git a/chrome/browser/speech/tts_controller.cc b/chrome/browser/speech/tts_controller.cc
index 6d749f3d9f7775a64258a518a8e3d48c2d2d59c0..75d75be4de30c7133b95e49bf05050cf3c50ebef 100644
--- a/chrome/browser/speech/tts_controller.cc
+++ b/chrome/browser/speech/tts_controller.cc
@@ -10,13 +10,7 @@
#include "base/float_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.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_extension_api.h"
#include "chrome/browser/speech/tts_platform.h"
-#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
namespace {
// A value to be used to indicate that there is no char index available.
@@ -120,7 +114,8 @@ TtsController* TtsController::GetInstance() {
TtsController::TtsController()
: current_utterance_(NULL),
paused_(false),
- platform_impl_(NULL) {
+ platform_impl_(NULL),
+ tts_engine_delegate_(NULL) {
}
TtsController::~TtsController() {
@@ -172,6 +167,9 @@ void TtsController::SpeakNow(Utterance* utterance) {
if (native_voices.empty() && !voices.empty()) {
// TODO(dtseng): Notify extension caller of an error.
utterance->set_voice_name("");
+ // TODO(gaochun): Replace the global variable g_browser_process with
+ // GetContentClient()->browser() to eliminate the dependency of browser
+ // once TTS implementation was moved to content.
utterance->set_lang(g_browser_process->GetApplicationLocale());
index = GetMatchingVoice(utterance, voices);
@@ -192,7 +190,8 @@ void TtsController::SpeakNow(Utterance* utterance) {
DCHECK(!voice.extension_id.empty());
current_utterance_ = utterance;
utterance->set_extension_id(voice.extension_id);
- ExtensionTtsEngineSpeak(utterance, voice);
+ if (tts_engine_delegate_)
+ tts_engine_delegate_->Speak(utterance, voice);
bool sends_end_event =
voice.events.find(TTS_EVENT_END) != voice.events.end();
if (!sends_end_event) {
@@ -237,7 +236,8 @@ void TtsController::Stop() {
paused_ = false;
if (current_utterance_ && !current_utterance_->extension_id().empty()) {
#if !defined(OS_ANDROID)
- ExtensionTtsEngineStop(current_utterance_);
+ if (tts_engine_delegate_)
+ tts_engine_delegate_->Stop(current_utterance_);
#endif
} else {
GetPlatformImpl()->clear_error();
@@ -255,7 +255,8 @@ void TtsController::Pause() {
paused_ = true;
if (current_utterance_ && !current_utterance_->extension_id().empty()) {
#if !defined(OS_ANDROID)
- ExtensionTtsEnginePause(current_utterance_);
+ if (tts_engine_delegate_)
+ tts_engine_delegate_->Pause(current_utterance_);
#endif
} else if (current_utterance_) {
GetPlatformImpl()->clear_error();
@@ -267,7 +268,8 @@ void TtsController::Resume() {
paused_ = false;
if (current_utterance_ && !current_utterance_->extension_id().empty()) {
#if !defined(OS_ANDROID)
- ExtensionTtsEngineResume(current_utterance_);
+ if (tts_engine_delegate_)
+ tts_engine_delegate_->Resume(current_utterance_);
#endif
} else if (current_utterance_) {
GetPlatformImpl()->clear_error();
@@ -298,8 +300,8 @@ void TtsController::OnTtsEvent(int utterance_id,
void TtsController::GetVoices(Profile* profile,
std::vector<VoiceData>* out_voices) {
#if !defined(OS_ANDROID)
- if (profile)
- GetExtensionVoices(profile, out_voices);
+ if (profile && tts_engine_delegate_)
+ tts_engine_delegate_->GetVoices(profile, out_voices);
#endif
TtsPlatformImpl* platform_impl = GetPlatformImpl();
@@ -441,3 +443,8 @@ void TtsController::RemoveVoicesChangedDelegate(
VoicesChangedDelegate* delegate) {
voices_changed_delegates_.erase(delegate);
}
+
+void TtsController::SetTtsEngineDelegate(
+ TtsEngineDelegate* delegate) {
+ tts_engine_delegate_ = delegate;
+}
« no previous file with comments | « chrome/browser/speech/tts_controller.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698