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

Side by Side Diff: chrome/browser/speech/tts_android.cc

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698