OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 protected: | 44 protected: |
45 ProfileKeyedBaseFactory(const char* name, | 45 ProfileKeyedBaseFactory(const char* name, |
46 ProfileDependencyManager* manager); | 46 ProfileDependencyManager* manager); |
47 virtual ~ProfileKeyedBaseFactory(); | 47 virtual ~ProfileKeyedBaseFactory(); |
48 | 48 |
49 // The main public interface for declaring dependencies between services | 49 // The main public interface for declaring dependencies between services |
50 // created by factories. | 50 // created by factories. |
51 void DependsOn(ProfileKeyedBaseFactory* rhs); | 51 void DependsOn(ProfileKeyedBaseFactory* rhs); |
52 | 52 |
53 // Finds which profile (if any) to use using the Service.*Incognito methods. | 53 // Interface for people building a concrete FooServiceFactory: -------------- |
54 content::BrowserContext* GetProfileToUse(content::BrowserContext* profile); | |
55 | 54 |
56 // Interface for people building a concrete FooServiceFactory: -------------- | 55 // Finds which browser context (if any) to use. |
| 56 virtual content::BrowserContext* GetBrowserContextToUse( |
| 57 content::BrowserContext* context) const; |
57 | 58 |
58 // Register any user preferences on this service. This is called during | 59 // Register any user preferences on this service. This is called during |
59 // CreateProfileService() since preferences are registered on a per Profile | 60 // CreateProfileService() since preferences are registered on a per Profile |
60 // basis. | 61 // basis. |
61 virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) {} | 62 virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) {} |
62 | 63 |
63 // By default, if we are asked for a service with an Incognito profile, we | |
64 // pass back NULL. To redirect to the Incognito's original profile or to | |
65 // create another instance, even for Incognito windows, override one of the | |
66 // following methods: | |
67 virtual bool ServiceRedirectedInIncognito() const; | |
68 virtual bool ServiceHasOwnInstanceInIncognito() const; | |
69 | |
70 // By default, we create instances of a service lazily and wait until | 64 // By default, we create instances of a service lazily and wait until |
71 // GetForProfile() is called on our subclass. Some services need to be | 65 // GetForProfile() is called on our subclass. Some services need to be |
72 // created as soon as the Profile has been brought up. | 66 // created as soon as the Profile has been brought up. |
73 virtual bool ServiceIsCreatedWithProfile() const; | 67 virtual bool ServiceIsCreatedWithProfile() const; |
74 | 68 |
75 // By default, TestingProfiles will be treated like normal profiles. You can | 69 // By default, TestingProfiles will be treated like normal profiles. You can |
76 // override this so that by default, the service associated with the | 70 // override this so that by default, the service associated with the |
77 // TestingProfile is NULL. (This is just a shortcut around | 71 // TestingProfile is NULL. (This is just a shortcut around |
78 // SetTestingFactory() to make sure our profiles don't directly refer to the | 72 // SetTestingFactory() to make sure our profiles don't directly refer to the |
79 // services they use.) | 73 // services they use.) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 124 |
131 #if !defined(NDEBUG) | 125 #if !defined(NDEBUG) |
132 // A static string passed in to our constructor. Should be unique across all | 126 // A static string passed in to our constructor. Should be unique across all |
133 // services. This is used only for debugging in debug mode. (We can print | 127 // services. This is used only for debugging in debug mode. (We can print |
134 // pretty graphs with GraphViz with this information.) | 128 // pretty graphs with GraphViz with this information.) |
135 const char* service_name_; | 129 const char* service_name_; |
136 #endif | 130 #endif |
137 }; | 131 }; |
138 | 132 |
139 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ | 133 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
OLD | NEW |