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

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

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

Powered by Google App Engine
This is Rietveld 408576698