blob: 248a99dc4f65f15ddb34ef32538cbfd7ae326406 [file] [log] [blame]
// Copyright 2015 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 IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_
#define IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_
#include <memory>
#include "base/macros.h"
#include "base/no_destructor.h"
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
class AccountConsistencyService;
class ChromeBrowserState;
namespace ios {
// Singleton that creates the AccountConsistencyService(s) and associates those
// services with browser states.
class AccountConsistencyServiceFactory
: public BrowserStateKeyedServiceFactory {
public:
// Returns the instance of AccountConsistencyService associated with this
// browser state (creating one if none exists). Returns null if this browser
// state cannot have an AccountConsistencyService (for example, if it is
// incognito or if WKWebView is not enabled).
static AccountConsistencyService* GetForBrowserState(
ChromeBrowserState* browser_state);
// Returns an instance of the factory singleton.
static AccountConsistencyServiceFactory* GetInstance();
private:
friend class base::NoDestructor<AccountConsistencyServiceFactory>;
AccountConsistencyServiceFactory();
~AccountConsistencyServiceFactory() override;
// BrowserStateKeyedServiceFactory:
void RegisterBrowserStatePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
web::BrowserState* context) const override;
DISALLOW_COPY_AND_ASSIGN(AccountConsistencyServiceFactory);
};
} // namespace ios
#endif // IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_