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 "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 } // namespace | 81 } // namespace |
82 | 82 |
83 namespace data_reduction_proxy { | 83 namespace data_reduction_proxy { |
84 | 84 |
85 DataReductionProxySettings::DataReductionProxySettings( | 85 DataReductionProxySettings::DataReductionProxySettings( |
86 DataReductionProxyParams* params) | 86 DataReductionProxyParams* params) |
87 : restricted_by_carrier_(false), | 87 : restricted_by_carrier_(false), |
88 enabled_by_user_(false), | 88 enabled_by_user_(false), |
89 disabled_on_vpn_(false), | 89 disabled_on_vpn_(false), |
| 90 unreachable_(false), |
90 prefs_(NULL), | 91 prefs_(NULL), |
91 local_state_prefs_(NULL), | 92 local_state_prefs_(NULL), |
92 url_request_context_getter_(NULL) { | 93 url_request_context_getter_(NULL) { |
93 DCHECK(params); | 94 DCHECK(params); |
94 params_.reset(params); | 95 params_.reset(params); |
95 } | 96 } |
96 | 97 |
97 DataReductionProxySettings::~DataReductionProxySettings() { | 98 DataReductionProxySettings::~DataReductionProxySettings() { |
98 if (params_->allowed()) | 99 if (params_->allowed()) |
99 spdy_proxy_auth_enabled_.Destroy(); | 100 spdy_proxy_auth_enabled_.Destroy(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::Time last_update = base::Time::FromInternalValue(last_update_internal); | 201 base::Time last_update = base::Time::FromInternalValue(last_update_internal); |
201 return static_cast<int64>(last_update.ToJsTime()); | 202 return static_cast<int64>(last_update.ToJsTime()); |
202 } | 203 } |
203 | 204 |
204 DataReductionProxySettings::ContentLengthList | 205 DataReductionProxySettings::ContentLengthList |
205 DataReductionProxySettings::GetDailyOriginalContentLengths() { | 206 DataReductionProxySettings::GetDailyOriginalContentLengths() { |
206 DCHECK(thread_checker_.CalledOnValidThread()); | 207 DCHECK(thread_checker_.CalledOnValidThread()); |
207 return GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength); | 208 return GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength); |
208 } | 209 } |
209 | 210 |
| 211 void DataReductionProxySettings::SetUnreachable(bool unreachable) { |
| 212 unreachable_ = unreachable; |
| 213 } |
| 214 |
210 bool DataReductionProxySettings::IsDataReductionProxyUnreachable() { | 215 bool DataReductionProxySettings::IsDataReductionProxyUnreachable() { |
211 DCHECK(thread_checker_.CalledOnValidThread()); | 216 DCHECK(thread_checker_.CalledOnValidThread()); |
212 return usage_stats_ && usage_stats_->isDataReductionProxyUnreachable(); | 217 return unreachable_; |
213 } | |
214 | |
215 void DataReductionProxySettings::SetDataReductionProxyUsageStats( | |
216 DataReductionProxyUsageStats* usage_stats) { | |
217 usage_stats_ = usage_stats; | |
218 } | 218 } |
219 | 219 |
220 DataReductionProxySettings::ContentLengthList | 220 DataReductionProxySettings::ContentLengthList |
221 DataReductionProxySettings::GetDailyReceivedContentLengths() { | 221 DataReductionProxySettings::GetDailyReceivedContentLengths() { |
222 DCHECK(thread_checker_.CalledOnValidThread()); | 222 DCHECK(thread_checker_.CalledOnValidThread()); |
223 return GetDailyContentLengths(prefs::kDailyHttpReceivedContentLength); | 223 return GetDailyContentLengths(prefs::kDailyHttpReceivedContentLength); |
224 } | 224 } |
225 | 225 |
226 void DataReductionProxySettings::OnURLFetchComplete( | 226 void DataReductionProxySettings::OnURLFetchComplete( |
227 const net::URLFetcher* source) { | 227 const net::URLFetcher* source) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return prefs_; | 286 return prefs_; |
287 } | 287 } |
288 | 288 |
289 PrefService* DataReductionProxySettings::GetLocalStatePrefs() { | 289 PrefService* DataReductionProxySettings::GetLocalStatePrefs() { |
290 DCHECK(thread_checker_.CalledOnValidThread()); | 290 DCHECK(thread_checker_.CalledOnValidThread()); |
291 return local_state_prefs_; | 291 return local_state_prefs_; |
292 } | 292 } |
293 | 293 |
294 void DataReductionProxySettings::AddDefaultProxyBypassRules() { | 294 void DataReductionProxySettings::AddDefaultProxyBypassRules() { |
295 // localhost | 295 // localhost |
| 296 DCHECK(configurator_); |
296 configurator_->AddHostPatternToBypass("<local>"); | 297 configurator_->AddHostPatternToBypass("<local>"); |
297 // RFC1918 private addresses. | 298 // RFC1918 private addresses. |
298 configurator_->AddHostPatternToBypass("10.0.0.0/8"); | 299 configurator_->AddHostPatternToBypass("10.0.0.0/8"); |
299 configurator_->AddHostPatternToBypass("172.16.0.0/12"); | 300 configurator_->AddHostPatternToBypass("172.16.0.0/12"); |
300 configurator_->AddHostPatternToBypass("192.168.0.0/16"); | 301 configurator_->AddHostPatternToBypass("192.168.0.0/16"); |
301 // RFC4193 private addresses. | 302 // RFC4193 private addresses. |
302 configurator_->AddHostPatternToBypass("fc00::/7"); | 303 configurator_->AddHostPatternToBypass("fc00::/7"); |
303 // IPV6 probe addresses. | 304 // IPV6 probe addresses. |
304 configurator_->AddHostPatternToBypass("*-ds.metric.gstatic.com"); | 305 configurator_->AddHostPatternToBypass("*-ds.metric.gstatic.com"); |
305 configurator_->AddHostPatternToBypass("*-v4.metric.gstatic.com"); | 306 configurator_->AddHostPatternToBypass("*-v4.metric.gstatic.com"); |
| 307 #if defined(OS_ANDROID) |
| 308 // Chrome cannot authenticate with the data reduction proxy when fetching URLs |
| 309 // from the settings menu. |
| 310 configurator_->AddURLPatternToBypass( |
| 311 "http://www.google.com/policies/privacy*"); |
| 312 configurator_->AddHostPatternToBypass("*freezone.google.com"); |
| 313 configurator_->AddHostPatternToBypass("freezone.googleusercontent.com"); |
| 314 configurator_->AddURLPatternToBypass("http://g.co/gms/*"); |
| 315 configurator_->AddURLPatternToBypass("http://g.co/freezone*"); |
| 316 #endif |
306 } | 317 } |
307 | 318 |
308 void DataReductionProxySettings::LogProxyState( | 319 void DataReductionProxySettings::LogProxyState( |
309 bool enabled, bool restricted, bool at_startup) { | 320 bool enabled, bool restricted, bool at_startup) { |
310 // This must stay a LOG(WARNING); the output is used in processing customer | 321 // This must stay a LOG(WARNING); the output is used in processing customer |
311 // feedback. | 322 // feedback. |
312 const char kAtStartup[] = "at startup"; | 323 const char kAtStartup[] = "at startup"; |
313 const char kByUser[] = "by user action"; | 324 const char kByUser[] = "by user action"; |
314 const char kOn[] = "ON"; | 325 const char kOn[] = "ON"; |
315 const char kOff[] = "OFF"; | 326 const char kOff[] = "OFF"; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 ProbeWhetherDataReductionProxyIsAvailable(); | 398 ProbeWhetherDataReductionProxyIsAvailable(); |
388 WarmProxyConnection(); | 399 WarmProxyConnection(); |
389 } | 400 } |
390 } | 401 } |
391 | 402 |
392 void DataReductionProxySettings::SetProxyConfigs(bool enabled, | 403 void DataReductionProxySettings::SetProxyConfigs(bool enabled, |
393 bool alternative_enabled, | 404 bool alternative_enabled, |
394 bool restricted, | 405 bool restricted, |
395 bool at_startup) { | 406 bool at_startup) { |
396 DCHECK(thread_checker_.CalledOnValidThread()); | 407 DCHECK(thread_checker_.CalledOnValidThread()); |
| 408 DCHECK(configurator_); |
| 409 |
397 LogProxyState(enabled, restricted, at_startup); | 410 LogProxyState(enabled, restricted, at_startup); |
398 // The alternative is only configured if the standard configuration is | 411 // The alternative is only configured if the standard configuration is |
399 // is enabled. | 412 // is enabled. |
400 if (enabled & !params_->holdback()) { | 413 if (enabled & !params_->holdback()) { |
401 if (alternative_enabled) { | 414 if (alternative_enabled) { |
402 configurator_->Enable(restricted, | 415 configurator_->Enable(restricted, |
403 !params_->fallback_allowed(), | 416 !params_->fallback_allowed(), |
404 params_->alt_origin().spec(), | 417 params_->alt_origin().spec(), |
405 params_->alt_fallback_origin().spec(), | 418 params_->alt_fallback_origin().spec(), |
406 params_->ssl_origin().spec()); | 419 params_->ssl_origin().spec()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 SetProxyConfigs(enabled_by_user_, | 593 SetProxyConfigs(enabled_by_user_, |
581 IsDataReductionProxyAlternativeEnabled(), | 594 IsDataReductionProxyAlternativeEnabled(), |
582 restricted_by_carrier_, | 595 restricted_by_carrier_, |
583 false); | 596 false); |
584 } | 597 } |
585 disabled_on_vpn_ = false; | 598 disabled_on_vpn_ = false; |
586 return false; | 599 return false; |
587 } | 600 } |
588 | 601 |
589 } // namespace data_reduction_proxy | 602 } // namespace data_reduction_proxy |
OLD | NEW |