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"
14 struct DefaultSingletonTraits
;
17 class AccountConsistencyService
;
21 class ChromeBrowserState
;
23 // Singleton that owns the AccountConsistencyService(s) and associates them with
25 class AccountConsistencyServiceFactory
26 : public BrowserStateKeyedServiceFactory
{
28 // Returns the instance of AccountConsistencyService associated with this
29 // browser state (creating one if none exists). Returns null if this browser
30 // state cannot have an AccountConsistencyService (for example, if it is
31 // incognito or if WKWebView is not enabled).
32 static AccountConsistencyService
* GetForBrowserState(
33 ios::ChromeBrowserState
* browser_state
);
35 // Returns an instance of the factory singleton.
36 static AccountConsistencyServiceFactory
* GetInstance();
39 friend struct base::DefaultSingletonTraits
<AccountConsistencyServiceFactory
>;
41 AccountConsistencyServiceFactory();
42 ~AccountConsistencyServiceFactory() override
;
44 // BrowserStateKeyedServiceFactory:
45 void RegisterBrowserStatePrefs(
46 user_prefs::PrefRegistrySyncable
* registry
) override
;
47 scoped_ptr
<KeyedService
> BuildServiceInstanceFor(
48 web::BrowserState
* context
) const override
;
49 bool ServiceIsCreatedWithBrowserState() const override
;
51 DISALLOW_COPY_AND_ASSIGN(AccountConsistencyServiceFactory
);
56 #endif // IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_