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_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_system_factory.h" | 8 #include "chrome/browser/extensions/extension_system_factory.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_dependency_manager.h" | 11 #include "chrome/browser/profiles/profile_dependency_manager.h" |
11 #include "chrome/browser/profiles/profile_keyed_service.h" | 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
12 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 13 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 | 16 |
16 template <typename T> | 17 template <typename T> |
17 class ProfileKeyedAPIFactory; | 18 class ProfileKeyedAPIFactory; |
18 | 19 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 private: | 89 private: |
89 // ProfileKeyedServiceFactory implementation. | 90 // ProfileKeyedServiceFactory implementation. |
90 virtual ProfileKeyedService* BuildServiceInstanceFor( | 91 virtual ProfileKeyedService* BuildServiceInstanceFor( |
91 content::BrowserContext* profile) const OVERRIDE { | 92 content::BrowserContext* profile) const OVERRIDE { |
92 return new T(static_cast<Profile*>(profile)); | 93 return new T(static_cast<Profile*>(profile)); |
93 } | 94 } |
94 | 95 |
95 // ProfileKeyedBaseFactory implementation. | 96 // ProfileKeyedBaseFactory implementation. |
96 // These can be effectively overridden with template specializations. | 97 // These can be effectively overridden with template specializations. |
97 virtual bool ServiceRedirectedInIncognito() const OVERRIDE { | 98 virtual content::BrowserContext* GetBrowserContextToUse( |
98 return T::kServiceRedirectedInIncognito; | 99 content::BrowserContext* context) const OVERRIDE { |
| 100 if (T::kServiceRedirectedInIncognito) |
| 101 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 102 |
| 103 if (T::kServiceHasOwnInstanceInIncognito) |
| 104 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 105 |
| 106 return ProfileKeyedServiceFactory::GetBrowserContextToUse(context); |
99 } | 107 } |
100 | 108 |
101 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { | 109 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { |
102 return true; | 110 return true; |
103 } | 111 } |
104 | 112 |
105 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { | 113 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { |
106 return T::kServiceIsNULLWhileTesting; | 114 return T::kServiceIsNULLWhileTesting; |
107 } | 115 } |
108 | 116 |
109 virtual bool ServiceHasOwnInstanceInIncognito() const OVERRIDE { | |
110 return T::kServiceHasOwnInstanceInIncognito; | |
111 } | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); | 117 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); |
114 }; | 118 }; |
115 | 119 |
116 } // namespace extensions | 120 } // namespace extensions |
117 | 121 |
118 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 122 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
OLD | NEW |