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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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

Powered by Google App Engine
This is Rietveld 408576698