| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 whitelisted_path.IsParent(path)) { | 525 whitelisted_path.IsParent(path)) { |
| 528 return true; | 526 return true; |
| 529 } | 527 } |
| 530 } | 528 } |
| 531 | 529 |
| 532 DVLOG(1) << "File access denied - " << path.value().c_str(); | 530 DVLOG(1) << "File access denied - " << path.value().c_str(); |
| 533 return false; | 531 return false; |
| 534 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 532 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 535 } | 533 } |
| 536 | 534 |
| 535 // static |
| 536 void ChromeNetworkDelegate::EnableAccessToAllFilesForTesting(bool enabled) { |
| 537 g_access_to_all_files_enabled = enabled; |
| 538 } |
| 539 |
| 537 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( | 540 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( |
| 538 const GURL& url, | 541 const GURL& url, |
| 539 const GURL& first_party_for_cookies) const { | 542 const GURL& first_party_for_cookies) const { |
| 540 // nullptr during tests, or when we're running in the system context. | 543 // nullptr during tests, or when we're running in the system context. |
| 541 if (!cookie_settings_.get()) | 544 if (!cookie_settings_.get()) |
| 542 return false; | 545 return false; |
| 543 | 546 |
| 544 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies); | 547 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies); |
| 545 } | 548 } |
| 546 | 549 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 if (!data_use_aggregator_) | 601 if (!data_use_aggregator_) |
| 599 return; | 602 return; |
| 600 | 603 |
| 601 if (is_data_usage_off_the_record_) { | 604 if (is_data_usage_off_the_record_) { |
| 602 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 605 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 603 return; | 606 return; |
| 604 } | 607 } |
| 605 | 608 |
| 606 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 609 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 607 } | 610 } |
| OLD | NEW |