1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
13 struct DefaultSingletonTraits
;
14 class AccountConsistencyService
;
18 class ChromeBrowserState
;
20 // Singleton that owns the AccountConsistencyService(s) and associates them with
22 class AccountConsistencyServiceFactory
23 : public BrowserStateKeyedServiceFactory
{
25 // Returns the instance of AccountConsistencyService associated with this
26 // browser state (creating one if none exists). Returns null if this browser
27 // state cannot have an AccountConsistencyService (for example, if it is
28 // incognito or if WKWebView is not enabled).
29 static AccountConsistencyService
* GetForBrowserState(
30 ios::ChromeBrowserState
* browser_state
);
32 // Returns an instance of the factory singleton.
33 static AccountConsistencyServiceFactory
* GetInstance();
36 friend struct DefaultSingletonTraits
<AccountConsistencyServiceFactory
>;
38 AccountConsistencyServiceFactory();
39 ~AccountConsistencyServiceFactory() override
;
41 // BrowserStateKeyedServiceFactory:
42 void RegisterBrowserStatePrefs(
43 user_prefs::PrefRegistrySyncable
* registry
) override
;
44 scoped_ptr
<KeyedService
> BuildServiceInstanceFor(
45 web::BrowserState
* context
) const override
;
46 bool ServiceIsCreatedWithBrowserState() const override
;
48 DISALLOW_COPY_AND_ASSIGN(AccountConsistencyServiceFactory
);
53 #endif // IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_