Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / signin / account_consistency_service_factory.h
blob25ce69501bcb2bb9b1dbf2a6ffdda5f5ecfdd7d7
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"
12 namespace base {
13 template <typename T>
14 struct DefaultSingletonTraits;
17 class AccountConsistencyService;
19 namespace ios {
21 class ChromeBrowserState;
23 // Singleton that owns the AccountConsistencyService(s) and associates them with
24 // browser states.
25 class AccountConsistencyServiceFactory
26 : public BrowserStateKeyedServiceFactory {
27 public:
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();
38 private:
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);
54 } // namespace ios
56 #endif // IOS_CHROME_BROWSER_SIGNIN_ACCOUNT_CONSISTENCY_SERVICE_FACTORY_H_