Index: chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc |
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc |
index c7ada62cff74e326a930bf02a6ee6fdc5d761c3c..6f3ecc0f3b9d537f90bfa3bd9dd131a0ea0ef793 100644 |
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc |
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h" |
+#include "chrome/browser/profiles/profile_dependency_manager.h" |
#include "chrome/common/pref_names.h" |
#if defined(OS_ANDROID) |
#include "chrome/browser/geolocation/chrome_geolocation_permission_context_android.h" |
@@ -11,13 +12,58 @@ |
#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
#endif |
-ChromeGeolocationPermissionContext* |
- ChromeGeolocationPermissionContextFactory::Create(Profile* profile) { |
+namespace { |
+ |
+class Service : public ProfileKeyedService { |
+ public: |
+ explicit Service(Profile* profile) { |
#if defined(OS_ANDROID) |
- return new ChromeGeolocationPermissionContextAndroid(profile); |
+ context_ = new ChromeGeolocationPermissionContextAndroid(profile); |
#else |
- return new ChromeGeolocationPermissionContext(profile); |
+ context_ = new ChromeGeolocationPermissionContext(profile); |
#endif |
+ } |
+ |
+ ChromeGeolocationPermissionContext* context() { |
+ return context_.get(); |
+ } |
+ |
+ private: |
+ scoped_refptr<ChromeGeolocationPermissionContext> context_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Service); |
+}; |
+ |
+} // namespace |
+ |
+// static |
+ChromeGeolocationPermissionContext* |
+ChromeGeolocationPermissionContextFactory::GetForProfile(Profile* profile) { |
+ return static_cast<Service*>( |
+ GetInstance()->GetServiceForProfile(profile, true))->context(); |
+} |
+ |
+// static |
+ChromeGeolocationPermissionContextFactory* |
+ChromeGeolocationPermissionContextFactory::GetInstance() { |
+ return Singleton<ChromeGeolocationPermissionContextFactory>::get(); |
+} |
+ |
+ChromeGeolocationPermissionContextFactory:: |
+ChromeGeolocationPermissionContextFactory() |
+ : ProfileKeyedServiceFactory( |
+ "ChromeGeolocationPermissionContext", |
+ ProfileDependencyManager::GetInstance()) { |
+} |
+ |
+ChromeGeolocationPermissionContextFactory:: |
+~ChromeGeolocationPermissionContextFactory() { |
+} |
+ |
+ProfileKeyedService* |
+ChromeGeolocationPermissionContextFactory::BuildServiceInstanceFor( |
+ Profile* profile) const { |
+ return new Service(profile); |
} |
void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs( |
@@ -28,3 +74,8 @@ void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs( |
PrefServiceSyncable::UNSYNCABLE_PREF); |
#endif |
} |
+ |
+bool ChromeGeolocationPermissionContextFactory:: |
+ServiceRedirectedInIncognito() const { |
+ return true; |
+} |