Allow file:/// access to the Downloads folders in multi-profile sessions.
We have been whitelisted 'file:///home/chronos/user/Downloads'
on Chrome OS, but the third component may vary from "user"
when multiple profiles are logged into a session.
BUG=309556
Review URL: https://codereview.chromium.org/54053004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232751 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 4ec5a80..ffb7959 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -669,6 +669,17 @@
"/tmp",
"/var/log",
};
+
+ // The actual location of "/home/chronos/user/Downloads" is the Downloads
+ // directory under the profile path ("/home/chronos/user' is a hard link to
+ // current primary logged in profile.) For the support of multi-profile
+ // sessions, we are switching to use explicit "$PROFILE_PATH/Downloads" path
+ // and here whitelist such access.
+ if (!profile_path_.empty()) {
+ const base::FilePath downloads = profile_path_.AppendASCII("Downloads");
+ if (downloads == path.StripTrailingSeparators() || downloads.IsParent(path))
+ return true;
+ }
#elif defined(OS_ANDROID)
// Access to files in external storage is allowed.
base::FilePath external_storage_path;