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/profile.h" |
9 #include "chrome/browser/profiles/profile_dependency_manager.h" | 10 #include "chrome/browser/profiles/profile_dependency_manager.h" |
10 #include "chrome/browser/profiles/profile_keyed_service.h" | 11 #include "chrome/browser/profiles/profile_keyed_service.h" |
11 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 12 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 | 15 |
15 template <typename T> | 16 template <typename T> |
16 class ProfileKeyedAPIFactory; | 17 class ProfileKeyedAPIFactory; |
17 | 18 |
18 // Instantiations of ProfileKeyedAPIFactory should use this base class | 19 // Instantiations of ProfileKeyedAPIFactory should use this base class |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ProfileDependencyManager::GetInstance()) { | 80 ProfileDependencyManager::GetInstance()) { |
80 DeclareFactoryDependencies(); | 81 DeclareFactoryDependencies(); |
81 } | 82 } |
82 | 83 |
83 virtual ~ProfileKeyedAPIFactory() { | 84 virtual ~ProfileKeyedAPIFactory() { |
84 } | 85 } |
85 | 86 |
86 private: | 87 private: |
87 // ProfileKeyedServiceFactory implementation. | 88 // ProfileKeyedServiceFactory implementation. |
88 virtual ProfileKeyedService* BuildServiceInstanceFor( | 89 virtual ProfileKeyedService* BuildServiceInstanceFor( |
89 Profile* profile) const OVERRIDE { | 90 content::BrowserContext* profile) const OVERRIDE { |
90 return new T(profile); | 91 return new T(static_cast<Profile*>(profile)); |
91 } | 92 } |
92 | 93 |
93 // ProfileKeyedBaseFactory implementation. | 94 // ProfileKeyedBaseFactory implementation. |
94 // These can be effectively overridden with template specializations. | 95 // These can be effectively overridden with template specializations. |
95 virtual bool ServiceRedirectedInIncognito() const OVERRIDE { | 96 virtual bool ServiceRedirectedInIncognito() const OVERRIDE { |
96 return T::kServiceRedirectedInIncognito; | 97 return T::kServiceRedirectedInIncognito; |
97 } | 98 } |
98 | 99 |
99 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { | 100 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { |
100 return true; | 101 return true; |
101 } | 102 } |
102 | 103 |
103 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { | 104 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { |
104 return T::kServiceIsNULLWhileTesting; | 105 return T::kServiceIsNULLWhileTesting; |
105 } | 106 } |
106 | 107 |
107 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); | 108 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); |
108 }; | 109 }; |
109 | 110 |
110 } // namespace extensions | 111 } // namespace extensions |
111 | 112 |
112 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 113 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
OLD | NEW |