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 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/net/request_source_bandwidth_histograms.h" | 35 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
36 #include "chrome/browser/net/safe_search_util.h" | 36 #include "chrome/browser/net/safe_search_util.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/browser/task_management/task_manager_interface.h" | 38 #include "chrome/browser/task_management/task_manager_interface.h" |
39 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
40 #include "chrome/common/features.h" | 40 #include "chrome/common/features.h" |
41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
42 #include "components/content_settings/core/browser/cookie_settings.h" | 42 #include "components/content_settings/core/browser/cookie_settings.h" |
43 #include "components/data_usage/core/data_use_aggregator.h" | 43 #include "components/data_usage/core/data_use_aggregator.h" |
44 #include "components/domain_reliability/monitor.h" | 44 #include "components/domain_reliability/monitor.h" |
| 45 #include "components/policy/core/browser/url_blacklist_manager.h" |
45 #include "components/prefs/pref_member.h" | 46 #include "components/prefs/pref_member.h" |
46 #include "components/prefs/pref_service.h" | 47 #include "components/prefs/pref_service.h" |
47 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
48 #include "content/public/browser/render_frame_host.h" | 49 #include "content/public/browser/render_frame_host.h" |
49 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
50 #include "content/public/browser/resource_request_info.h" | 51 #include "content/public/browser/resource_request_info.h" |
51 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/process_type.h" | 53 #include "content/public/common/process_type.h" |
53 #include "net/base/host_port_pair.h" | 54 #include "net/base/host_port_pair.h" |
54 #include "net/base/load_flags.h" | 55 #include "net/base/load_flags.h" |
(...skipping 10 matching lines...) Expand all Loading... |
65 #include "chrome/browser/io_thread.h" | 66 #include "chrome/browser/io_thread.h" |
66 #include "chrome/browser/precache/precache_manager_factory.h" | 67 #include "chrome/browser/precache/precache_manager_factory.h" |
67 #include "components/precache/content/precache_manager.h" | 68 #include "components/precache/content/precache_manager.h" |
68 #endif | 69 #endif |
69 | 70 |
70 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
71 #include "base/sys_info.h" | 72 #include "base/sys_info.h" |
72 #include "chrome/common/chrome_switches.h" | 73 #include "chrome/common/chrome_switches.h" |
73 #endif | 74 #endif |
74 | 75 |
75 #if defined(ENABLE_CONFIGURATION_POLICY) | |
76 #include "components/policy/core/browser/url_blacklist_manager.h" | |
77 #endif | |
78 | |
79 #if defined(ENABLE_EXTENSIONS) | 76 #if defined(ENABLE_EXTENSIONS) |
80 #include "extensions/common/constants.h" | 77 #include "extensions/common/constants.h" |
81 #endif | 78 #endif |
82 | 79 |
83 using content::BrowserThread; | 80 using content::BrowserThread; |
84 using content::RenderViewHost; | 81 using content::RenderViewHost; |
85 using content::ResourceRequestInfo; | 82 using content::ResourceRequestInfo; |
86 using content::ResourceType; | 83 using content::ResourceType; |
87 | 84 |
88 // By default we don't allow access to all file:// urls on ChromeOS and | 85 // By default we don't allow access to all file:// urls on ChromeOS and |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } // namespace | 285 } // namespace |
289 | 286 |
290 ChromeNetworkDelegate::ChromeNetworkDelegate( | 287 ChromeNetworkDelegate::ChromeNetworkDelegate( |
291 extensions::EventRouterForwarder* event_router, | 288 extensions::EventRouterForwarder* event_router, |
292 BooleanPrefMember* enable_referrers) | 289 BooleanPrefMember* enable_referrers) |
293 : profile_(NULL), | 290 : profile_(NULL), |
294 enable_referrers_(enable_referrers), | 291 enable_referrers_(enable_referrers), |
295 enable_do_not_track_(NULL), | 292 enable_do_not_track_(NULL), |
296 force_google_safe_search_(NULL), | 293 force_google_safe_search_(NULL), |
297 force_youtube_safety_mode_(NULL), | 294 force_youtube_safety_mode_(NULL), |
298 #if defined(ENABLE_CONFIGURATION_POLICY) | |
299 url_blacklist_manager_(NULL), | 295 url_blacklist_manager_(NULL), |
300 #endif | |
301 domain_reliability_monitor_(NULL), | 296 domain_reliability_monitor_(NULL), |
302 experimental_web_platform_features_enabled_( | 297 experimental_web_platform_features_enabled_( |
303 base::CommandLine::ForCurrentProcess() | 298 base::CommandLine::ForCurrentProcess() |
304 ->HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)), | 299 ->HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)), |
305 data_use_aggregator_(nullptr), | 300 data_use_aggregator_(nullptr), |
306 is_data_usage_off_the_record_(true) { | 301 is_data_usage_off_the_record_(true) { |
307 DCHECK(enable_referrers); | 302 DCHECK(enable_referrers); |
308 extensions_delegate_.reset( | 303 extensions_delegate_.reset( |
309 ChromeExtensionsNetworkDelegate::Create(event_router)); | 304 ChromeExtensionsNetworkDelegate::Create(event_router)); |
310 } | 305 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 370 |
376 int ChromeNetworkDelegate::OnBeforeURLRequest( | 371 int ChromeNetworkDelegate::OnBeforeURLRequest( |
377 net::URLRequest* request, | 372 net::URLRequest* request, |
378 const net::CompletionCallback& callback, | 373 const net::CompletionCallback& callback, |
379 GURL* new_url) { | 374 GURL* new_url) { |
380 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 375 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
381 tracked_objects::ScopedTracker tracking_profile1( | 376 tracked_objects::ScopedTracker tracking_profile1( |
382 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 377 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
383 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest")); | 378 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest")); |
384 | 379 |
385 #if defined(ENABLE_CONFIGURATION_POLICY) | |
386 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 380 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
387 // blocked. However, an extension might redirect the request to another URL, | 381 // blocked. However, an extension might redirect the request to another URL, |
388 // which is not blocked. | 382 // which is not blocked. |
389 | 383 |
390 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 384 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
391 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; | 385 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; |
392 if (info && content::IsResourceTypeFrame(info->GetResourceType()) && | 386 if (info && content::IsResourceTypeFrame(info->GetResourceType()) && |
393 url_blacklist_manager_ && | 387 url_blacklist_manager_ && |
394 url_blacklist_manager_->ShouldBlockRequestForFrame( | 388 url_blacklist_manager_->ShouldBlockRequestForFrame( |
395 request->url(), &error)) { | 389 request->url(), &error)) { |
396 // URL access blocked by policy. | 390 // URL access blocked by policy. |
397 request->net_log().AddEvent( | 391 request->net_log().AddEvent( |
398 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST, | 392 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST, |
399 net::NetLog::StringCallback("url", | 393 net::NetLog::StringCallback("url", |
400 &request->url().possibly_invalid_spec())); | 394 &request->url().possibly_invalid_spec())); |
401 return error; | 395 return error; |
402 } | 396 } |
403 #endif | |
404 | 397 |
405 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 398 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
406 tracked_objects::ScopedTracker tracking_profile2( | 399 tracked_objects::ScopedTracker tracking_profile2( |
407 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 400 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
408 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 2")); | 401 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest 2")); |
409 | 402 |
410 extensions_delegate_->ForwardStartRequestStatus(request); | 403 extensions_delegate_->ForwardStartRequestStatus(request); |
411 | 404 |
412 if (!enable_referrers_->GetValue()) | 405 if (!enable_referrers_->GetValue()) |
413 request->SetReferrer(std::string()); | 406 request->SetReferrer(std::string()); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 if (!data_use_aggregator_) | 741 if (!data_use_aggregator_) |
749 return; | 742 return; |
750 | 743 |
751 if (is_data_usage_off_the_record_) { | 744 if (is_data_usage_off_the_record_) { |
752 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 745 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
753 return; | 746 return; |
754 } | 747 } |
755 | 748 |
756 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 749 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
757 } | 750 } |
OLD | NEW |