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

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: Fix Android compile error. Add GetInstance() call to ProfileDependencyManager. Created 8 years 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 83e274fc83150ac735830da16c6b9f79801dc559..4c0497afc7d85ca1894c081280358307abc5b938 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);
#endif
+ }
+
+ ChromeGeolocationPermissionContext* context() {
+ return static_cast<ChromeGeolocationPermissionContext*>(context_.get());
+ }
+
+ private:
+ scoped_refptr<content::GeolocationPermissionContext> context_;
+};
+
+} // 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(

Powered by Google App Engine
This is Rietveld 408576698