Commit 945828b6 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Convert signin_ui_util away from ProfileOAuth2TokenService

Replace usage of PO2TS APIs with calls to IdentityManager's methods.

Bug: 904412
Change-Id: I0543f8e4c78a5b19915933082f9f9074dcb4d7d8
Reviewed-on: https://chromium-review.googlesource.com/c/1338082Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#608424}
parent 2cdda48e
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_global_error.h" #include "chrome/browser/signin/signin_global_error.h"
#include "chrome/browser/signin/signin_global_error_factory.h" #include "chrome/browser/signin/signin_global_error_factory.h"
...@@ -28,11 +28,12 @@ ...@@ -28,11 +28,12 @@
#include "components/browser_sync/profile_sync_service.h" #include "components/browser_sync/profile_sync_service.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_consistency_method.h" #include "components/signin/core/browser/account_consistency_method.h"
#include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "third_party/re2/src/re2/re2.h" #include "third_party/re2/src/re2/re2.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/text_elider.h" #include "ui/gfx/text_elider.h"
...@@ -167,11 +168,12 @@ void EnableSyncFromPromo( ...@@ -167,11 +168,12 @@ void EnableSyncFromPromo(
? signin_metrics::PromoAction::PROMO_ACTION_WITH_DEFAULT ? signin_metrics::PromoAction::PROMO_ACTION_WITH_DEFAULT
: signin_metrics::PromoAction::PROMO_ACTION_NOT_DEFAULT; : signin_metrics::PromoAction::PROMO_ACTION_NOT_DEFAULT;
ProfileOAuth2TokenService* token_service = identity::IdentityManager* identity_manager =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile); IdentityManagerFactory::GetForProfile(profile);
bool needs_reauth_before_enable_sync = bool needs_reauth_before_enable_sync =
!token_service->RefreshTokenIsAvailable(account.account_id) || !identity_manager->HasAccountWithRefreshToken(account.account_id) ||
token_service->RefreshTokenHasError(account.account_id); identity_manager->HasAccountWithRefreshTokenInPersistentErrorState(
account.account_id);
if (needs_reauth_before_enable_sync) { if (needs_reauth_before_enable_sync) {
browser->signin_view_controller()->ShowDiceSigninTab( browser->signin_view_controller()->ShowDiceSigninTab(
profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser, access_point, profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser, access_point,
...@@ -209,9 +211,10 @@ std::string GetDisplayEmail(Profile* profile, const std::string& account_id) { ...@@ -209,9 +211,10 @@ std::string GetDisplayEmail(Profile* profile, const std::string& account_id) {
std::vector<AccountInfo> GetAccountsForDicePromos(Profile* profile) { std::vector<AccountInfo> GetAccountsForDicePromos(Profile* profile) {
// Fetch account ids for accounts that have a token. // Fetch account ids for accounts that have a token.
ProfileOAuth2TokenService* token_service = identity::IdentityManager* identity_manager =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile); IdentityManagerFactory::GetForProfile(profile);
std::vector<std::string> account_ids = token_service->GetAccounts(); std::vector<AccountInfo> accounts_with_tokens =
identity_manager->GetAccountsWithRefreshTokens();
// Compute the default account. // Compute the default account.
SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
...@@ -233,18 +236,13 @@ std::vector<AccountInfo> GetAccountsForDicePromos(Profile* profile) { ...@@ -233,18 +236,13 @@ std::vector<AccountInfo> GetAccountsForDicePromos(Profile* profile) {
// Fetch account information for each id and make sure that the first account // Fetch account information for each id and make sure that the first account
// in the list matches the first account in the Gaia cookies (if available). // in the list matches the first account in the Gaia cookies (if available).
AccountTrackerService* account_tracker_service =
AccountTrackerServiceFactory::GetForProfile(profile);
std::vector<AccountInfo> accounts; std::vector<AccountInfo> accounts;
for (const std::string& account_id : account_ids) { for (auto account_info : accounts_with_tokens) {
DCHECK(!account_id.empty()); DCHECK(!account_info.IsEmpty());
AccountInfo account_info = if (!signin_manager->IsAllowedUsername(account_info.email)) {
account_tracker_service->GetAccountInfo(account_id);
if (account_info.IsEmpty() ||
!signin_manager->IsAllowedUsername(account_info.email)) {
continue; continue;
} }
if (account_id == default_account_id) if (account_info.account_id == default_account_id)
accounts.insert(accounts.begin(), account_info); accounts.insert(accounts.begin(), account_info);
else else
accounts.push_back(account_info); accounts.push_back(account_info);
......
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