Commit aec54d09 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Signin][Android] Minimize IdentityManager JNI interface

Reimplement GetPrimaryAccountId/HasPrimaryAccount in
IdentityManager.java as helpers on top of GetPrimaryAccountInfo instead
of standalone methods that are routed through JNI separately. This makes
the code more concise, facilitates mocking and simplifies future changes
to these methods.

Bug: 1046746
Change-Id: I8bfb715cb562b957849ca6e272a1731c17d98194
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026573
Commit-Queue: David Roger <droger@chromium.org>
Auto-Submit: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736771}
parent d52c1f13
...@@ -116,7 +116,7 @@ public class IdentityManager { ...@@ -116,7 +116,7 @@ public class IdentityManager {
* Returns whether the user's primary account is available. * Returns whether the user's primary account is available.
*/ */
public boolean hasPrimaryAccount() { public boolean hasPrimaryAccount() {
return IdentityManagerJni.get().hasPrimaryAccount(mNativeIdentityManager); return getPrimaryAccountInfo() != null;
} }
/** /**
...@@ -141,7 +141,8 @@ public class IdentityManager { ...@@ -141,7 +141,8 @@ public class IdentityManager {
* is available. * is available.
*/ */
public @Nullable CoreAccountId getPrimaryAccountId() { public @Nullable CoreAccountId getPrimaryAccountId() {
return IdentityManagerJni.get().getPrimaryAccountId(mNativeIdentityManager); CoreAccountInfo primaryAccountInfo = getPrimaryAccountInfo();
return primaryAccountInfo == null ? null : primaryAccountInfo.getId();
} }
/** /**
...@@ -225,8 +226,6 @@ public class IdentityManager { ...@@ -225,8 +226,6 @@ public class IdentityManager {
@NativeMethods @NativeMethods
interface Natives { interface Natives {
public @Nullable CoreAccountInfo getPrimaryAccountInfo(long nativeIdentityManager); public @Nullable CoreAccountInfo getPrimaryAccountInfo(long nativeIdentityManager);
public @Nullable CoreAccountId getPrimaryAccountId(long nativeIdentityManager);
public boolean hasPrimaryAccount(long nativeIdentityManager);
public @Nullable CoreAccountInfo public @Nullable CoreAccountInfo
findExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress( findExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress(
long nativeIdentityManager, String email); long nativeIdentityManager, String email);
......
...@@ -400,10 +400,6 @@ void IdentityManager::ForceRefreshOfExtendedAccountInfo( ...@@ -400,10 +400,6 @@ void IdentityManager::ForceRefreshOfExtendedAccountInfo(
account_fetcher_service_->ForceRefreshOfAccountInfo(account_id); account_fetcher_service_->ForceRefreshOfAccountInfo(account_id);
} }
bool IdentityManager::HasPrimaryAccount(JNIEnv* env) const {
return HasPrimaryAccount();
}
base::android::ScopedJavaLocalRef<jobject> base::android::ScopedJavaLocalRef<jobject>
IdentityManager::GetPrimaryAccountInfo(JNIEnv* env) const { IdentityManager::GetPrimaryAccountInfo(JNIEnv* env) const {
if (HasPrimaryAccount()) if (HasPrimaryAccount())
...@@ -411,13 +407,6 @@ IdentityManager::GetPrimaryAccountInfo(JNIEnv* env) const { ...@@ -411,13 +407,6 @@ IdentityManager::GetPrimaryAccountInfo(JNIEnv* env) const {
return nullptr; return nullptr;
} }
base::android::ScopedJavaLocalRef<jobject> IdentityManager::GetPrimaryAccountId(
JNIEnv* env) const {
if (HasPrimaryAccount())
return ConvertToJavaCoreAccountId(env, GetPrimaryAccountId());
return nullptr;
}
base::android::ScopedJavaLocalRef<jobject> IdentityManager:: base::android::ScopedJavaLocalRef<jobject> IdentityManager::
FindExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress( FindExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress(
JNIEnv* env, JNIEnv* env,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment