Added owners for common login-related code that was moved recently.
[chromium-blink-merge.git] / chrome / browser / signin / profile_oauth2_token_service_factory.h
blobab58937b3f5325808dab9ab457fe83e0b91b7d39
1 // Copyright 2012 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 CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
8 #include "base/memory/singleton.h"
9 #include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
11 class ProfileOAuth2TokenService;
12 class Profile;
14 #if defined(OS_ANDROID)
15 class AndroidProfileOAuth2TokenService;
16 #else
17 class MutableProfileOAuth2TokenService;
18 #endif
20 // A wrapper of ProfileOAuth2TokenService so we can use it as a BCKS.
21 class ProfileOAuth2TokenServiceWrapper : public BrowserContextKeyedService {
22 public:
23 virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() = 0;
26 /// Singleton that owns all ProfileOAuth2TokenServices and associates them with
27 // Profiles. Listens for the Profile's destruction notification and cleans up
28 // the associated ProfileOAuth2TokenService.
29 class ProfileOAuth2TokenServiceFactory
30 : public BrowserContextKeyedServiceFactory {
31 public:
32 // Returns the instance of ProfileOAuth2TokenService associated with this
33 // profile (creating one if none exists). Returns NULL if this profile
34 // cannot have a ProfileOAuth2TokenService (for example, if |profile| is
35 // incognito).
36 static ProfileOAuth2TokenService* GetForProfile(Profile* profile);
38 // Returns the platform specific instance of ProfileOAuth2TokenService
39 // associated with this profile (creating one if none exists). Returns NULL
40 // if this profile cannot have a ProfileOAuth2TokenService (for example,
41 // if |profile| is incognito).
42 #if defined(OS_ANDROID)
43 static AndroidProfileOAuth2TokenService* GetPlatformSpecificForProfile(
44 Profile* profile);
45 #else
46 static MutableProfileOAuth2TokenService* GetPlatformSpecificForProfile(
47 Profile* profile);
48 #endif
50 // Returns an instance of the ProfileOAuth2TokenServiceFactory singleton.
51 static ProfileOAuth2TokenServiceFactory* GetInstance();
53 private:
54 friend struct DefaultSingletonTraits<ProfileOAuth2TokenServiceFactory>;
55 friend class ProfileOAuth2TokenServiceWrapperImpl;
57 #if defined(OS_ANDROID)
58 typedef AndroidProfileOAuth2TokenService PlatformSpecificOAuth2TokenService;
59 #else
60 typedef MutableProfileOAuth2TokenService PlatformSpecificOAuth2TokenService;
61 #endif
63 ProfileOAuth2TokenServiceFactory();
64 virtual ~ProfileOAuth2TokenServiceFactory();
66 // BrowserContextKeyedServiceFactory implementation.
67 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
68 content::BrowserContext* context) const OVERRIDE;
70 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenServiceFactory);
73 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_FACTORY_H_