| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 #if BUILDFLAG(ENABLE_EXTENSIONS) | 76 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 77 #include "extensions/common/constants.h" | 77 #include "extensions/common/constants.h" |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 using content::BrowserThread; | 80 using content::BrowserThread; |
| 81 using content::RenderViewHost; | 81 using content::RenderViewHost; |
| 82 using content::ResourceRequestInfo; | 82 using content::ResourceRequestInfo; |
| 83 | 83 |
| 84 // By default we don't allow access to all file:// urls on ChromeOS and | |
| 85 // Android. | |
| 86 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | |
| 87 bool ChromeNetworkDelegate::g_allow_file_access_ = false; | |
| 88 #else | |
| 89 bool ChromeNetworkDelegate::g_allow_file_access_ = true; | |
| 90 #endif | |
| 91 | |
| 92 namespace { | 84 namespace { |
| 93 | 85 |
| 94 const char kDNTHeader[] = "DNT"; | 86 const char kDNTHeader[] = "DNT"; |
| 95 | 87 |
| 96 // Gets called when the extensions finish work on the URL. If the extensions | 88 // Gets called when the extensions finish work on the URL. If the extensions |
| 97 // did not do a redirect (so |new_url| is empty) then we enforce the | 89 // did not do a redirect (so |new_url| is empty) then we enforce the |
| 98 // SafeSearch parameters. Otherwise we will get called again after the | 90 // SafeSearch parameters. Otherwise we will get called again after the |
| 99 // redirect and we enforce SafeSearch then. | 91 // redirect and we enforce SafeSearch then. |
| 100 void ForceGoogleSafeSearchCallbackWrapper( | 92 void ForceGoogleSafeSearchCallbackWrapper( |
| 101 const net::CompletionCallback& callback, | 93 const net::CompletionCallback& callback, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 force_youtube_restrict->MoveToThread( | 205 force_youtube_restrict->MoveToThread( |
| 214 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 206 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 215 } | 207 } |
| 216 if (allowed_domains_for_apps) { | 208 if (allowed_domains_for_apps) { |
| 217 allowed_domains_for_apps->Init(prefs::kAllowedDomainsForApps, pref_service); | 209 allowed_domains_for_apps->Init(prefs::kAllowedDomainsForApps, pref_service); |
| 218 allowed_domains_for_apps->MoveToThread( | 210 allowed_domains_for_apps->MoveToThread( |
| 219 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 211 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 220 } | 212 } |
| 221 } | 213 } |
| 222 | 214 |
| 223 // static | |
| 224 void ChromeNetworkDelegate::AllowAccessToAllFiles() { | |
| 225 g_allow_file_access_ = true; | |
| 226 } | |
| 227 | |
| 228 int ChromeNetworkDelegate::OnBeforeURLRequest( | 215 int ChromeNetworkDelegate::OnBeforeURLRequest( |
| 229 net::URLRequest* request, | 216 net::URLRequest* request, |
| 230 const net::CompletionCallback& callback, | 217 const net::CompletionCallback& callback, |
| 231 GURL* new_url) { | 218 GURL* new_url) { |
| 232 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 219 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
| 233 tracked_objects::ScopedTracker tracking_profile1( | 220 tracked_objects::ScopedTracker tracking_profile1( |
| 234 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 221 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 235 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest")); | 222 "456327 URLRequest::ChromeNetworkDelegate::OnBeforeURLRequest")); |
| 236 | 223 |
| 237 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 224 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 info->GetWebContentsGetterForRequest(), | 444 info->GetWebContentsGetterForRequest(), |
| 458 request.url(), request.first_party_for_cookies(), | 445 request.url(), request.first_party_for_cookies(), |
| 459 cookie_line, *options, !allow)); | 446 cookie_line, *options, !allow)); |
| 460 } | 447 } |
| 461 | 448 |
| 462 return allow; | 449 return allow; |
| 463 } | 450 } |
| 464 | 451 |
| 465 bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, | 452 bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, |
| 466 const base::FilePath& path) const { | 453 const base::FilePath& path) const { |
| 467 if (g_allow_file_access_) | |
| 468 return true; | |
| 469 | |
| 470 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 454 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 471 return true; | 455 return true; |
| 472 #else | 456 #else |
| 473 #if defined(OS_CHROMEOS) | 457 #if defined(OS_CHROMEOS) |
| 474 // If we're running Chrome for ChromeOS on Linux, we want to allow file | 458 // If we're running Chrome for ChromeOS on Linux, we want to allow file |
| 475 // access. | 459 // access. |
| 476 if (!base::SysInfo::IsRunningOnChromeOS() || | 460 if (!base::SysInfo::IsRunningOnChromeOS() || |
| 477 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 461 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| 478 return true; | 462 return true; |
| 479 } | 463 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 if (!data_use_aggregator_) | 560 if (!data_use_aggregator_) |
| 577 return; | 561 return; |
| 578 | 562 |
| 579 if (is_data_usage_off_the_record_) { | 563 if (is_data_usage_off_the_record_) { |
| 580 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 564 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 581 return; | 565 return; |
| 582 } | 566 } |
| 583 | 567 |
| 584 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 568 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 585 } | 569 } |
| OLD | NEW |