Commit 5099db59 authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Replace IdentityServicesProvider functions in history classes.

Fix for crrev.com/c/2242078 that is reverted here(crrev.com/c/2259150),
because of crbug.com/1098208.

This CL replaces deprecated functions of IdentityServicesProvider with
the newer service getters with profile parameter. Since
HistoryManager runs only in regular mode, this CL always pass
regular profile to IdentityServicesProvider. The code behaviour stays
same as today.

Bug: 1041781, 1075562
Change-Id: Ib1f32ca458c7d2243991d7b4f17af1c8f5c2f78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262952Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782931}
parent 1df00953
...@@ -196,7 +196,9 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ...@@ -196,7 +196,9 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
}}); }});
// 9. Listen to changes in sign in state. // 9. Listen to changes in sign in state.
IdentityServicesProvider.get().getSigninManager().addSignInStateObserver(this); IdentityServicesProvider.get()
.getSigninManager(Profile.getLastUsedRegularProfile())
.addSignInStateObserver(this);
// 10. Create PrefChangeRegistrar to receive notifications on preference changes. // 10. Create PrefChangeRegistrar to receive notifications on preference changes.
mPrefChangeRegistrar = new PrefChangeRegistrar(); mPrefChangeRegistrar = new PrefChangeRegistrar();
...@@ -293,7 +295,9 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ...@@ -293,7 +295,9 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
mHistoryAdapter.onDestroyed(); mHistoryAdapter.onDestroyed();
mLargeIconBridge.destroy(); mLargeIconBridge.destroy();
mLargeIconBridge = null; mLargeIconBridge = null;
IdentityServicesProvider.get().getSigninManager().removeSignInStateObserver(this); IdentityServicesProvider.get()
.getSigninManager(Profile.getLastUsedRegularProfile())
.removeSignInStateObserver(this);
mPrefChangeRegistrar.destroy(); mPrefChangeRegistrar.destroy();
} }
......
...@@ -566,9 +566,11 @@ public class HistoryActivityTest { ...@@ -566,9 +566,11 @@ public class HistoryActivityTest {
final Account account = final Account account =
mAccountManagerTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL); mAccountManagerTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
IdentityServicesProvider.get().getSigninManager().onFirstRunCheckDone(); Profile profile = Profile.getLastUsedRegularProfile();
IdentityServicesProvider.get().getSigninManager().addSignInStateObserver(mTestObserver); IdentityServicesProvider.get().getSigninManager(profile).onFirstRunCheckDone();
IdentityServicesProvider.get().getSigninManager().signIn( IdentityServicesProvider.get().getSigninManager(profile).addSignInStateObserver(
mTestObserver);
IdentityServicesProvider.get().getSigninManager(profile).signIn(
SigninAccessPoint.UNKNOWN, account, null); SigninAccessPoint.UNKNOWN, account, null);
}); });
...@@ -624,8 +626,9 @@ public class HistoryActivityTest { ...@@ -624,8 +626,9 @@ public class HistoryActivityTest {
int currentCallCount = mTestObserver.onSigninStateChangedCallback.getCallCount(); int currentCallCount = mTestObserver.onSigninStateChangedCallback.getCallCount();
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() ()
-> IdentityServicesProvider.get().getSigninManager().signOut( -> IdentityServicesProvider.get()
SignoutReason.SIGNOUT_TEST)); .getSigninManager(Profile.getLastUsedRegularProfile())
.signOut(SignoutReason.SIGNOUT_TEST));
mTestObserver.onSigninStateChangedCallback.waitForCallback(currentCallCount, 1); mTestObserver.onSigninStateChangedCallback.waitForCallback(currentCallCount, 1);
Assert.assertNull(mAccountManagerTestRule.getCurrentSignedInAccount()); Assert.assertNull(mAccountManagerTestRule.getCurrentSignedInAccount());
...@@ -633,7 +636,7 @@ public class HistoryActivityTest { ...@@ -633,7 +636,7 @@ public class HistoryActivityTest {
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() ()
-> IdentityServicesProvider.get() -> IdentityServicesProvider.get()
.getSigninManager() .getSigninManager(Profile.getLastUsedRegularProfile())
.removeSignInStateObserver(mTestObserver)); .removeSignInStateObserver(mTestObserver));
} }
} }
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