Commit 65cef4ba authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Chromium LUCI CQ

Remove kGoogleServicesHostedDomain preference.

The hosted domain is already stored in the AccountInfo (managed by
the AccountTrackerService). This CL removes the preference
|kGoogleServicesHostedDomain| as it holds duplicated information.

Note: There is a slight change of behavior as
GaiaInfoUpdateService::UpdatePrimaryAccount may no longer be called
on start-up if the hosted domain is missing. This may lead to the
profile info cache not being updated if the application crashed after
the AccountInfo was stored on disk, but before the ProfileInfoCache was
stored on disk (in production code, this is impossible as the
GaiaInfoUpdateService updates the primary account information as soon
as AccountInfo is updated by the AccountTracker).

Bug: None

Change-Id: I6c7697d55528198a86f2a8a1612407c4f8807817
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617704Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Auto-Submit: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842250}
parent 2ba079bc
......@@ -523,6 +523,9 @@ const char kAssistantPrivacyInfoDismissedInLauncher[] =
const char kAssistantQuickAnswersEnabled[] =
"settings.voice_interaction.quick_answers.enabled";
// Deprecated 01/2021
const char kGoogleServicesHostedDomain[] = "google.services.hosted_domain";
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
......@@ -618,6 +621,8 @@ void RegisterProfilePrefsForMigration(
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
registry->RegisterBooleanPref(kAssistantQuickAnswersEnabled, true);
registry->RegisterStringPref(kGoogleServicesHostedDomain, std::string());
}
} // namespace
......@@ -1261,6 +1266,9 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 12/2020
profile_prefs->ClearPref(kAssistantQuickAnswersEnabled);
// Added 01/2021
profile_prefs->ClearPref(kGoogleServicesHostedDomain);
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
}
......@@ -37,12 +37,10 @@
GAIAInfoUpdateService::GAIAInfoUpdateService(
signin::IdentityManager* identity_manager,
ProfileAttributesStorage* profile_attributes_storage,
const base::FilePath& profile_path,
PrefService* profile_prefs)
const base::FilePath& profile_path)
: identity_manager_(identity_manager),
profile_attributes_storage_(profile_attributes_storage),
profile_path_(profile_path),
profile_prefs_(profile_prefs) {
profile_path_(profile_path) {
identity_manager_->AddObserver(this);
if (!ShouldUpdatePrimaryAccount()) {
......@@ -94,11 +92,7 @@ void GAIAInfoUpdateService::UpdatePrimaryAccount(const AccountInfo& info) {
gaia_id_of_profile_attribute_entry_ = info.gaia;
entry->SetGAIAGivenName(base::UTF8ToUTF16(info.given_name));
entry->SetGAIAName(base::UTF8ToUTF16(info.full_name));
entry->SetHostedDomain(info.hosted_domain);
const base::string16 hosted_domain = base::UTF8ToUTF16(info.hosted_domain);
profile_prefs_->SetString(prefs::kGoogleServicesHostedDomain,
base::UTF16ToUTF8(hosted_domain));
if (info.picture_url == kNoPictureURLFound) {
entry->SetGAIAPicture(std::string(), gfx::Image());
......@@ -147,8 +141,6 @@ void GAIAInfoUpdateService::ClearProfileEntry() {
entry->SetGAIAGivenName(base::string16());
entry->SetGAIAPicture(std::string(), gfx::Image());
entry->SetHostedDomain(std::string());
// Unset the cached URL.
profile_prefs_->ClearPref(prefs::kGoogleServicesHostedDomain);
}
void GAIAInfoUpdateService::Shutdown() {
......
......@@ -26,8 +26,7 @@ class GAIAInfoUpdateService : public KeyedService,
public:
GAIAInfoUpdateService(signin::IdentityManager* identity_manager,
ProfileAttributesStorage* profile_attributes_storage,
const base::FilePath& profile_path,
PrefService* prefs);
const base::FilePath& profile_path);
~GAIAInfoUpdateService() override;
......@@ -58,7 +57,6 @@ class GAIAInfoUpdateService : public KeyedService,
signin::IdentityManager* identity_manager_;
ProfileAttributesStorage* profile_attributes_storage_;
const base::FilePath profile_path_;
PrefService* profile_prefs_;
// TODO(msalama): remove when |SigninProfileAttributesUpdater| is folded into
// |GAIAInfoUpdateService|.
std::string gaia_id_of_profile_attribute_entry_;
......
......@@ -47,7 +47,7 @@ KeyedService* GAIAInfoUpdateServiceFactory::BuildServiceInstanceFor(
return new GAIAInfoUpdateService(
IdentityManagerFactory::GetForProfile(profile),
&g_browser_process->profile_manager()->GetProfileAttributesStorage(),
profile->GetPath(), profile->GetPrefs());
profile->GetPath());
}
bool GAIAInfoUpdateServiceFactory::ServiceIsNULLWhileTesting() const {
......
......@@ -88,7 +88,7 @@ class GAIAInfoUpdateServiceTestBase : public testing::Test {
service_.reset(new GAIAInfoUpdateService(
identity_test_env_.identity_manager(),
testing_profile_manager_.profile_attributes_storage(),
profile()->GetPath(), profile()->GetPrefs()));
profile()->GetPath()));
}
void TearDown() override {
......@@ -166,9 +166,6 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) {
EXPECT_EQ(entry->GetGAIAGivenName(), base::UTF8ToUTF16("Pat"));
EXPECT_EQ(entry->GetGAIAName(), base::UTF8ToUTF16("Pat Foo"));
EXPECT_EQ(entry->GetHostedDomain(), kNoHostedDomainFound);
EXPECT_EQ(
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain),
kNoHostedDomainFound);
gfx::Image gaia_picture = gfx::test::CreateImage(256, 256);
signin::SimulateAccountImageFetch(identity_test_env()->identity_manager(),
......@@ -183,10 +180,6 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) {
EXPECT_TRUE(entry->GetGAIAName().empty());
EXPECT_EQ(nullptr, entry->GetGAIAPicture());
EXPECT_TRUE(entry->GetHostedDomain().empty());
EXPECT_TRUE(profile()
->GetPrefs()
->GetString(prefs::kGoogleServicesHostedDomain)
.empty());
}
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
......@@ -229,9 +222,6 @@ TEST_F(GAIAInfoUpdateServiceDiceTest, RevokeSyncConsent) {
EXPECT_EQ(entry->GetGAIAGivenName(), base::UTF8ToUTF16("Pat"));
EXPECT_EQ(entry->GetGAIAName(), base::UTF8ToUTF16("Pat Foo"));
EXPECT_EQ(entry->GetHostedDomain(), kNoHostedDomainFound);
EXPECT_EQ(
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain),
kNoHostedDomainFound);
EXPECT_TRUE(gfx::test::AreImagesEqual(gaia_picture, entry->GetAvatarIcon()));
}
......@@ -253,9 +243,6 @@ TEST_F(GAIAInfoUpdateServiceTest, LogInLogOut) {
EXPECT_EQ(entry->GetGAIAGivenName(), base::UTF8ToUTF16("Pat"));
EXPECT_EQ(entry->GetGAIAName(), base::UTF8ToUTF16("Pat Foo"));
EXPECT_EQ(entry->GetHostedDomain(), kNoHostedDomainFound);
EXPECT_EQ(
profile()->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain),
kNoHostedDomainFound);
gfx::Image gaia_picture = gfx::test::CreateImage(256, 256);
signin::SimulateAccountImageFetch(identity_test_env()->identity_manager(),
......@@ -272,10 +259,6 @@ TEST_F(GAIAInfoUpdateServiceTest, LogInLogOut) {
EXPECT_TRUE(entry->GetGAIAName().empty());
EXPECT_EQ(nullptr, entry->GetGAIAPicture());
EXPECT_TRUE(entry->GetHostedDomain().empty());
EXPECT_TRUE(profile()
->GetPrefs()
->GetString(prefs::kGoogleServicesHostedDomain)
.empty());
}
TEST_F(GAIAInfoUpdateServiceTest, LogInLogOutLogIn) {
......
......@@ -1413,12 +1413,6 @@ void ProfileManager::DoFinalInitForServices(Profile* profile,
ChildAccountServiceFactory::GetForProfile(profile)->Init();
SupervisedUserServiceFactory::GetForProfile(profile)->Init();
#endif
#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
// If the lock enabled algorithm changed, update this profile's lock status.
// This depends on services which shouldn't be initialized until
// DoFinalInitForServices.
profiles::UpdateIsProfileLockEnabledIfNeeded(profile);
#endif
// Activate data reduction proxy. This creates a request context and makes a
// URL request to check if the data reduction proxy server is reachable.
......
......@@ -347,21 +347,16 @@ bool IsLockAvailable(Profile* profile) {
return false;
}
std::string hosted_domain = profile->GetPrefs()->
GetString(prefs::kGoogleServicesHostedDomain);
// TODO(mlerman): After one release remove any hosted_domain reference to the
// pref, since all users will have this in the AccountTrackerService.
if (hosted_domain.empty()) {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
base::Optional<AccountInfo> primary_account_info =
identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
identity_manager->GetPrimaryAccountInfo());
if (primary_account_info.has_value())
hosted_domain = primary_account_info.value().hosted_domain;
}
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
if (!identity_manager->HasPrimaryAccount())
return false;
base::Optional<AccountInfo> primary_account_info =
identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
identity_manager->GetPrimaryAccountInfo());
std::string hosted_domain = primary_account_info.has_value()
? primary_account_info.value().hosted_domain
: "";
// TODO(mlerman): Prohibit only users who authenticate using SAML. Until then,
// prohibited users who use hosted domains (aside from google.com).
......
......@@ -210,14 +210,6 @@ bool IsProfileLocked(const base::FilePath& profile_path) {
}
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void UpdateIsProfileLockEnabledIfNeeded(Profile* profile) {
if (!profile->GetPrefs()->GetString(prefs::kGoogleServicesHostedDomain).
empty())
return;
UpdateGaiaProfileInfoIfNeeded(profile);
}
void UpdateGaiaProfileInfoIfNeeded(Profile* profile) {
DCHECK(profile);
......
......@@ -92,10 +92,6 @@ bool IsGuestModeRequested(const base::CommandLine& command_line,
bool IsProfileLocked(const base::FilePath& profile_path);
#if !BUILDFLAG(IS_CHROMEOS_ASH)
// If the lock-enabled information for this profile is not up to date, starts
// an update for the Gaia profile info.
void UpdateIsProfileLockEnabledIfNeeded(Profile* profile);
// Starts an update for a new version of the Gaia profile picture and other
// profile info.
void UpdateGaiaProfileInfoIfNeeded(Profile* profile);
......
......@@ -47,8 +47,6 @@ PrimaryAccountManager::~PrimaryAccountManager() {
// static
void PrimaryAccountManager::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterStringPref(prefs::kGoogleServicesHostedDomain,
std::string());
registry->RegisterStringPref(prefs::kGoogleServicesLastAccountId,
std::string());
registry->RegisterStringPref(prefs::kGoogleServicesLastUsername,
......@@ -336,7 +334,6 @@ void PrimaryAccountManager::OnSignoutDecisionReached(
}
PrimaryAccountChangeEvent::State previous_state = GetPrimaryAccountState();
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesHostedDomain);
// Revoke all tokens before sending signed_out notification, because there
// may be components that don't listen for token service events when the
......
......@@ -49,10 +49,6 @@ const char kGoogleServicesAccountId[] = "google.services.account_id";
const char kGoogleServicesConsentedToSync[] =
"google.services.consented_to_sync";
// The profile's hosted domain; empty if unset; kNoHostedDomainFound if there
// is none.
const char kGoogleServicesHostedDomain[] = "google.services.hosted_domain";
// Similar to kGoogleServicesLastUsername, this is the corresponding version of
// kGoogleServicesAccountId that is not cleared on signout.
const char kGoogleServicesLastAccountId[] = "google.services.last_account_id";
......
......@@ -20,7 +20,6 @@ extern const char kGaiaCookieChangedTime[];
extern const char kGaiaCookiePeriodicReportTime[];
extern const char kGoogleServicesAccountId[];
extern const char kGoogleServicesConsentedToSync[];
extern const char kGoogleServicesHostedDomain[];
extern const char kGoogleServicesLastAccountId[];
extern const char kGoogleServicesLastUsername[];
extern const char kGoogleServicesSigninScopedDeviceId[];
......
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