Commit 02f680ec authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Cleanup AccountConsistencyModeManager pref registration

Before this CL, the AccountConsistency preferences were registered in
ChromeSigninClientFactory, which is not the right place.
This CL moves the registration to the
AccountConsistencyModeManagerFactory.

This requires splitting the AccountConsistencyModeManagerFactory
in its own file, so that it can be registered correctly in
chrome_browser_main_extra_parts_profiles.cc

Change-Id: I0d0dc59796c96d8e48d31a244e59bfe1eb01e334
Reviewed-on: https://chromium-review.googlesource.com/c/1355167Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612649}
parent 6658de10
...@@ -1414,6 +1414,8 @@ jumbo_split_static_library("browser") { ...@@ -1414,6 +1414,8 @@ jumbo_split_static_library("browser") {
"signin/about_signin_internals_factory.h", "signin/about_signin_internals_factory.h",
"signin/account_consistency_mode_manager.cc", "signin/account_consistency_mode_manager.cc",
"signin/account_consistency_mode_manager.h", "signin/account_consistency_mode_manager.h",
"signin/account_consistency_mode_manager_factory.cc",
"signin/account_consistency_mode_manager_factory.h",
"signin/account_fetcher_service_factory.cc", "signin/account_fetcher_service_factory.cc",
"signin/account_fetcher_service_factory.h", "signin/account_fetcher_service_factory.h",
"signin/account_investigator_factory.cc", "signin/account_investigator_factory.cc",
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/signin/about_signin_internals_factory.h" #include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/account_consistency_mode_manager_factory.h"
#include "chrome/browser/signin/account_fetcher_service_factory.h" #include "chrome/browser/signin/account_fetcher_service_factory.h"
#include "chrome/browser/signin/account_investigator_factory.h" #include "chrome/browser/signin/account_investigator_factory.h"
#include "chrome/browser/signin/account_reconcilor_factory.h" #include "chrome/browser/signin/account_reconcilor_factory.h"
...@@ -218,6 +219,7 @@ void ChromeBrowserMainExtraPartsProfiles:: ...@@ -218,6 +219,7 @@ void ChromeBrowserMainExtraPartsProfiles::
} }
#endif #endif
AboutSigninInternalsFactory::GetInstance(); AboutSigninInternalsFactory::GetInstance();
AccountConsistencyModeManagerFactory::GetInstance();
AccountFetcherServiceFactory::GetInstance(); AccountFetcherServiceFactory::GetInstance();
AccountInvestigatorFactory::GetInstance(); AccountInvestigatorFactory::GetInstance();
AccountReconcilorFactory::GetInstance(); AccountReconcilorFactory::GetInstance();
......
...@@ -8,20 +8,16 @@ ...@@ -8,20 +8,16 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_consistency_mode_manager_factory.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_buildflags.h" #include "components/signin/core/browser/signin_buildflags.h"
#include "components/signin/core/browser/signin_pref_names.h" #include "components/signin/core/browser/signin_pref_names.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/google_api_keys.h" #include "google_apis/google_api_keys.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -63,40 +59,6 @@ enum class DiceMigrationStatus { ...@@ -63,40 +59,6 @@ enum class DiceMigrationStatus {
}; };
#endif #endif
class AccountConsistencyModeManagerFactory
: public BrowserContextKeyedServiceFactory {
public:
// Returns an instance of the factory singleton.
static AccountConsistencyModeManagerFactory* GetInstance() {
return base::Singleton<AccountConsistencyModeManagerFactory>::get();
}
static AccountConsistencyModeManager* GetForProfile(Profile* profile) {
DCHECK(profile);
return static_cast<AccountConsistencyModeManager*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
private:
friend struct base::DefaultSingletonTraits<
AccountConsistencyModeManagerFactory>;
AccountConsistencyModeManagerFactory()
: BrowserContextKeyedServiceFactory(
"AccountConsistencyModeManager",
BrowserContextDependencyManager::GetInstance()) {}
~AccountConsistencyModeManagerFactory() override = default;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override {
DCHECK(!context->IsOffTheRecord());
Profile* profile = static_cast<Profile*>(context);
return new AccountConsistencyModeManager(profile);
}
};
// Returns the default account consistency for guest profiles. // Returns the default account consistency for guest profiles.
AccountConsistencyMethod GetMethodForNonRegularProfile() { AccountConsistencyMethod GetMethodForNonRegularProfile() {
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/account_consistency_mode_manager_factory.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/signin/core/browser/signin_buildflags.h"
// static
AccountConsistencyModeManagerFactory*
AccountConsistencyModeManagerFactory::GetInstance() {
return base::Singleton<AccountConsistencyModeManagerFactory>::get();
}
// static
AccountConsistencyModeManager*
AccountConsistencyModeManagerFactory::GetForProfile(Profile* profile) {
DCHECK(profile);
return static_cast<AccountConsistencyModeManager*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
AccountConsistencyModeManagerFactory::AccountConsistencyModeManagerFactory()
: BrowserContextKeyedServiceFactory(
"AccountConsistencyModeManager",
BrowserContextDependencyManager::GetInstance()) {}
AccountConsistencyModeManagerFactory::~AccountConsistencyModeManagerFactory() =
default;
KeyedService* AccountConsistencyModeManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
DCHECK(!context->IsOffTheRecord());
return new AccountConsistencyModeManager(
Profile::FromBrowserContext(context));
}
void AccountConsistencyModeManagerFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
AccountConsistencyModeManager::RegisterProfilePrefs(registry);
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_MODE_MANAGER_FACTORY_H_
#define CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_MODE_MANAGER_FACTORY_H_
#include "base/memory/singleton.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class AccountConsistencyModeManagerFactory
: public BrowserContextKeyedServiceFactory {
public:
// Returns an instance of the factory singleton.
static AccountConsistencyModeManagerFactory* GetInstance();
static AccountConsistencyModeManager* GetForProfile(Profile* profile);
private:
friend struct base::DefaultSingletonTraits<
AccountConsistencyModeManagerFactory>;
AccountConsistencyModeManagerFactory();
~AccountConsistencyModeManagerFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
};
#endif // CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_MODE_MANAGER_FACTORY_H_
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
ChromeSigninClientFactory::ChromeSigninClientFactory() ChromeSigninClientFactory::ChromeSigninClientFactory()
...@@ -31,8 +30,3 @@ KeyedService* ChromeSigninClientFactory::BuildServiceInstanceFor( ...@@ -31,8 +30,3 @@ KeyedService* ChromeSigninClientFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return new ChromeSigninClient(Profile::FromBrowserContext(context)); return new ChromeSigninClient(Profile::FromBrowserContext(context));
} }
void ChromeSigninClientFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
AccountConsistencyModeManager::RegisterProfilePrefs(registry);
}
...@@ -32,8 +32,6 @@ class ChromeSigninClientFactory : public BrowserContextKeyedServiceFactory { ...@@ -32,8 +32,6 @@ class ChromeSigninClientFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory: // BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override; content::BrowserContext* profile) const override;
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
}; };
#endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_FACTORY_H_ #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_FACTORY_H_
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