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

Unified Diff: components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java

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 side-by-side diff with in-line comments
Download patch
Index: components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
diff --git a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
index ba1b73d088cd614c503c0561950e6f6a9f3efbce..b55c2a9c08e8aec27f3dabe00a82ae0e2e606f6b 100644
--- a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
+++ b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
@@ -13,6 +13,7 @@
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
+import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
@@ -25,7 +26,6 @@
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
-import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.MainDex;
@@ -42,10 +42,12 @@
@MainDex
public class SystemAccountManagerDelegate implements AccountManagerDelegate {
private final AccountManager mAccountManager;
+ private final Context mApplicationContext;
private static final String TAG = "Auth";
- public SystemAccountManagerDelegate() {
- mAccountManager = AccountManager.get(ContextUtils.getApplicationContext());
+ public SystemAccountManagerDelegate(Context context) {
+ mApplicationContext = context.getApplicationContext();
+ mAccountManager = AccountManager.get(context.getApplicationContext());
}
@Override
@@ -66,7 +68,7 @@
assert AccountManagerHelper.GOOGLE_ACCOUNT_TYPE.equals(account.type);
try {
return GoogleAuthUtil.getTokenWithNotification(
- ContextUtils.getApplicationContext(), account, authTokenScope, null);
+ mApplicationContext, account, authTokenScope, null);
} catch (GoogleAuthException ex) {
// This case includes a UserRecoverableNotifiedException, but most clients will have
// their own retry mechanism anyway.
@@ -80,7 +82,7 @@
@Override
public void invalidateAuthToken(String authToken) throws AuthException {
try {
- GoogleAuthUtil.clearToken(ContextUtils.getApplicationContext(), authToken);
+ GoogleAuthUtil.clearToken(mApplicationContext, authToken);
} catch (GooglePlayServicesAvailabilityException ex) {
throw new AuthException(false /* isTransientError */, ex);
} catch (GoogleAuthException ex) {
@@ -164,7 +166,7 @@
}
protected boolean hasGetAccountsPermission() {
- return ApiCompatibilityUtils.checkPermission(ContextUtils.getApplicationContext(),
+ return ApiCompatibilityUtils.checkPermission(mApplicationContext,
Manifest.permission.GET_ACCOUNTS, Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_GRANTED;
}
@@ -173,7 +175,7 @@
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return true;
}
- return ApiCompatibilityUtils.checkPermission(ContextUtils.getApplicationContext(),
+ return ApiCompatibilityUtils.checkPermission(mApplicationContext,
"android.permission.MANAGE_ACCOUNTS", Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_GRANTED;
}

Powered by Google App Engine
This is Rietveld 408576698