| 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/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 BrowserContextDependencyManager::GetInstance()) { | 86 BrowserContextDependencyManager::GetInstance()) { |
| 87 DeclareFactoryDependencies(); | 87 DeclareFactoryDependencies(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual ~ProfileKeyedAPIFactory() { | 90 virtual ~ProfileKeyedAPIFactory() { |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // BrowserContextKeyedServiceFactory implementation. | 94 // BrowserContextKeyedServiceFactory implementation. |
| 95 virtual BrowserContextKeyedService* BuildServiceInstanceFor( | 95 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 96 content::BrowserContext* profile) const OVERRIDE { | 96 content::BrowserContext* context) const OVERRIDE { |
| 97 return new T(static_cast<Profile*>(profile)); | 97 return new T(static_cast<Profile*>(context)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 // BrowserContextKeyedBaseFactory implementation. | 100 // BrowserContextKeyedBaseFactory implementation. |
| 101 // These can be effectively overridden with template specializations. | 101 // These can be effectively overridden with template specializations. |
| 102 virtual content::BrowserContext* GetBrowserContextToUse( | 102 virtual content::BrowserContext* GetBrowserContextToUse( |
| 103 content::BrowserContext* context) const OVERRIDE { | 103 content::BrowserContext* context) const OVERRIDE { |
| 104 if (T::kServiceRedirectedInIncognito) | 104 if (T::kServiceRedirectedInIncognito) |
| 105 return chrome::GetBrowserContextRedirectedInIncognito(context); | 105 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 106 | 106 |
| 107 if (T::kServiceHasOwnInstanceInIncognito) | 107 if (T::kServiceHasOwnInstanceInIncognito) |
| 108 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 108 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 109 | 109 |
| 110 return BrowserContextKeyedServiceFactory::GetBrowserContextToUse(context); | 110 return BrowserContextKeyedServiceFactory::GetBrowserContextToUse(context); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE { | 113 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE { |
| 114 return T::kServiceIsCreatedWithBrowserContext; | 114 return T::kServiceIsCreatedWithBrowserContext; |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { | 117 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { |
| 118 return T::kServiceIsNULLWhileTesting; | 118 return T::kServiceIsNULLWhileTesting; |
| 119 } | 119 } |
| 120 | 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); | 121 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 } // namespace extensions | 124 } // namespace extensions |
| 125 | 125 |
| 126 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 126 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
| OLD | NEW |