| 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 BrowserThread::UI, FROM_HERE, | 441 BrowserThread::UI, FROM_HERE, |
| 442 base::Bind(&TabSpecificContentSettings::CookieChanged, | 442 base::Bind(&TabSpecificContentSettings::CookieChanged, |
| 443 info->GetWebContentsGetterForRequest(), | 443 info->GetWebContentsGetterForRequest(), |
| 444 request.url(), request.first_party_for_cookies(), | 444 request.url(), request.first_party_for_cookies(), |
| 445 cookie_line, *options, !allow)); | 445 cookie_line, *options, !allow)); |
| 446 } | 446 } |
| 447 | 447 |
| 448 return allow; | 448 return allow; |
| 449 } | 449 } |
| 450 | 450 |
| 451 bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, | 451 bool ChromeNetworkDelegate::OnCanAccessFile( |
| 452 const base::FilePath& path) const { | 452 const net::URLRequest& request, |
| 453 const base::FilePath& original_path, |
| 454 const base::FilePath& absolute_path) const { |
| 453 #if defined(OS_CHROMEOS) | 455 #if defined(OS_CHROMEOS) |
| 454 // If we're running Chrome for ChromeOS on Linux, we want to allow file | 456 // If we're running Chrome for ChromeOS on Linux, we want to allow file |
| 455 // access. This is checked here to make IsAccessAllowed() unit-testable. | 457 // access. This is checked here to make IsAccessAllowed() unit-testable. |
| 456 if (!base::SysInfo::IsRunningOnChromeOS() || | 458 if (!base::SysInfo::IsRunningOnChromeOS() || |
| 457 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 459 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| 458 return true; | 460 return true; |
| 459 } | 461 } |
| 460 #endif | 462 #endif |
| 461 | 463 |
| 464 #if defined(OS_CHROMEOS) |
| 465 // Use the absolute path on Chrome OS so that symbolic links that point to |
| 466 // paths outside of the whitelist are rejected. |
| 467 const base::FilePath& path = absolute_path; |
| 468 #else |
| 469 // Use the original path on Android. Android's whitelist relies on symbolic |
| 470 // links (ex. /sdcard is whitelisted and commonly a symbolic link). |
| 471 const base::FilePath& path = original_path; |
| 472 #endif |
| 462 return IsAccessAllowed(path, profile_path_); | 473 return IsAccessAllowed(path, profile_path_); |
| 463 } | 474 } |
| 464 | 475 |
| 465 // static | 476 // static |
| 466 bool ChromeNetworkDelegate::IsAccessAllowed( | 477 bool ChromeNetworkDelegate::IsAccessAllowed( |
| 467 const base::FilePath& path, | 478 const base::FilePath& path, |
| 468 const base::FilePath& profile_path) { | 479 const base::FilePath& profile_path) { |
| 469 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 480 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 470 return true; | 481 return true; |
| 471 #else | 482 #else |
| 472 | |
| 473 #if defined(OS_CHROMEOS) | 483 #if defined(OS_CHROMEOS) |
| 474 // Use a whitelist to only allow access to files residing in the list of | 484 // Use a whitelist to only allow access to files residing in the list of |
| 475 // directories below. | 485 // directories below. |
| 476 static const char* const kLocalAccessWhiteList[] = { | 486 static const char* const kLocalAccessWhiteList[] = { |
| 477 "/home/chronos/user/Downloads", | 487 "/home/chronos/user/Downloads", |
| 478 "/home/chronos/user/log", | 488 "/home/chronos/user/log", |
| 479 "/home/chronos/user/WebRTC Logs", | 489 "/home/chronos/user/WebRTC Logs", |
| 480 "/media", | 490 "/media", |
| 481 "/opt/oem", | 491 "/opt/oem", |
| 482 "/usr/share/chromeos-assets", | 492 "/usr/share/chromeos-assets", |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (!data_use_aggregator_) | 565 if (!data_use_aggregator_) |
| 556 return; | 566 return; |
| 557 | 567 |
| 558 if (is_data_usage_off_the_record_) { | 568 if (is_data_usage_off_the_record_) { |
| 559 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 569 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 560 return; | 570 return; |
| 561 } | 571 } |
| 562 | 572 |
| 563 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 573 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 564 } | 574 } |
| OLD | NEW |