Commit 35c38c5d authored by Pâris MEULEMAN's avatar Pâris MEULEMAN Committed by Commit Bot

Add ExternalAuthUtils methods to SigninManagerDelegate

This CL extends the java |SigninManagerDelegate| interface and its
android implementation |ChromeSigninManagerDelegate| with
|isGooglePlayServicesMissing| and |canUseGooglePlayServices|, removing
|ExternalAuthUtils| and |UserRecoverableErrorHandler| dependencies from
|SigninManager|.

Bug: 963400
Change-Id: I5faadf64e9e1565ca3eb458ae02ed8085e1f17bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613085Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663017}
parent ed61be65
......@@ -4,8 +4,27 @@
package org.chromium.chrome.browser.signin;
import android.app.Activity;
import android.content.Context;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;
/**
* This implementation of {@link SigninManagerDelegate} provides {@link SigninManager} access to
* //chrome/browser level dependencies.
*/
public class ChromeSigninManagerDelegate implements SigninManagerDelegate {}
public class ChromeSigninManagerDelegate implements SigninManagerDelegate {
@Override
public void handleGooglePlayServicesUnavailability(Activity activity, boolean cancelable) {
UserRecoverableErrorHandler errorHandler = activity != null
? new UserRecoverableErrorHandler.ModalDialog(activity, cancelable)
: new UserRecoverableErrorHandler.SystemNotification();
ExternalAuthUtils.getInstance().canUseGooglePlayServices(errorHandler);
}
@Override
public boolean isGooglePlayServicesPresent(Context context) {
return !ExternalAuthUtils.getInstance().isGooglePlayServicesMissing(context);
}
}
......@@ -27,8 +27,6 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.task.PostTask;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;
import org.chromium.components.signin.AccountIdProvider;
import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.components.signin.AccountTrackerService;
......@@ -303,7 +301,7 @@ public class SigninManager implements AccountTrackerService.OnSystemAccountsSeed
*/
public boolean isSigninSupported() {
return !ApiCompatibilityUtils.isDemoUser(mContext)
&& !ExternalAuthUtils.getInstance().isGooglePlayServicesMissing(mContext);
&& mDelegate.isGooglePlayServicesPresent(mContext);
}
/**
......@@ -425,10 +423,7 @@ public class SigninManager implements AccountTrackerService.OnSystemAccountsSeed
mSignInState.mBlockedOnAccountSeeding = true;
} else {
Activity activity = mSignInState.mActivity;
UserRecoverableErrorHandler errorHandler = activity != null
? new UserRecoverableErrorHandler.ModalDialog(activity, !isForceSigninEnabled())
: new UserRecoverableErrorHandler.SystemNotification();
ExternalAuthUtils.getInstance().canUseGooglePlayServices(errorHandler);
mDelegate.handleGooglePlayServicesUnavailability(activity, !isForceSigninEnabled());
Log.w(TAG, "Cancelling the sign-in process as Google Play services is unavailable");
abortSignIn();
}
......
......@@ -4,9 +4,25 @@
package org.chromium.chrome.browser.signin;
import android.app.Activity;
import android.content.Context;
/**
* Interface providing SigninManager access to dependencies that are not part of the SignIn
* component. This interface interacts with //chrome features such as Policy, Sync, data wiping,
* Google Play services.
*/
public interface SigninManagerDelegate {}
public interface SigninManagerDelegate {
/**
* If there is no Google Play Services available, ask the user to fix by showing either a
* notification or a modal dialog
* @param activity The activity used to open the dialog, or null to use notifications
* @param cancelable Whether the dialog can be canceled
*/
public void handleGooglePlayServicesUnavailability(Activity activity, boolean cancelable);
/**
* @return Whether the device has Google Play Services.
*/
public boolean isGooglePlayServicesPresent(Context context);
}
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