| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/profiler/scoped_tracker.h" | 24 #include "base/profiler/scoped_tracker.h" |
| 25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 26 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 30 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 31 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 31 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 32 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 32 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 33 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 33 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
| 34 #include "chrome/browser/net/connect_interceptor.h" | |
| 35 #include "chrome/browser/net/request_source_bandwidth_histograms.h" | 34 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
| 36 #include "chrome/browser/net/safe_search_util.h" | 35 #include "chrome/browser/net/safe_search_util.h" |
| 37 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
| 38 #include "chrome/browser/task_management/task_manager_interface.h" | 37 #include "chrome/browser/task_management/task_manager_interface.h" |
| 39 #include "chrome/common/chrome_constants.h" | 38 #include "chrome/common/chrome_constants.h" |
| 40 #include "chrome/common/features.h" | 39 #include "chrome/common/features.h" |
| 41 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 42 #include "components/content_settings/core/browser/cookie_settings.h" | 41 #include "components/content_settings/core/browser/cookie_settings.h" |
| 43 #include "components/data_usage/core/data_use_aggregator.h" | 42 #include "components/data_usage/core/data_use_aggregator.h" |
| 44 #include "components/domain_reliability/monitor.h" | 43 #include "components/domain_reliability/monitor.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 void ChromeNetworkDelegate::set_profile(void* profile) { | 316 void ChromeNetworkDelegate::set_profile(void* profile) { |
| 318 profile_ = profile; | 317 profile_ = profile; |
| 319 extensions_delegate_->set_profile(profile); | 318 extensions_delegate_->set_profile(profile); |
| 320 } | 319 } |
| 321 | 320 |
| 322 void ChromeNetworkDelegate::set_cookie_settings( | 321 void ChromeNetworkDelegate::set_cookie_settings( |
| 323 content_settings::CookieSettings* cookie_settings) { | 322 content_settings::CookieSettings* cookie_settings) { |
| 324 cookie_settings_ = cookie_settings; | 323 cookie_settings_ = cookie_settings; |
| 325 } | 324 } |
| 326 | 325 |
| 327 void ChromeNetworkDelegate::set_predictor( | |
| 328 chrome_browser_net::Predictor* predictor) { | |
| 329 connect_interceptor_.reset( | |
| 330 new chrome_browser_net::ConnectInterceptor(predictor)); | |
| 331 } | |
| 332 | |
| 333 void ChromeNetworkDelegate::set_data_use_aggregator( | 326 void ChromeNetworkDelegate::set_data_use_aggregator( |
| 334 data_usage::DataUseAggregator* data_use_aggregator, | 327 data_usage::DataUseAggregator* data_use_aggregator, |
| 335 bool is_data_usage_off_the_record) { | 328 bool is_data_usage_off_the_record) { |
| 336 data_use_aggregator_ = data_use_aggregator; | 329 data_use_aggregator_ = data_use_aggregator; |
| 337 is_data_usage_off_the_record_ = is_data_usage_off_the_record; | 330 is_data_usage_off_the_record_ = is_data_usage_off_the_record; |
| 338 } | 331 } |
| 339 | 332 |
| 340 // static | 333 // static |
| 341 void ChromeNetworkDelegate::InitializePrefsOnUIThread( | 334 void ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 342 BooleanPrefMember* enable_referrers, | 335 BooleanPrefMember* enable_referrers, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 5")); | 442 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 5")); |
| 450 | 443 |
| 451 if (allowed_domains_for_apps_ && | 444 if (allowed_domains_for_apps_ && |
| 452 !allowed_domains_for_apps_->GetValue().empty() && | 445 !allowed_domains_for_apps_->GetValue().empty() && |
| 453 request->url().DomainIs("google.com")) { | 446 request->url().DomainIs("google.com")) { |
| 454 request->SetExtraRequestHeaderByName("X-GoogApps-Allowed-Domains", | 447 request->SetExtraRequestHeaderByName("X-GoogApps-Allowed-Domains", |
| 455 allowed_domains_for_apps_->GetValue(), | 448 allowed_domains_for_apps_->GetValue(), |
| 456 true); | 449 true); |
| 457 } | 450 } |
| 458 | 451 |
| 459 if (connect_interceptor_) | |
| 460 connect_interceptor_->WitnessURLRequest(request); | |
| 461 | |
| 462 return rv; | 452 return rv; |
| 463 } | 453 } |
| 464 | 454 |
| 465 int ChromeNetworkDelegate::OnBeforeSendHeaders( | 455 int ChromeNetworkDelegate::OnBeforeSendHeaders( |
| 466 net::URLRequest* request, | 456 net::URLRequest* request, |
| 467 const net::CompletionCallback& callback, | 457 const net::CompletionCallback& callback, |
| 468 net::HttpRequestHeaders* headers) { | 458 net::HttpRequestHeaders* headers) { |
| 469 if (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()) | 459 if (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()) |
| 470 safe_search_util::ForceYouTubeSafetyMode(request, headers); | 460 safe_search_util::ForceYouTubeSafetyMode(request, headers); |
| 471 | 461 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 if (!data_use_aggregator_) | 748 if (!data_use_aggregator_) |
| 759 return; | 749 return; |
| 760 | 750 |
| 761 if (is_data_usage_off_the_record_) { | 751 if (is_data_usage_off_the_record_) { |
| 762 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 752 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 763 return; | 753 return; |
| 764 } | 754 } |
| 765 | 755 |
| 766 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 756 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 767 } | 757 } |
| OLD | NEW |