OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ |
6 #define CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ | 6 #define CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "chrome/browser/speech/tts_platform.h" | 10 #include "chrome/browser/speech/tts_platform.h" |
| 11 #include "chrome/common/features.h" |
11 | 12 |
12 class TtsPlatformImplAndroid : public TtsPlatformImpl { | 13 class TtsPlatformImplAndroid : public TtsPlatformImpl { |
13 public: | 14 public: |
14 // TtsPlatformImpl implementation. | 15 // TtsPlatformImpl implementation. |
15 bool PlatformImplAvailable() override; | 16 bool PlatformImplAvailable() override; |
16 bool Speak(int utterance_id, | 17 bool Speak(int utterance_id, |
17 const std::string& utterance, | 18 const std::string& utterance, |
18 const std::string& lang, | 19 const std::string& lang, |
19 const VoiceData& voice, | 20 const VoiceData& voice, |
20 const UtteranceContinuousParameters& params) override; | 21 const UtteranceContinuousParameters& params) override; |
21 bool StopSpeaking() override; | 22 bool StopSpeaking() override; |
22 void Pause() override; | 23 void Pause() override; |
23 void Resume() override; | 24 void Resume() override; |
24 bool IsSpeaking() override; | 25 bool IsSpeaking() override; |
25 void GetVoices(std::vector<VoiceData>* out_voices) override; | 26 void GetVoices(std::vector<VoiceData>* out_voices) override; |
26 | 27 |
27 // Methods called from Java via JNI. | 28 // Methods called from Java via JNI. |
28 void VoicesChanged(JNIEnv* env, jobject obj); | 29 void VoicesChanged(JNIEnv* env, jobject obj); |
29 void OnEndEvent(JNIEnv* env, jobject obj, jint utterance_id); | 30 void OnEndEvent(JNIEnv* env, jobject obj, jint utterance_id); |
30 void OnErrorEvent(JNIEnv* env, jobject obj, jint utterance_id); | 31 void OnErrorEvent(JNIEnv* env, jobject obj, jint utterance_id); |
31 void OnStartEvent(JNIEnv* env, jobject obj, jint utterance_id); | 32 void OnStartEvent(JNIEnv* env, jobject obj, jint utterance_id); |
32 | 33 |
33 // Static functions. | 34 // Static functions. |
34 static TtsPlatformImplAndroid* GetInstance(); | 35 static TtsPlatformImplAndroid* GetInstance(); |
| 36 #if BUILDFLAG(ANDROID_JAVA_UI) |
35 static bool Register(JNIEnv* env); | 37 static bool Register(JNIEnv* env); |
| 38 #endif |
36 | 39 |
37 private: | 40 private: |
38 friend struct base::DefaultSingletonTraits<TtsPlatformImplAndroid>; | 41 friend struct base::DefaultSingletonTraits<TtsPlatformImplAndroid>; |
39 | 42 |
40 TtsPlatformImplAndroid(); | 43 TtsPlatformImplAndroid(); |
41 ~TtsPlatformImplAndroid() override; | 44 ~TtsPlatformImplAndroid() override; |
42 | 45 |
43 void SendFinalTtsEvent( | 46 void SendFinalTtsEvent( |
44 int utterance_id, TtsEventType event_type, int char_index); | 47 int utterance_id, TtsEventType event_type, int char_index); |
45 | 48 |
46 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 49 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
47 int utterance_id_; | 50 int utterance_id_; |
48 std::string utterance_; | 51 std::string utterance_; |
49 | 52 |
50 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplAndroid); | 53 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplAndroid); |
51 }; | 54 }; |
52 | 55 |
53 #endif // CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ | 56 #endif // CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ |
OLD | NEW |