Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / signin / oauth2_token_service_factory.h
blob1f757aa508ffcfb1f115c41e69994a9ff3e54b14
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_OAUTH2_TOKEN_SERVICE_FACTORY_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_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 ios {
13 class ChromeBrowserState;
16 namespace base {
17 template <typename T>
18 struct DefaultSingletonTraits;
19 } // namespace base
21 class ProfileOAuth2TokenService;
23 // Singleton that owns all ProfileOAuth2TokenServices and associates them with
24 // ios::ChromeBrowserState.
25 class OAuth2TokenServiceFactory : public BrowserStateKeyedServiceFactory {
26 public:
27 // Returns the instance of ProfileOAuth2TokenService associated with this
28 // browser state (creating one if none exists). Returns nulltpr if this
29 // browser state cannot have a ProfileOAuth2TokenService (for example, if
30 // |browser_state| is incognito).
31 static ProfileOAuth2TokenService* GetForBrowserState(
32 ios::ChromeBrowserState* browser_state);
34 // Returns an instance of the OAuth2TokenServiceFactory singleton.
35 static OAuth2TokenServiceFactory* GetInstance();
37 private:
38 friend struct base::DefaultSingletonTraits<OAuth2TokenServiceFactory>;
40 OAuth2TokenServiceFactory();
41 ~OAuth2TokenServiceFactory() override;
43 // BrowserStateKeyedServiceFactory implementation.
44 scoped_ptr<KeyedService> BuildServiceInstanceFor(
45 web::BrowserState* context) const override;
46 void RegisterBrowserStatePrefs(
47 user_prefs::PrefRegistrySyncable* registry) override;
49 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceFactory);
52 #endif // IOS_CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_FACTORY_H_