| 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/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 url_blacklist_manager_(NULL), | 259 url_blacklist_manager_(NULL), |
| 260 #endif | 260 #endif |
| 261 domain_reliability_monitor_(NULL), | 261 domain_reliability_monitor_(NULL), |
| 262 received_content_length_(0), | 262 received_content_length_(0), |
| 263 original_content_length_(0), | 263 original_content_length_(0), |
| 264 first_request_(true), | 264 first_request_(true), |
| 265 prerender_tracker_(NULL), | 265 prerender_tracker_(NULL), |
| 266 data_reduction_proxy_params_(NULL), | 266 data_reduction_proxy_params_(NULL), |
| 267 data_reduction_proxy_usage_stats_(NULL), | 267 data_reduction_proxy_usage_stats_(NULL), |
| 268 data_reduction_proxy_auth_request_handler_(NULL), | 268 data_reduction_proxy_auth_request_handler_(NULL), |
| 269 data_reduction_proxy_statistics_prefs_(NULL) { | 269 data_reduction_proxy_statistics_prefs_(NULL), |
| 270 data_reduction_proxy_event_store_(NULL) { |
| 270 DCHECK(enable_referrers); | 271 DCHECK(enable_referrers); |
| 271 extensions_delegate_.reset( | 272 extensions_delegate_.reset( |
| 272 ChromeExtensionsNetworkDelegate::Create(event_router)); | 273 ChromeExtensionsNetworkDelegate::Create(event_router)); |
| 273 } | 274 } |
| 274 | 275 |
| 275 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} | 276 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} |
| 276 | 277 |
| 277 void ChromeNetworkDelegate::set_extension_info_map( | 278 void ChromeNetworkDelegate::set_extension_info_map( |
| 278 extensions::InfoMap* extension_info_map) { | 279 extensions::InfoMap* extension_info_map) { |
| 279 extensions_delegate_->set_extension_info_map(extension_info_map); | 280 extensions_delegate_->set_extension_info_map(extension_info_map); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 base::Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const { | 371 base::Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const { |
| 371 base::DictionaryValue* dict = new base::DictionaryValue(); | 372 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 372 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | 373 // Use strings to avoid overflow. base::Value only supports 32-bit integers. |
| 373 dict->SetString("session_received_content_length", | 374 dict->SetString("session_received_content_length", |
| 374 base::Int64ToString(received_content_length_)); | 375 base::Int64ToString(received_content_length_)); |
| 375 dict->SetString("session_original_content_length", | 376 dict->SetString("session_original_content_length", |
| 376 base::Int64ToString(original_content_length_)); | 377 base::Int64ToString(original_content_length_)); |
| 377 return dict; | 378 return dict; |
| 378 } | 379 } |
| 379 | 380 |
| 381 base::Value* ChromeNetworkDelegate::DataReductionProxyInfoToValue() const { |
| 382 base::DictionaryValue* data_reduction_proxy_info = |
| 383 new base::DictionaryValue(); |
| 384 |
| 385 if (data_reduction_proxy_enabled_) { |
| 386 data_reduction_proxy_info->SetString( |
| 387 "enabled", |
| 388 data_reduction_proxy_enabled_->GetValue() ? "true" : "false"); |
| 389 } else { |
| 390 data_reduction_proxy_info->SetString("enabled", "unknown"); |
| 391 } |
| 392 |
| 393 if (data_reduction_proxy_event_store_) { |
| 394 data_reduction_proxy_event_store_->AddStoredEvents( |
| 395 data_reduction_proxy_info); |
| 396 } |
| 397 |
| 398 return data_reduction_proxy_info; |
| 399 } |
| 400 |
| 380 int ChromeNetworkDelegate::OnBeforeURLRequest( | 401 int ChromeNetworkDelegate::OnBeforeURLRequest( |
| 381 net::URLRequest* request, | 402 net::URLRequest* request, |
| 382 const net::CompletionCallback& callback, | 403 const net::CompletionCallback& callback, |
| 383 GURL* new_url) { | 404 GURL* new_url) { |
| 384 #if defined(ENABLE_CONFIGURATION_POLICY) | 405 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 385 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 406 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
| 386 // blocked. However, an extension might redirect the request to another URL, | 407 // blocked. However, an extension might redirect the request to another URL, |
| 387 // which is not blocked. | 408 // which is not blocked. |
| 388 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; | 409 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; |
| 389 if (url_blacklist_manager_ && | 410 if (url_blacklist_manager_ && |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 if (data_reduction_proxy_statistics_prefs_) { | 853 if (data_reduction_proxy_statistics_prefs_) { |
| 833 StoreAccumulatedContentLength(received_content_length, | 854 StoreAccumulatedContentLength(received_content_length, |
| 834 original_content_length, | 855 original_content_length, |
| 835 request_type, | 856 request_type, |
| 836 reinterpret_cast<Profile*>(profile_), | 857 reinterpret_cast<Profile*>(profile_), |
| 837 data_reduction_proxy_statistics_prefs_); | 858 data_reduction_proxy_statistics_prefs_); |
| 838 } | 859 } |
| 839 received_content_length_ += received_content_length; | 860 received_content_length_ += received_content_length; |
| 840 original_content_length_ += original_content_length; | 861 original_content_length_ += original_content_length; |
| 841 } | 862 } |
| OLD | NEW |