| 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 #include "chrome/browser/speech/tts_android.h" | 5 #include "chrome/browser/speech/tts_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/speech/tts_controller.h" | 12 #include "chrome/browser/speech/tts_controller.h" |
| 13 #include "jni/TtsPlatformImpl_jni.h" | 13 #include "jni/TtsPlatformImpl_jni.h" |
| 14 | 14 |
| 15 using base::android::AttachCurrentThread; | 15 using base::android::AttachCurrentThread; |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { | 18 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
| 19 return TtsPlatformImplAndroid::GetInstance(); | 19 return TtsPlatformImplAndroid::GetInstance(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 TtsPlatformImplAndroid::TtsPlatformImplAndroid() | 22 TtsPlatformImplAndroid::TtsPlatformImplAndroid() |
| 23 : utterance_id_(0) { | 23 : utterance_id_(0) { |
| 24 JNIEnv* env = AttachCurrentThread(); | 24 JNIEnv* env = AttachCurrentThread(); |
| 25 java_ref_.Reset( | 25 java_ref_.Reset( |
| 26 Java_TtsPlatformImpl_create(env, | 26 Java_TtsPlatformImpl_create(env, |
| 27 reinterpret_cast<jint>(this), | 27 reinterpret_cast<intptr_t>(this), |
| 28 base::android::GetApplicationContext())); | 28 base::android::GetApplicationContext())); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TtsPlatformImplAndroid::~TtsPlatformImplAndroid() { | 31 TtsPlatformImplAndroid::~TtsPlatformImplAndroid() { |
| 32 JNIEnv* env = AttachCurrentThread(); | 32 JNIEnv* env = AttachCurrentThread(); |
| 33 Java_TtsPlatformImpl_destroy(env, java_ref_.obj()); | 33 Java_TtsPlatformImpl_destroy(env, java_ref_.obj()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool TtsPlatformImplAndroid::PlatformImplAvailable() { | 36 bool TtsPlatformImplAndroid::PlatformImplAvailable() { |
| 37 return true; | 37 return true; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // static | 140 // static |
| 141 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { | 141 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { |
| 142 return Singleton<TtsPlatformImplAndroid>::get(); | 142 return Singleton<TtsPlatformImplAndroid>::get(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 bool TtsPlatformImplAndroid::Register(JNIEnv* env) { | 146 bool TtsPlatformImplAndroid::Register(JNIEnv* env) { |
| 147 return RegisterNativesImpl(env); | 147 return RegisterNativesImpl(env); |
| 148 } | 148 } |
| OLD | NEW |