190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/android/jni_android.h" 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/android/scoped_java_ref.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/speech/tts_platform.h" 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class TtsPlatformImplAndroid : public TtsPlatformImpl { 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) public: 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // TtsPlatformImpl implementation. 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool PlatformImplAvailable() OVERRIDE; 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool Speak( 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int utterance_id, 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string& utterance, 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string& lang, 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const VoiceData& voice, 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const UtteranceContinuousParameters& params) OVERRIDE; 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool StopSpeaking() OVERRIDE; 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void Pause() OVERRIDE; 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void Resume() OVERRIDE; 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool IsSpeaking() OVERRIDE; 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE; 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Methods called from Java via JNI. 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void VoicesChanged(JNIEnv* env, jobject obj); 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void OnEndEvent(JNIEnv* env, jobject obj, jint utterance_id); 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void OnErrorEvent(JNIEnv* env, jobject obj, jint utterance_id); 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void OnStartEvent(JNIEnv* env, jobject obj, jint utterance_id); 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Static functions. 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static TtsPlatformImplAndroid* GetInstance(); 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static bool Register(JNIEnv* env); 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private: 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) friend struct DefaultSingletonTraits<TtsPlatformImplAndroid>; 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) TtsPlatformImplAndroid(); 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual ~TtsPlatformImplAndroid(); 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void SendFinalTtsEvent( 4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int utterance_id, TtsEventType event_type, int char_index); 4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::android::ScopedJavaGlobalRef<jobject> java_ref_; 4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int utterance_id_; 4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string utterance_; 5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplAndroid); 5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // CHROME_BROWSER_SPEECH_TTS_ANDROID_H_ 55