OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_factory_and
roid.h" |
| 6 #include "base/memory/singleton.h" |
| 7 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 12 |
| 13 // static |
| 14 DataReductionProxySettingsAndroid* |
| 15 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext( |
| 16 content::BrowserContext* context) { |
| 17 return static_cast<DataReductionProxySettingsAndroid*>( |
| 18 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 19 } |
| 20 |
| 21 // static |
| 22 bool DataReductionProxySettingsFactoryAndroid:: |
| 23 HasDataReductionProxySettingsAndroid( |
| 24 content::BrowserContext* context) { |
| 25 return GetInstance()->GetServiceForBrowserContext(context, false) != NULL; |
| 26 } |
| 27 |
| 28 // static |
| 29 DataReductionProxySettingsFactoryAndroid* |
| 30 DataReductionProxySettingsFactoryAndroid::GetInstance() { |
| 31 return Singleton<DataReductionProxySettingsFactoryAndroid>::get(); |
| 32 } |
| 33 |
| 34 |
| 35 DataReductionProxySettingsFactoryAndroid:: |
| 36 DataReductionProxySettingsFactoryAndroid() |
| 37 : BrowserContextKeyedServiceFactory( |
| 38 "ProfileSyncService", |
| 39 BrowserContextDependencyManager::GetInstance()) { |
| 40 } |
| 41 |
| 42 DataReductionProxySettingsFactoryAndroid:: |
| 43 ~DataReductionProxySettingsFactoryAndroid() { |
| 44 } |
| 45 |
| 46 KeyedService* DataReductionProxySettingsFactoryAndroid::BuildServiceInstanceFor( |
| 47 content::BrowserContext* context) const { |
| 48 Profile* profile = static_cast<Profile*>(context); |
| 49 int flags = DataReductionProxyParams::kFallbackAllowed; |
| 50 if (DataReductionProxyParams::IsIncludedInFieldTrial()) |
| 51 flags |= DataReductionProxyParams::kAllowed; |
| 52 if (DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()) |
| 53 flags |= DataReductionProxyParams::kAlternativeAllowed; |
| 54 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial()) |
| 55 flags |= DataReductionProxyParams::kPromoAllowed; |
| 56 |
| 57 DataReductionProxySettingsAndroid* settings = |
| 58 new DataReductionProxySettingsAndroid( |
| 59 new DataReductionProxyParams(flags)); |
| 60 settings->InitDataReductionProxySettings(profile); |
| 61 return settings; |
| 62 } |
| 63 |
OLD | NEW |