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..b80b277f30db494c99fc512a63fe67f6da9502e7 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,56 @@ |
#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); |
Bernhard Bauer
2013/01/02 14:59:53
Nit: only one space
John Knottenbelt
2013/01/02 15:49:02
Done.
|
#endif |
+ } |
+ |
+ ChromeGeolocationPermissionContext* context() { |
+ return static_cast<ChromeGeolocationPermissionContext*>(context_.get()); |
+ } |
+ |
+ private: |
+ scoped_refptr<content::GeolocationPermissionContext> context_; |
Bernhard Bauer
2013/01/02 14:59:53
If you make this a ChromeGeolocationPermissionCont
John Knottenbelt
2013/01/02 15:49:02
Yes. Thanks, that's much neater!
On 2013/01/02 14
|
+}; |
+ |
+} // 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( |
Bernhard Bauer
2013/01/02 14:59:53
Nit: Indent four spaces (in total)
John Knottenbelt
2013/01/02 15:49:02
Done.
|
+ "ChromeGeolocationPermissionContext", |
Bernhard Bauer
2013/01/02 14:59:53
...and then this line four spaces w/r/t to the Pro
John Knottenbelt
2013/01/02 15:49:02
Done.
|
+ ProfileDependencyManager::GetInstance()) { |
+} |
+ |
+ChromeGeolocationPermissionContextFactory:: |
+~ChromeGeolocationPermissionContextFactory() { |
+} |
+ |
+ProfileKeyedService* |
+ChromeGeolocationPermissionContextFactory::BuildServiceInstanceFor( |
+ Profile* profile) const { |
+ return new Service(profile); |
} |
void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs( |
@@ -28,3 +72,8 @@ void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs( |
PrefServiceSyncable::UNSYNCABLE_PREF); |
#endif |
} |
+ |
+bool ChromeGeolocationPermissionContextFactory:: |
+ServiceRedirectedInIncognito() const { |
+ return true; |
+} |