| OLD | NEW |
| 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/geolocation_permission_context_factory.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" | 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/features.h" |
| 9 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 #include "components/pref_registry/pref_registry_syncable.h" | 12 #include "components/pref_registry/pref_registry_syncable.h" |
| 12 #if defined(OS_ANDROID) | 13 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 13 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 14 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
| 14 #else | 15 #else |
| 15 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 16 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 GeolocationPermissionContext* | 21 GeolocationPermissionContext* |
| 21 GeolocationPermissionContextFactory::GetForProfile(Profile* profile) { | 22 GeolocationPermissionContextFactory::GetForProfile(Profile* profile) { |
| 22 return static_cast<GeolocationPermissionContext*>( | 23 return static_cast<GeolocationPermissionContext*>( |
| 23 GetInstance()->GetServiceForBrowserContext(profile, true)); | 24 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // static | 27 // static |
| 27 GeolocationPermissionContextFactory* | 28 GeolocationPermissionContextFactory* |
| 28 GeolocationPermissionContextFactory::GetInstance() { | 29 GeolocationPermissionContextFactory::GetInstance() { |
| 29 return base::Singleton<GeolocationPermissionContextFactory>::get(); | 30 return base::Singleton<GeolocationPermissionContextFactory>::get(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 #if !defined(OS_ANDROID) | 33 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 33 GeolocationPermissionContextFactory::GeolocationPermissionContextFactory() | 34 GeolocationPermissionContextFactory::GeolocationPermissionContextFactory() |
| 34 : PermissionContextFactoryBase( | 35 : PermissionContextFactoryBase( |
| 35 "GeolocationPermissionContext", | 36 "GeolocationPermissionContext", |
| 36 BrowserContextDependencyManager::GetInstance()) { | 37 BrowserContextDependencyManager::GetInstance()) { |
| 37 } | 38 } |
| 38 #else | 39 #else |
| 39 GeolocationPermissionContextFactory::GeolocationPermissionContextFactory() | 40 GeolocationPermissionContextFactory::GeolocationPermissionContextFactory() |
| 40 : PermissionContextFactoryBase( | 41 : PermissionContextFactoryBase( |
| 41 "GeolocationPermissionContextAndroid", | 42 "GeolocationPermissionContextAndroid", |
| 42 BrowserContextDependencyManager::GetInstance()) { | 43 BrowserContextDependencyManager::GetInstance()) { |
| 43 } | 44 } |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 46 | 47 |
| 47 GeolocationPermissionContextFactory::~GeolocationPermissionContextFactory() { | 48 GeolocationPermissionContextFactory::~GeolocationPermissionContextFactory() { |
| 48 } | 49 } |
| 49 | 50 |
| 50 KeyedService* | 51 KeyedService* |
| 51 GeolocationPermissionContextFactory::BuildServiceInstanceFor( | 52 GeolocationPermissionContextFactory::BuildServiceInstanceFor( |
| 52 content::BrowserContext* profile) const { | 53 content::BrowserContext* profile) const { |
| 53 #if !defined(OS_ANDROID) | 54 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 54 return new GeolocationPermissionContext(static_cast<Profile*>(profile)); | 55 return new GeolocationPermissionContext(static_cast<Profile*>(profile)); |
| 55 #else | 56 #else |
| 56 return new GeolocationPermissionContextAndroid( | 57 return new GeolocationPermissionContextAndroid( |
| 57 static_cast<Profile*>(profile)); | 58 static_cast<Profile*>(profile)); |
| 58 #endif | 59 #endif |
| 59 } | 60 } |
| 60 | 61 |
| 61 void GeolocationPermissionContextFactory::RegisterProfilePrefs( | 62 void GeolocationPermissionContextFactory::RegisterProfilePrefs( |
| 62 user_prefs::PrefRegistrySyncable* registry) { | 63 user_prefs::PrefRegistrySyncable* registry) { |
| 63 #if defined(OS_ANDROID) | 64 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 64 registry->RegisterBooleanPref(prefs::kGeolocationEnabled, true); | 65 registry->RegisterBooleanPref(prefs::kGeolocationEnabled, true); |
| 65 #endif | 66 #endif |
| 66 } | 67 } |
| OLD | NEW |