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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java

Issue 2828353002: Android: Remove GetApplicationContext part 3 (Closed)
Patch Set: Fix android webview 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: content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
index 41b253e8f46ee1f7bc53d3704e0cfe97ac003162..7ddb2bce5b2af36e62bb055c8f4b41e136a2902a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
+++ b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
@@ -17,6 +17,7 @@ import android.speech.RecognitionService;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
+import org.chromium.base.ContextUtils;
import org.chromium.base.PackageUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -50,7 +51,6 @@ public class SpeechRecognition {
// PROVIDER_MIN_VERSION as selected by initialize().
private static ComponentName sRecognitionProvider;
- private final Context mContext;
private final Intent mIntent;
private final RecognitionListener mListener;
private SpeechRecognizer mRecognizer;
@@ -188,8 +188,10 @@ public class SpeechRecognition {
if (!service.packageName.equals(PROVIDER_PACKAGE_NAME)) continue;
- if (PackageUtils.getPackageVersion(context, service.packageName) < PROVIDER_MIN_VERSION)
+ if (PackageUtils.getPackageVersion(context, service.packageName)
+ < PROVIDER_MIN_VERSION) {
continue;
+ }
sRecognitionProvider = new ComponentName(service.packageName, service.name);
@@ -200,21 +202,22 @@ public class SpeechRecognition {
return false;
}
- private SpeechRecognition(final Context context, long nativeSpeechRecognizerImplAndroid) {
- mContext = context;
+ private SpeechRecognition(long nativeSpeechRecognizerImplAndroid) {
mContinuous = false;
mNativeSpeechRecognizerImplAndroid = nativeSpeechRecognizerImplAndroid;
mListener = new Listener();
mIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
if (sRecognitionProvider != null) {
- mRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext, sRecognitionProvider);
+ mRecognizer = SpeechRecognizer.createSpeechRecognizer(
+ ContextUtils.getApplicationContext(), sRecognitionProvider);
} else {
// It is possible to force-enable the speech recognition web platform feature (using a
// command-line flag) even if initialize() failed to find the PROVIDER_PACKAGE_NAME
// provider, in which case the first available speech recognition provider is used.
// Caveat: Continuous mode may not work as expected with a different provider.
- mRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext);
+ mRecognizer =
+ SpeechRecognizer.createSpeechRecognizer(ContextUtils.getApplicationContext());
}
mRecognizer.setRecognitionListener(mListener);
@@ -244,8 +247,8 @@ public class SpeechRecognition {
@CalledByNative
private static SpeechRecognition createSpeechRecognition(
- Context context, long nativeSpeechRecognizerImplAndroid) {
- return new SpeechRecognition(context, nativeSpeechRecognizerImplAndroid);
+ long nativeSpeechRecognizerImplAndroid) {
+ return new SpeechRecognition(nativeSpeechRecognizerImplAndroid);
}
@CalledByNative

Powered by Google App Engine
This is Rietveld 408576698