Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Unified Diff: chrome/browser/geolocation/chrome_geolocation_permission_context_factory.cc

Issue 11587003: Make ChromeGeolocationPermissionContextFactory a ProfileKeyedServiceFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698