| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #if BUILDFLAG(ENABLE_EXTENSIONS) | 75 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 76 #include "extensions/common/constants.h" | 76 #include "extensions/common/constants.h" |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 using content::BrowserThread; | 79 using content::BrowserThread; |
| 80 using content::RenderViewHost; | 80 using content::RenderViewHost; |
| 81 using content::ResourceRequestInfo; | 81 using content::ResourceRequestInfo; |
| 82 | 82 |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| 85 bool g_access_to_all_files_enabled = false; |
| 86 |
| 85 const char kDNTHeader[] = "DNT"; | 87 const char kDNTHeader[] = "DNT"; |
| 86 | 88 |
| 87 // Gets called when the extensions finish work on the URL. If the extensions | 89 // Gets called when the extensions finish work on the URL. If the extensions |
| 88 // did not do a redirect (so |new_url| is empty) then we enforce the | 90 // did not do a redirect (so |new_url| is empty) then we enforce the |
| 89 // SafeSearch parameters. Otherwise we will get called again after the | 91 // SafeSearch parameters. Otherwise we will get called again after the |
| 90 // redirect and we enforce SafeSearch then. | 92 // redirect and we enforce SafeSearch then. |
| 91 void ForceGoogleSafeSearchCallbackWrapper( | 93 void ForceGoogleSafeSearchCallbackWrapper( |
| 92 const net::CompletionCallback& callback, | 94 const net::CompletionCallback& callback, |
| 93 net::URLRequest* request, | 95 net::URLRequest* request, |
| 94 GURL* new_url, | 96 GURL* new_url, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 !allow)); | 446 !allow)); |
| 445 } | 447 } |
| 446 | 448 |
| 447 return allow; | 449 return allow; |
| 448 } | 450 } |
| 449 | 451 |
| 450 bool ChromeNetworkDelegate::OnCanAccessFile( | 452 bool ChromeNetworkDelegate::OnCanAccessFile( |
| 451 const net::URLRequest& request, | 453 const net::URLRequest& request, |
| 452 const base::FilePath& original_path, | 454 const base::FilePath& original_path, |
| 453 const base::FilePath& absolute_path) const { | 455 const base::FilePath& absolute_path) const { |
| 454 #if defined(OS_CHROMEOS) | 456 if (g_access_to_all_files_enabled) |
| 455 // browser_tests and interactive_ui_tests rely on the ability to open any | |
| 456 // files via file: scheme. | |
| 457 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | |
| 458 return true; | 457 return true; |
| 459 #endif | |
| 460 | 458 |
| 461 #if defined(OS_ANDROID) | 459 #if defined(OS_ANDROID) |
| 462 // Android's whitelist relies on symbolic links (ex. /sdcard is whitelisted | 460 // Android's whitelist relies on symbolic links (ex. /sdcard is whitelisted |
| 463 // and commonly a symbolic link), thus do not check absolute paths. | 461 // and commonly a symbolic link), thus do not check absolute paths. |
| 464 return IsAccessAllowed(original_path, profile_path_); | 462 return IsAccessAllowed(original_path, profile_path_); |
| 465 #else | 463 #else |
| 466 return (IsAccessAllowed(original_path, profile_path_) && | 464 return (IsAccessAllowed(original_path, profile_path_) && |
| 467 IsAccessAllowed(absolute_path, profile_path_)); | 465 IsAccessAllowed(absolute_path, profile_path_)); |
| 468 #endif | 466 #endif |
| 469 } | 467 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 white_listed_path.IsParent(path)) { | 524 white_listed_path.IsParent(path)) { |
| 527 return true; | 525 return true; |
| 528 } | 526 } |
| 529 } | 527 } |
| 530 | 528 |
| 531 DVLOG(1) << "File access denied - " << path.value().c_str(); | 529 DVLOG(1) << "File access denied - " << path.value().c_str(); |
| 532 return false; | 530 return false; |
| 533 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 531 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 534 } | 532 } |
| 535 | 533 |
| 534 // static |
| 535 void ChromeNetworkDelegate::EnableAccessToAllFilesForTesting(bool enabled) { |
| 536 g_access_to_all_files_enabled = enabled; |
| 537 } |
| 538 |
| 536 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( | 539 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( |
| 537 const GURL& url, | 540 const GURL& url, |
| 538 const GURL& first_party_for_cookies) const { | 541 const GURL& first_party_for_cookies) const { |
| 539 // nullptr during tests, or when we're running in the system context. | 542 // nullptr during tests, or when we're running in the system context. |
| 540 if (!cookie_settings_.get()) | 543 if (!cookie_settings_.get()) |
| 541 return false; | 544 return false; |
| 542 | 545 |
| 543 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies); | 546 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies); |
| 544 } | 547 } |
| 545 | 548 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (!data_use_aggregator_) | 600 if (!data_use_aggregator_) |
| 598 return; | 601 return; |
| 599 | 602 |
| 600 if (is_data_usage_off_the_record_) { | 603 if (is_data_usage_off_the_record_) { |
| 601 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 604 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 602 return; | 605 return; |
| 603 } | 606 } |
| 604 | 607 |
| 605 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 608 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 606 } | 609 } |
| OLD | NEW |