Commit 7e164ff3 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

Fix ShouldShowCookieException method

This a follow up to crrev.com/c/1251627.

The method for showing the cookie exception
for signed-in and syncing users has been
corrected.

The problem was that, when Dice is enabled and
the user signs into Gmail, they are also signed
into Chrome, so the signed-in/syncing message was
shown even though the user is not syncing.

Screenshot before:
https://drive.google.com/file/d/117tFXEA7WaokpHlghypqWGL3fTQMpC6n/view?usp=sharing
Screenshot after:
https://drive.google.com/file/d/188Pu7XAHUJm39fpzY9lNqD6CgQAVi24I/view?usp=sharing

Bug: 889137
Change-Id: I60ab697e4774842258dfc47ba6a53a2b34765650
Reviewed-on: https://chromium-review.googlesource.com/1256944
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595846}
parent 0b8f4b54
......@@ -28,6 +28,11 @@
#include "chrome/browser/browsing_data/counters/hosted_apps_counter.h"
#endif
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
#endif
// A helper function to display the size of cache in units of MB or higher.
// We need this, as 1 MB is the lowest nonzero cache size displayed by the
// counter.
......@@ -45,16 +50,14 @@ bool ShouldShowCookieException(Profile* profile) {
auto* signin_manager = SigninManagerFactory::GetForProfile(profile);
return signin_manager->IsAuthenticated();
}
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
if (AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) {
auto* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
std::vector<std::string> accounts = token_service->GetAccounts();
bool has_valid_token = std::any_of(
accounts.begin(), accounts.end(), [&](std::string account_id) {
return !token_service->RefreshTokenHasError(account_id);
});
return has_valid_token;
sync_ui_util::MessageType sync_status = sync_ui_util::GetStatus(
profile, ProfileSyncServiceFactory::GetForProfile(profile),
*SigninManagerFactory::GetForProfile(profile));
return sync_status == sync_ui_util::SYNCED;
}
#endif
return 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