Commit ebda22fb authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Replace deprecated IdServicesProvider functions in firstrun classes.

This CL replaces deprecated functions of IdentityServicesProvider with
the newer service getters with profile parameter. Since first run flow
only run in regular mode, it is safe to pass always regular profile to
IdentityServicesProvider functions.

Note: This CL does not make any behaviour change.

Bug: 1041781, 1075562
Change-Id: Ibee67f4d13e364613ebd267c77ec2d5981b9458e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241545Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779826}
parent 1c332e27
...@@ -25,6 +25,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches; ...@@ -25,6 +25,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.locale.LocaleManager; import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager; import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.services.AndroidChildAccountHelper; import org.chromium.chrome.browser.services.AndroidChildAccountHelper;
import org.chromium.chrome.browser.signin.IdentityServicesProvider; import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
...@@ -93,12 +94,15 @@ public abstract class FirstRunFlowSequencer { ...@@ -93,12 +94,15 @@ public abstract class FirstRunFlowSequencer {
@VisibleForTesting @VisibleForTesting
protected boolean isSignedIn() { protected boolean isSignedIn() {
return IdentityServicesProvider.get().getIdentityManager().hasPrimaryAccount(); return IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.hasPrimaryAccount();
} }
@VisibleForTesting @VisibleForTesting
protected boolean isSyncAllowed() { protected boolean isSyncAllowed() {
SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(); SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
Profile.getLastUsedRegularProfile());
return FirstRunUtils.canAllowSync() && !signinManager.isSigninDisabledByPolicy() return FirstRunUtils.canAllowSync() && !signinManager.isSigninDisabledByPolicy()
&& signinManager.isSigninSupported(); && signinManager.isSigninSupported();
} }
......
...@@ -49,7 +49,8 @@ public final class FirstRunSignInProcessor { ...@@ -49,7 +49,8 @@ public final class FirstRunSignInProcessor {
* @param activity The context for the FRE parameters processor. * @param activity The context for the FRE parameters processor.
*/ */
public static void start(final Activity activity) { public static void start(final Activity activity) {
SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(); SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
Profile.getLastUsedRegularProfile());
signinManager.onFirstRunCheckDone(); signinManager.onFirstRunCheckDone();
// Skip signin if the first run flow is not complete. Examples of cases where the user // Skip signin if the first run flow is not complete. Examples of cases where the user
...@@ -187,7 +188,8 @@ public final class FirstRunSignInProcessor { ...@@ -187,7 +188,8 @@ public final class FirstRunSignInProcessor {
* Allows the user to sign-in if there are no pending FRE sign-in requests. * Allows the user to sign-in if there are no pending FRE sign-in requests.
*/ */
public static void updateSigninManagerFirstRunCheckDone() { public static void updateSigninManagerFirstRunCheckDone() {
SigninManager manager = IdentityServicesProvider.get().getSigninManager(); SigninManager manager = IdentityServicesProvider.get().getSigninManager(
Profile.getLastUsedRegularProfile());
if (manager.isSignInAllowed()) return; if (manager.isSignInAllowed()) return;
if (!FirstRunStatus.getFirstRunFlowComplete()) return; if (!FirstRunStatus.getFirstRunFlowComplete()) return;
if (!getFirstRunFlowSignInComplete()) return; if (!getFirstRunFlowSignInComplete()) return;
......
...@@ -11,6 +11,7 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -11,6 +11,7 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.SyncFirstSetupCompleteSource; import org.chromium.chrome.browser.SyncFirstSetupCompleteSource;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils; import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler; import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.services.AndroidChildAccountHelper; import org.chromium.chrome.browser.services.AndroidChildAccountHelper;
import org.chromium.chrome.browser.signin.IdentityServicesProvider; import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
...@@ -64,12 +65,15 @@ public final class ForcedSigninProcessor { ...@@ -64,12 +65,15 @@ public final class ForcedSigninProcessor {
*/ */
private static void processForcedSignIn(@Nullable final Runnable onComplete) { private static void processForcedSignIn(@Nullable final Runnable onComplete) {
if (FirstRunUtils.canAllowSync() if (FirstRunUtils.canAllowSync()
&& IdentityServicesProvider.get().getIdentityManager().hasPrimaryAccount()) { && IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.hasPrimaryAccount()) {
// TODO(https://crbug.com/1044206): Remove this. // TODO(https://crbug.com/1044206): Remove this.
ProfileSyncService.get().setFirstSetupComplete(SyncFirstSetupCompleteSource.BASIC_FLOW); ProfileSyncService.get().setFirstSetupComplete(SyncFirstSetupCompleteSource.BASIC_FLOW);
} }
final SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(); final SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
Profile.getLastUsedRegularProfile());
// By definition we have finished all the checks for first run. // By definition we have finished all the checks for first run.
signinManager.onFirstRunCheckDone(); signinManager.onFirstRunCheckDone();
if (!FirstRunUtils.canAllowSync() || !signinManager.isSignInAllowed()) { if (!FirstRunUtils.canAllowSync() || !signinManager.isSignInAllowed()) {
...@@ -111,7 +115,9 @@ public final class ForcedSigninProcessor { ...@@ -111,7 +115,9 @@ public final class ForcedSigninProcessor {
// TODO(bauerb): Once external dependencies reliably use policy to force sign-in, // TODO(bauerb): Once external dependencies reliably use policy to force sign-in,
// consider removing the child account. // consider removing the child account.
public static void checkCanSignIn(final ChromeActivity activity) { public static void checkCanSignIn(final ChromeActivity activity) {
if (IdentityServicesProvider.get().getSigninManager().isForceSigninEnabled()) { if (IdentityServicesProvider.get()
.getSigninManager(Profile.getLastUsedRegularProfile())
.isForceSigninEnabled()) {
ExternalAuthUtils.getInstance().canUseGooglePlayServices( ExternalAuthUtils.getInstance().canUseGooglePlayServices(
new UserRecoverableErrorHandler.ModalDialog(activity, false)); new UserRecoverableErrorHandler.ModalDialog(activity, false));
} }
......
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