| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/browser/api/prefs/pref_member.h" | 10 #include "chrome/browser/api/prefs/pref_member.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "net/http/http_response_headers.h" | 36 #include "net/http/http_response_headers.h" |
| 37 #include "net/socket_stream/socket_stream.h" | 37 #include "net/socket_stream/socket_stream.h" |
| 38 #include "net/url_request/url_request.h" | 38 #include "net/url_request/url_request.h" |
| 39 | 39 |
| 40 #if !defined(OS_ANDROID) | 40 #if !defined(OS_ANDROID) |
| 41 #include "chrome/browser/managed_mode_url_filter.h" | 41 #include "chrome/browser/managed_mode_url_filter.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 45 #include "base/chromeos/chromeos_version.h" | 45 #include "base/chromeos/chromeos_version.h" |
| 46 #include "base/command_line.h" |
| 47 #include "chrome/common/chrome_switches.h" |
| 46 #endif | 48 #endif |
| 47 | 49 |
| 48 #if defined(ENABLE_CONFIGURATION_POLICY) | 50 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 49 #include "chrome/browser/policy/url_blacklist_manager.h" | 51 #include "chrome/browser/policy/url_blacklist_manager.h" |
| 50 #endif | 52 #endif |
| 51 | 53 |
| 52 using content::BrowserThread; | 54 using content::BrowserThread; |
| 53 using content::RenderViewHost; | 55 using content::RenderViewHost; |
| 54 using content::ResourceRequestInfo; | 56 using content::ResourceRequestInfo; |
| 55 | 57 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 const FilePath& path) const { | 360 const FilePath& path) const { |
| 359 if (g_allow_file_access_) | 361 if (g_allow_file_access_) |
| 360 return true; | 362 return true; |
| 361 | 363 |
| 362 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 364 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 363 return true; | 365 return true; |
| 364 #else | 366 #else |
| 365 #if defined(OS_CHROMEOS) | 367 #if defined(OS_CHROMEOS) |
| 366 // If we're running Chrome for ChromeOS on Linux, we want to allow file | 368 // If we're running Chrome for ChromeOS on Linux, we want to allow file |
| 367 // access. | 369 // access. |
| 368 if (!base::chromeos::IsRunningOnChromeOS()) | 370 if (!base::chromeos::IsRunningOnChromeOS() || |
| 371 CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| 369 return true; | 372 return true; |
| 373 } |
| 370 | 374 |
| 371 // Use a whitelist to only allow access to files residing in the list of | 375 // Use a whitelist to only allow access to files residing in the list of |
| 372 // directories below. | 376 // directories below. |
| 373 static const char* const kLocalAccessWhiteList[] = { | 377 static const char* const kLocalAccessWhiteList[] = { |
| 374 "/home/chronos/user/Downloads", | 378 "/home/chronos/user/Downloads", |
| 375 "/home/chronos/user/log", | 379 "/home/chronos/user/log", |
| 376 "/media", | 380 "/media", |
| 377 "/opt/oem", | 381 "/opt/oem", |
| 378 "/usr/share/chromeos-assets", | 382 "/usr/share/chromeos-assets", |
| 379 "/tmp", | 383 "/tmp", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 395 | 399 |
| 396 for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) { | 400 for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) { |
| 397 const FilePath white_listed_path(kLocalAccessWhiteList[i]); | 401 const FilePath white_listed_path(kLocalAccessWhiteList[i]); |
| 398 // FilePath::operator== should probably handle trailing separators. | 402 // FilePath::operator== should probably handle trailing separators. |
| 399 if (white_listed_path == path.StripTrailingSeparators() || | 403 if (white_listed_path == path.StripTrailingSeparators() || |
| 400 white_listed_path.IsParent(path)) { | 404 white_listed_path.IsParent(path)) { |
| 401 return true; | 405 return true; |
| 402 } | 406 } |
| 403 } | 407 } |
| 404 | 408 |
| 409 DVLOG(1) << "File access denied - " << path.value().c_str(); |
| 405 return false; | 410 return false; |
| 406 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 411 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 407 } | 412 } |
| 408 | 413 |
| 409 bool ChromeNetworkDelegate::OnCanThrottleRequest( | 414 bool ChromeNetworkDelegate::OnCanThrottleRequest( |
| 410 const net::URLRequest& request) const { | 415 const net::URLRequest& request) const { |
| 411 if (g_never_throttle_requests_) { | 416 if (g_never_throttle_requests_) { |
| 412 return false; | 417 return false; |
| 413 } | 418 } |
| 414 | 419 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 432 #endif | 437 #endif |
| 433 return net::OK; | 438 return net::OK; |
| 434 } | 439 } |
| 435 | 440 |
| 436 void ChromeNetworkDelegate::OnRequestWaitStateChange( | 441 void ChromeNetworkDelegate::OnRequestWaitStateChange( |
| 437 const net::URLRequest& request, | 442 const net::URLRequest& request, |
| 438 RequestWaitState state) { | 443 RequestWaitState state) { |
| 439 if (load_time_stats_) | 444 if (load_time_stats_) |
| 440 load_time_stats_->OnRequestWaitStateChange(request, state); | 445 load_time_stats_->OnRequestWaitStateChange(request, state); |
| 441 } | 446 } |
| OLD | NEW |