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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h" 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h"
6 6
7 #include "chrome/browser/profiles/profile_dependency_manager.h"
7 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
8 #if defined(OS_ANDROID) 9 #if defined(OS_ANDROID)
9 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_andro id.h" 10 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_andro id.h"
10 #else 11 #else
11 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 12 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
12 #endif 13 #endif
13 14
15 namespace {
16
17 class Service : public ProfileKeyedService {
18 public:
19 explicit Service(Profile* profile) {
20 #if defined(OS_ANDROID)
21 context_ = new ChromeGeolocationPermissionContextAndroid(profile);
22 #else
23 context_ = new ChromeGeolocationPermissionContext(profile);
24 #endif
25 }
26
27 ChromeGeolocationPermissionContext* context() {
28 return context_.get();
29 }
30
31 private:
32 scoped_refptr<ChromeGeolocationPermissionContext> context_;
33 };
sky 2013/01/07 14:51:44 DISALLOW_...
34
35 } // namespace
36
37 // static
14 ChromeGeolocationPermissionContext* 38 ChromeGeolocationPermissionContext*
15 ChromeGeolocationPermissionContextFactory::Create(Profile* profile) { 39 ChromeGeolocationPermissionContextFactory::GetForProfile(Profile* profile) {
16 #if defined(OS_ANDROID) 40 return static_cast<Service*>(
17 return new ChromeGeolocationPermissionContextAndroid(profile); 41 GetInstance()->GetServiceForProfile(profile, true))->context();
18 #else 42 }
19 return new ChromeGeolocationPermissionContext(profile); 43
20 #endif 44 // static
45 ChromeGeolocationPermissionContextFactory*
46 ChromeGeolocationPermissionContextFactory::GetInstance() {
47 return Singleton<ChromeGeolocationPermissionContextFactory>::get();
48 }
49
50 ChromeGeolocationPermissionContextFactory::
51 ChromeGeolocationPermissionContextFactory()
52 : ProfileKeyedServiceFactory(
53 "ChromeGeolocationPermissionContext",
54 ProfileDependencyManager::GetInstance()) {
55 }
56
57 ChromeGeolocationPermissionContextFactory::
58 ~ChromeGeolocationPermissionContextFactory() {
59 }
60
61 ProfileKeyedService*
62 ChromeGeolocationPermissionContextFactory::BuildServiceInstanceFor(
63 Profile* profile) const {
64 return new Service(profile);
21 } 65 }
22 66
23 void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs( 67 void ChromeGeolocationPermissionContextFactory::RegisterUserPrefs(
24 PrefServiceSyncable* user_prefs) { 68 PrefServiceSyncable* user_prefs) {
25 #if defined(OS_ANDROID) 69 #if defined(OS_ANDROID)
26 user_prefs->RegisterBooleanPref(prefs::kGeolocationEnabled, 70 user_prefs->RegisterBooleanPref(prefs::kGeolocationEnabled,
27 true, 71 true,
28 PrefServiceSyncable::UNSYNCABLE_PREF); 72 PrefServiceSyncable::UNSYNCABLE_PREF);
29 #endif 73 #endif
30 } 74 }
75
76 bool ChromeGeolocationPermissionContextFactory::
77 ServiceRedirectedInIncognito() const {
78 return true;
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698