Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java |
index bd2fcefb860146f412713c3f80405c988f4f1af0..f18c5adb864ccd11d530e97cfdd6ef2956ed93e7 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java |
@@ -3,6 +3,8 @@ |
// found in the LICENSE file. |
package org.chromium.chrome.browser.ntp.snippets; |
+ |
+import android.content.Context; |
import com.google.android.gms.gcm.GcmNetworkManager; |
import com.google.android.gms.gcm.PeriodicTask; |
@@ -50,15 +52,16 @@ |
/** |
* Create a SnippetsLauncher object, which is owned by C++. |
+ * @param context The app context. |
*/ |
@VisibleForTesting |
@CalledByNative |
- public static SnippetsLauncher create() { |
+ public static SnippetsLauncher create(Context context) { |
if (sInstance != null) { |
throw new IllegalStateException("Already instantiated"); |
} |
- sInstance = new SnippetsLauncher(); |
+ sInstance = new SnippetsLauncher(context); |
return sInstance; |
} |
@@ -81,19 +84,19 @@ |
return sInstance != null; |
} |
- protected SnippetsLauncher() { |
- checkGCM(); |
- mScheduler = GcmNetworkManager.getInstance(ContextUtils.getApplicationContext()); |
+ protected SnippetsLauncher(Context context) { |
+ checkGCM(context); |
+ mScheduler = GcmNetworkManager.getInstance(context); |
} |
- private boolean canUseGooglePlayServices() { |
+ private boolean canUseGooglePlayServices(Context context) { |
return ExternalAuthUtils.getInstance().canUseGooglePlayServices( |
- ContextUtils.getApplicationContext(), new UserRecoverableErrorHandler.Silent()); |
+ context, new UserRecoverableErrorHandler.Silent()); |
} |
- private void checkGCM() { |
+ private void checkGCM(Context context) { |
// Check to see if Play Services is up to date, and disable GCM if not. |
- if (!canUseGooglePlayServices()) { |
+ if (!canUseGooglePlayServices(context)) { |
mGCMEnabled = false; |
Log.i(TAG, "Disabling SnippetsLauncher because Play Services is not up to date."); |
} |