OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" |
7 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
8 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 11 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" | 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
11 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" | 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" |
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 18 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 20 #include "net/url_request/url_request_context_getter.h" |
18 | 21 |
19 using data_reduction_proxy::DataReductionProxyParams; | 22 using data_reduction_proxy::DataReductionProxyParams; |
20 using data_reduction_proxy::DataReductionProxySettings; | 23 using data_reduction_proxy::DataReductionProxySettings; |
21 | 24 |
22 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( | 25 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( |
23 DataReductionProxyParams* params) : DataReductionProxySettings(params) { | 26 DataReductionProxyParams* params) : DataReductionProxySettings(params) { |
24 } | 27 } |
25 | 28 |
26 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { | 29 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
27 } | 30 } |
28 | 31 |
29 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( | 32 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
30 Profile* profile) { | 33 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
31 DCHECK(profile); | 34 configurator, |
32 PrefService* prefs = profile->GetPrefs(); | 35 PrefService* profile_prefs, |
33 | 36 PrefService* local_state_prefs, |
34 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> | 37 net::URLRequestContextGetter* request_context) { |
35 configurator(new DataReductionProxyChromeConfigurator(prefs)); | |
36 SetProxyConfigurator(configurator.Pass()); | 38 SetProxyConfigurator(configurator.Pass()); |
37 DataReductionProxySettings::InitDataReductionProxySettings( | 39 DataReductionProxySettings::InitDataReductionProxySettings( |
38 prefs, | 40 profile_prefs, |
39 g_browser_process->local_state(), | 41 local_state_prefs, |
40 ProfileManager::GetActiveUserProfile()->GetRequestContext()); | 42 request_context); |
41 DataReductionProxySettings::SetOnDataReductionEnabledCallback( | 43 DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
42 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, | 44 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, |
43 base::Unretained(this))); | 45 base::Unretained(this))); |
44 | |
45 SetDataReductionProxyAlternativeEnabled( | 46 SetDataReductionProxyAlternativeEnabled( |
46 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); | 47 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); |
47 } | 48 } |
48 | 49 |
49 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( | 50 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( |
50 bool data_reduction_proxy_enabled) { | 51 bool data_reduction_proxy_enabled) { |
51 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( | 52 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( |
52 "DataReductionProxyEnabled", | 53 "DataReductionProxyEnabled", |
53 data_reduction_proxy_enabled ? "true" : "false"); | 54 data_reduction_proxy_enabled ? "true" : "false"); |
54 } | 55 } |
(...skipping 11 matching lines...) Expand all Loading... |
66 // static | 67 // static |
67 std::string DataReductionProxyChromeSettings::GetClient() { | 68 std::string DataReductionProxyChromeSettings::GetClient() { |
68 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
69 return data_reduction_proxy::kClientChromeAndroid; | 70 return data_reduction_proxy::kClientChromeAndroid; |
70 #elif defined(OS_IOS) | 71 #elif defined(OS_IOS) |
71 return data_reduction_proxy::kClientChromeIOS; | 72 return data_reduction_proxy::kClientChromeIOS; |
72 #else | 73 #else |
73 return ""; | 74 return ""; |
74 #endif | 75 #endif |
75 } | 76 } |
OLD | NEW |