| 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" |
| 34 #include "chrome/browser/net/request_source_bandwidth_histograms.h" | 35 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
| 35 #include "chrome/browser/net/safe_search_util.h" | 36 #include "chrome/browser/net/safe_search_util.h" |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
| 37 #include "chrome/browser/task_manager/task_manager_interface.h" | 38 #include "chrome/browser/task_manager/task_manager_interface.h" |
| 38 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
| 39 #include "chrome/common/features.h" | 40 #include "chrome/common/features.h" |
| 40 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 41 #include "components/content_settings/core/browser/cookie_settings.h" | 42 #include "components/content_settings/core/browser/cookie_settings.h" |
| 42 #include "components/data_usage/core/data_use_aggregator.h" | 43 #include "components/data_usage/core/data_use_aggregator.h" |
| 43 #include "components/domain_reliability/monitor.h" | 44 #include "components/domain_reliability/monitor.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 void ChromeNetworkDelegate::set_profile(void* profile) { | 176 void ChromeNetworkDelegate::set_profile(void* profile) { |
| 176 profile_ = profile; | 177 profile_ = profile; |
| 177 extensions_delegate_->set_profile(profile); | 178 extensions_delegate_->set_profile(profile); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void ChromeNetworkDelegate::set_cookie_settings( | 181 void ChromeNetworkDelegate::set_cookie_settings( |
| 181 content_settings::CookieSettings* cookie_settings) { | 182 content_settings::CookieSettings* cookie_settings) { |
| 182 cookie_settings_ = cookie_settings; | 183 cookie_settings_ = cookie_settings; |
| 183 } | 184 } |
| 184 | 185 |
| 186 void ChromeNetworkDelegate::set_predictor( |
| 187 chrome_browser_net::Predictor* predictor) { |
| 188 connect_interceptor_.reset( |
| 189 new chrome_browser_net::ConnectInterceptor(predictor)); |
| 190 } |
| 191 |
| 185 void ChromeNetworkDelegate::set_data_use_aggregator( | 192 void ChromeNetworkDelegate::set_data_use_aggregator( |
| 186 data_usage::DataUseAggregator* data_use_aggregator, | 193 data_usage::DataUseAggregator* data_use_aggregator, |
| 187 bool is_data_usage_off_the_record) { | 194 bool is_data_usage_off_the_record) { |
| 188 data_use_aggregator_ = data_use_aggregator; | 195 data_use_aggregator_ = data_use_aggregator; |
| 189 is_data_usage_off_the_record_ = is_data_usage_off_the_record; | 196 is_data_usage_off_the_record_ = is_data_usage_off_the_record; |
| 190 } | 197 } |
| 191 | 198 |
| 192 // static | 199 // static |
| 193 void ChromeNetworkDelegate::InitializePrefsOnUIThread( | 200 void ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 194 BooleanPrefMember* enable_referrers, | 201 BooleanPrefMember* enable_referrers, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 5")); | 308 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 5")); |
| 302 | 309 |
| 303 if (allowed_domains_for_apps_ && | 310 if (allowed_domains_for_apps_ && |
| 304 !allowed_domains_for_apps_->GetValue().empty() && | 311 !allowed_domains_for_apps_->GetValue().empty() && |
| 305 request->url().DomainIs("google.com")) { | 312 request->url().DomainIs("google.com")) { |
| 306 request->SetExtraRequestHeaderByName("X-GoogApps-Allowed-Domains", | 313 request->SetExtraRequestHeaderByName("X-GoogApps-Allowed-Domains", |
| 307 allowed_domains_for_apps_->GetValue(), | 314 allowed_domains_for_apps_->GetValue(), |
| 308 true); | 315 true); |
| 309 } | 316 } |
| 310 | 317 |
| 318 if (connect_interceptor_) |
| 319 connect_interceptor_->WitnessURLRequest(request); |
| 320 |
| 311 return rv; | 321 return rv; |
| 312 } | 322 } |
| 313 | 323 |
| 314 int ChromeNetworkDelegate::OnBeforeStartTransaction( | 324 int ChromeNetworkDelegate::OnBeforeStartTransaction( |
| 315 net::URLRequest* request, | 325 net::URLRequest* request, |
| 316 const net::CompletionCallback& callback, | 326 const net::CompletionCallback& callback, |
| 317 net::HttpRequestHeaders* headers) { | 327 net::HttpRequestHeaders* headers) { |
| 318 if (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()) | 328 if (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()) |
| 319 safe_search_util::ForceYouTubeSafetyMode(request, headers); | 329 safe_search_util::ForceYouTubeSafetyMode(request, headers); |
| 320 | 330 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 if (!data_use_aggregator_) | 595 if (!data_use_aggregator_) |
| 586 return; | 596 return; |
| 587 | 597 |
| 588 if (is_data_usage_off_the_record_) { | 598 if (is_data_usage_off_the_record_) { |
| 589 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 599 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 590 return; | 600 return; |
| 591 } | 601 } |
| 592 | 602 |
| 593 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 603 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 594 } | 604 } |
| OLD | NEW |