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

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

Issue 1353393002: Mask the AccountManager{Future,Callback} with a simple Callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rmcas
Patch Set: fix test. move background task to where it is required. Created 5 years, 2 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/ChildAccountInfoFetcher.java
diff --git a/components/signin/core/browser/android/java/src/org/chromium/components/signin/ChildAccountInfoFetcher.java b/components/signin/core/browser/android/java/src/org/chromium/components/signin/ChildAccountInfoFetcher.java
index d2fe99182669b9c30729fd0c79d0714ee6196af2..db155bcdebd46b07011c18360422dd2aed40bf03 100644
--- a/components/signin/core/browser/android/java/src/org/chromium/components/signin/ChildAccountInfoFetcher.java
+++ b/components/signin/core/browser/android/java/src/org/chromium/components/signin/ChildAccountInfoFetcher.java
@@ -5,19 +5,13 @@
package org.chromium.components.signin;
import android.accounts.Account;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
import android.content.Context;
import org.chromium.base.ApplicationStatus;
-import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
+import org.chromium.sync.signin.AccountManagerDelegate.Callback;
import org.chromium.sync.signin.AccountManagerHelper;
-import java.io.IOException;
-
/**
* ChildAccountInfoFetcher for the Android platform.
* Checks whether an account is a child account from the AccountManager.
@@ -35,30 +29,11 @@ public final class ChildAccountInfoFetcher {
Context app = ApplicationStatus.getApplicationContext();
assert app != null;
AccountManagerHelper helper = AccountManagerHelper.get(app);
- Account[] accounts = helper.getGoogleAccounts();
- Account candidate_account = null;
- for (Account account : accounts) {
- if (account.name.equals(accountName)) {
- candidate_account = account;
- break;
- }
- }
- if (candidate_account == null) {
- nativeSetIsChildAccount(nativeAccountFetcherService, accountId, false);
- return;
- }
- helper.checkChildAccount(candidate_account, new AccountManagerCallback<Boolean>() {
+ Account account = helper.createAccountFromName(accountName);
+ helper.checkChildAccount(account, new Callback<Boolean>() {
@Override
- public void run(AccountManagerFuture<Boolean> future) {
- assert future.isDone();
- try {
- boolean isChildAccount = future.getResult();
- nativeSetIsChildAccount(nativeAccountFetcherService, accountId, isChildAccount);
- } catch (AuthenticatorException | IOException e) {
- Log.e(TAG, "Error while fetching child account info: ", e);
- } catch (OperationCanceledException e) {
- Log.e(TAG, "Child account info fetch was cancelled. This should not happen.");
- }
+ public void gotResult(Boolean isChildAccount) {
+ nativeSetIsChildAccount(nativeAccountFetcherService, accountId, isChildAccount);
}
});
}

Powered by Google App Engine
This is Rietveld 408576698