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