Commit cf88a217 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

[signin] Add logs to investigate why there is a mismatch in the list of accounts.

This CL adds the logs necessary to debug on Canary why there is a mismatch
in the list of accounts that leads to the Signin modal dialog being presented
on every start-up.

Bug: 1006717

Change-Id: Ic326d2166ef473a4f9922d8f1ee9221634fdbef2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817884Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698871}
parent 2a2cf70b
......@@ -315,6 +315,9 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
_browserLauncher.interfaceProvider.currentInterface.browserState;
if ([SignedInAccountsViewController
shouldBePresentedForBrowserState:currentBrowserState]) {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
[appNavigation presentSignedInAccountsViewControllerForBrowserState:
currentBrowserState];
}
......
......@@ -1092,6 +1092,9 @@ enum class EnterTabSwitcherSnapshotResult {
if ([SignedInAccountsViewController
shouldBePresentedForBrowserState:
[self currentBrowserState]]) {
// TODO(crbug.com/1006717): Remove these logs once
// bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
[self
presentSignedInAccountsViewControllerForBrowserState:
[self currentBrowserState]];
......@@ -1456,6 +1459,9 @@ enum class EnterTabSwitcherSnapshotResult {
// Show the sign-in promo if needed
if ([SigninPromoViewController
shouldBePresentedForBrowserState:_mainBrowserState]) {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
UIViewController* promoController = [[SigninPromoViewController alloc]
initWithBrowserState:_mainBrowserState
dispatcher:self.mainBVC.dispatcher];
......
......@@ -123,9 +123,15 @@ void AuthenticationService::Shutdown() {
}
void AuthenticationService::OnApplicationWillEnterForeground() {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d", __FUNCTION__, __LINE__);
if (identity_manager_observer_.IsObservingSources())
return;
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d", __FUNCTION__, __LINE__);
identity_manager_observer_.Add(identity_manager_);
// As the SSO library does not send notification when the app is in the
......@@ -165,9 +171,15 @@ void AuthenticationService::OnApplicationWillEnterForeground() {
}
void AuthenticationService::OnApplicationDidEnterBackground() {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
if (!identity_manager_observer_.IsObservingSources())
return;
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
// Stop observing |identity_manager_| when in the background. Note that
// this allows checking whether the app is in background without having a
// separate bool by using identity_manager_observer_.IsObservingSources().
......@@ -187,6 +199,9 @@ bool AuthenticationService::ShouldPromptForSignIn() const {
}
void AuthenticationService::ComputeHaveAccountsChanged(bool should_prompt) {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d", __FUNCTION__, __LINE__);
// Load accounts from preference before synchronizing the accounts with
// the system, otherwiser we would never detect any changes to the list
// of accounts.
......@@ -205,9 +220,29 @@ void AuthenticationService::ComputeHaveAccountsChanged(bool should_prompt) {
std::sort(new_accounts.begin(), new_accounts.end());
have_accounts_changed_ = old_accounts != new_accounts;
// Temporary log the lists of accounts used to compute
// |have_accounts_changed_|.
NSMutableArray* old_accounts_array =
[NSMutableArray arrayWithCapacity:old_accounts.size()];
for (const std::string& old_account : old_accounts)
[old_accounts_array addObject:base::SysUTF8ToNSString(old_account)];
NSMutableArray* new_accounts_array =
[NSMutableArray arrayWithCapacity:new_accounts.size()];
for (const std::string& new_account : new_accounts)
[new_accounts_array addObject:base::SysUTF8ToNSString(new_account)];
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d: have_accounts_changed = %s"
" [ old accounts = %@ ], [ new account = %@ ]",
__FUNCTION__, __LINE__, have_accounts_changed_ ? "true" : "false",
old_accounts_array, new_accounts_array);
}
bool AuthenticationService::HaveAccountsChanged() const {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d: have_accounts_changed = %s", __FUNCTION__, __LINE__,
have_accounts_changed_ ? "true" : "false");
return have_accounts_changed_;
}
......@@ -247,6 +282,17 @@ void AuthenticationService::StoreAccountsInPrefs() {
std::vector<base::Value> accounts_pref_value;
for (const CoreAccountInfo& account_info : accounts)
accounts_pref_value.emplace_back(account_info.account_id.id);
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSMutableArray* accounts_pref_value_array =
[NSMutableArray arrayWithCapacity:accounts_pref_value.size()];
for (const base::Value& account : accounts_pref_value) {
[accounts_pref_value_array
addObject:base::SysUTF8ToNSString(account.GetString())];
}
NSLog(@"%s %d: accounts = %@", __FUNCTION__, __LINE__,
accounts_pref_value_array);
pref_service_->Set(prefs::kSigninLastAccounts,
base::Value(std::move(accounts_pref_value)));
}
......
......@@ -199,9 +199,16 @@ BOOL gSignedInAccountsViewControllerIsShown = NO;
+ (BOOL)shouldBePresentedForBrowserState:
(ios::ChromeBrowserState*)browserState {
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
if (!browserState || browserState->IsOffTheRecord()) {
return NO;
}
// TODO(crbug.com/1006717): Remove these logs once bug 1006717 is fixed.
NSLog(@"%s %d:", __FUNCTION__, __LINE__);
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState);
return !gSignedInAccountsViewControllerIsShown &&
......
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