Chromium Code Reviews| Index: chrome/browser/net/chrome_network_delegate.cc |
| diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc |
| index 545d127b789df21079f0aeae4a5142900d437290..61a588c77dc9d25e188c0f48f9dfd872a6e4ab2f 100644 |
| --- a/chrome/browser/net/chrome_network_delegate.cc |
| +++ b/chrome/browser/net/chrome_network_delegate.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/net/chrome_network_delegate.h" |
| +#include "base/chromeos/chromeos_version.h" |
|
achuithb
2012/04/19 20:05:56
Shouldn't this be under #if defined(OS_CHROMEOS)?
Greg Spencer (Chromium)
2012/04/19 20:51:17
Whoops. Yep. Done.
|
| #include "base/logging.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/content_settings/cookie_settings.h" |
| @@ -304,3 +305,43 @@ bool ChromeNetworkDelegate::CanSetCookie( |
| return allow; |
| } |
| + |
| +bool ChromeNetworkDelegate::CanAccessFile(const net::URLRequest* request, |
| + const FilePath& path) { |
| +#if defined(OS_CHROMEOS) |
| + static const char* const kLocalAccessWhiteList[] = { |
|
achuithb
2012/04/19 20:05:56
Could you please add a comment here stating that w
Greg Spencer (Chromium)
2012/04/19 20:51:17
Done.
|
| + "/home/chronos/user/Downloads", |
| + "/home/chronos/user/log", |
| + "/media", |
| + "/opt/oem", |
| + "/usr/share/chromeos-assets", |
| + "/tmp", |
| + "/var/log", |
| + }; |
| + |
| + // If we're running Chrome for ChromeOS on Linux, we want to allow files |
| + // within the user's Downloads directory. |
| + if (!base::chromeos::IsRunningOnChromeOS()) { |
| + const char* home = getenv("HOME"); |
|
achuithb
2012/04/19 20:05:56
I think you should just return true here. We only
Greg Spencer (Chromium)
2012/04/19 20:51:17
Done. I do worry a bit that making it act differe
|
| + if (home && strlen(home) > 0) { |
| + FilePath home_path(home); |
| + home_path = home_path.AppendASCII("Downloads"); |
| + if (home_path.IsParent(path)) |
| + return true; |
| + } |
| + } |
| + |
| + for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) { |
| + const FilePath white_listed_path(kLocalAccessWhiteList[i]); |
| + // FilePath::operator== should probably handle trailing separators. |
| + if (white_listed_path == path.StripTrailingSeparators() || |
| + white_listed_path.IsParent(path)) { |
| + return true; |
| + } |
| + } |
| + return false; |
| +#else // !defined(OS_CHROMEOS) |
| + // On other platforms we allow file:// access by default. |
| + return true; |
| +#endif |
| +} |