Chromium Code Reviews| Index: chrome/browser/speech/tts_android.cc |
| diff --git a/chrome/browser/speech/tts_android.cc b/chrome/browser/speech/tts_android.cc |
| index bcc501c302ec72ddf3e312b0340a35101d9bbae3..8cb56f2bae870cdac35c92d61341f7adc5f0f840 100644 |
| --- a/chrome/browser/speech/tts_android.cc |
| +++ b/chrome/browser/speech/tts_android.cc |
| @@ -10,7 +10,10 @@ |
| #include "base/memory/singleton.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/speech/tts_controller.h" |
| + |
| +#if defined(ANDROID_JAVA_UI) |
|
Ted C
2015/11/30 19:39:05
same comment as platform_util
no sievers
2015/11/30 23:56:34
I can revert these changes. The Java implementatio
|
| #include "jni/TtsPlatformImpl_jni.h" |
| +#endif |
| using base::android::AttachCurrentThread; |
| @@ -21,16 +24,20 @@ TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
| TtsPlatformImplAndroid::TtsPlatformImplAndroid() |
| : utterance_id_(0) { |
| +#if defined(ANDROID_JAVA_UI) |
| JNIEnv* env = AttachCurrentThread(); |
| java_ref_.Reset( |
| Java_TtsPlatformImpl_create(env, |
| reinterpret_cast<intptr_t>(this), |
| base::android::GetApplicationContext())); |
| +#endif |
| } |
| TtsPlatformImplAndroid::~TtsPlatformImplAndroid() { |
| +#if defined(ANDROID_JAVA_UI) |
| JNIEnv* env = AttachCurrentThread(); |
| Java_TtsPlatformImpl_destroy(env, java_ref_.obj()); |
| +#endif |
| } |
| bool TtsPlatformImplAndroid::PlatformImplAvailable() { |
| @@ -43,6 +50,7 @@ bool TtsPlatformImplAndroid::Speak( |
| const std::string& lang, |
| const VoiceData& voice, |
| const UtteranceContinuousParameters& params) { |
| +#if defined(ANDROID_JAVA_UI) |
| JNIEnv* env = AttachCurrentThread(); |
| jboolean success = Java_TtsPlatformImpl_speak( |
| env, java_ref_.obj(), utterance_id, |
| @@ -55,14 +63,23 @@ bool TtsPlatformImplAndroid::Speak( |
| utterance_ = utterance; |
| utterance_id_ = utterance_id; |
| return true; |
| +#else |
| + NOTIMPLEMENTED(); |
| + return false; |
| +#endif |
| } |
| bool TtsPlatformImplAndroid::StopSpeaking() { |
| +#if defined(ANDROID_JAVA_UI) |
| JNIEnv* env = AttachCurrentThread(); |
| Java_TtsPlatformImpl_stop(env, java_ref_.obj()); |
| utterance_id_ = 0; |
| utterance_.clear(); |
| return true; |
| +#else |
| + NOTIMPLEMENTED(); |
| + return false; |
| +#endif |
| } |
| void TtsPlatformImplAndroid::Pause() { |
| @@ -78,6 +95,7 @@ bool TtsPlatformImplAndroid::IsSpeaking() { |
| void TtsPlatformImplAndroid::GetVoices( |
| std::vector<VoiceData>* out_voices) { |
| +#if defined(ANDROID_JAVA_UI) |
| JNIEnv* env = AttachCurrentThread(); |
| if (!Java_TtsPlatformImpl_isInitialized(env, java_ref_.obj())) |
| return; |
| @@ -96,6 +114,7 @@ void TtsPlatformImplAndroid::GetVoices( |
| data.events.insert(TTS_EVENT_END); |
| data.events.insert(TTS_EVENT_ERROR); |
| } |
| +#endif |
| } |
| void TtsPlatformImplAndroid::VoicesChanged(JNIEnv* env, jobject obj) { |
| @@ -141,6 +160,8 @@ TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { |
| } |
| // static |
| +#if defined(ANDROID_JAVA_UI) |
| bool TtsPlatformImplAndroid::Register(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |
| +#endif |