| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 // ProfileKeyedServiceFactory implementation. | 89 // ProfileKeyedServiceFactory implementation. |
| 89 virtual ProfileKeyedService* BuildServiceInstanceFor( | 90 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 90 content::BrowserContext* profile) const OVERRIDE { | 91 content::BrowserContext* profile) const OVERRIDE { |
| 91 return new T(static_cast<Profile*>(profile)); | 92 return new T(static_cast<Profile*>(profile)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 // ProfileKeyedBaseFactory implementation. | 95 // ProfileKeyedBaseFactory implementation. |
| 95 // These can be effectively overridden with template specializations. | 96 // These can be effectively overridden with template specializations. |
| 96 virtual bool ServiceRedirectedInIncognito() const OVERRIDE { | 97 virtual content::BrowserContext* GetBrowserContextToUse( |
| 97 return T::kServiceRedirectedInIncognito; | 98 content::BrowserContext* context) const OVERRIDE { |
| 99 if (T::kServiceRedirectedInIncognito) |
| 100 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 101 |
| 102 return ProfileKeyedServiceFactory::GetBrowserContextToUse(context); |
| 98 } | 103 } |
| 99 | 104 |
| 100 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { | 105 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE { |
| 101 return true; | 106 return true; |
| 102 } | 107 } |
| 103 | 108 |
| 104 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { | 109 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE { |
| 105 return T::kServiceIsNULLWhileTesting; | 110 return T::kServiceIsNULLWhileTesting; |
| 106 } | 111 } |
| 107 | 112 |
| 108 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); | 113 DISALLOW_COPY_AND_ASSIGN(ProfileKeyedAPIFactory); |
| 109 }; | 114 }; |
| 110 | 115 |
| 111 } // namespace extensions | 116 } // namespace extensions |
| 112 | 117 |
| 113 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ | 118 #endif // CHROME_BROWSER_EXTENSIONS_API_PROFILE_KEYED_API_FACTORY_H_ |
| OLD | NEW |