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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java

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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java
index 0c4d11442f901d1f4ccc5d9da628f6a4ba96f694..656bc341c327f8ad23dda3ec3ff51281ab1430d1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java
@@ -4,11 +4,11 @@
package org.chromium.chrome.browser;
-import android.content.Context;
import android.os.Build;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
+import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.annotations.CalledByNative;
@@ -68,39 +68,38 @@ class TtsPlatformImpl {
private String mCurrentLanguage;
private PendingUtterance mPendingUtterance;
- protected TtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context context) {
+ protected TtsPlatformImpl(long nativeTtsPlatformImplAndroid) {
mInitialized = false;
mNativeTtsPlatformImplAndroid = nativeTtsPlatformImplAndroid;
- mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
- @Override
- public void onInit(int status) {
- if (status == TextToSpeech.SUCCESS) {
- ThreadUtils.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- initialize();
- }
- });
+ mTextToSpeech = new TextToSpeech(
+ ContextUtils.getApplicationContext(), new TextToSpeech.OnInitListener() {
+ @Override
+ public void onInit(int status) {
+ if (status == TextToSpeech.SUCCESS) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ initialize();
+ }
+ });
+ }
}
- }
- });
+ });
addOnUtteranceProgressListener();
}
/**
* Create a TtsPlatformImpl object, which is owned by TtsPlatformImplAndroid
* on the C++ side.
+ * @param nativeTtsPlatformImplAndroid The C++ object that owns us.
*
- * @param nativeTtsPlatformImplAndroid The C++ object that owns us.
- * @param context The app context.
*/
@CalledByNative
- private static TtsPlatformImpl create(long nativeTtsPlatformImplAndroid,
- Context context) {
+ private static TtsPlatformImpl create(long nativeTtsPlatformImplAndroid) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- return new LollipopTtsPlatformImpl(nativeTtsPlatformImplAndroid, context);
+ return new LollipopTtsPlatformImpl(nativeTtsPlatformImplAndroid);
} else {
- return new TtsPlatformImpl(nativeTtsPlatformImplAndroid, context);
+ return new TtsPlatformImpl(nativeTtsPlatformImplAndroid);
}
}

Powered by Google App Engine
This is Rietveld 408576698