Commit 282db9b4 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Allow access to $HOME/Downloads for linux-chromeos

In linux-chromeos, $HOME/Downloads rather than profile_path is used as
the FilesApp MyFiles directory, and currently these files cannot be
opened in a browser since they are not within the allowed paths.

https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/chromeos/file_manager/path_util.cc;l=247-249;drc=c2dbbeb2f40590e1696e6c853f9e814404be6471

Since linux-chromeos is a testing-only system, we can allow any paths to
be accessed which is helpful for testing such as the current drag and
drop work I am doing.

Bug: 1144138
Change-Id: I34253192270c982bd54c0d1bba33bd81e3532042
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531073Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826524}
parent bb195df3
......@@ -9,6 +9,11 @@
#include "base/path_service.h"
#include "build/build_config.h"
#if defined(OS_CHROMEOS)
#include "base/system/sys_info.h"
#include "chrome/browser/download/download_prefs.h"
#endif
#if defined(OS_ANDROID)
#include "base/android/path_utils.h"
#endif
......@@ -58,6 +63,11 @@ bool IsAccessAllowedInternal(const base::FilePath& path,
const base::FilePath webrtc_logs = profile_path.AppendASCII("WebRTC Logs");
allowlist.push_back(webrtc_logs);
}
// In linux-chromeos, MyFiles dir is at $HOME/Downloads.
if (!base::SysInfo::IsRunningOnChromeOS())
allowlist.push_back(DownloadPrefs::GetDefaultDownloadDirectory());
#elif defined(OS_ANDROID)
// Access to files in external storage is allowed.
base::FilePath external_storage_path;
......
......@@ -10,6 +10,13 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/scoped_set_running_on_chromeos_for_testing.h"
#include "chrome/browser/download/download_prefs.h"
#endif
#if defined(OS_ANDROID)
#include "base/base_paths_android.h"
#endif
......@@ -24,6 +31,12 @@ bool IsAccessAllowed(const std::string& path,
base::FilePath::FromUTF8Unsafe(profile_path));
}
#if defined(OS_CHROMEOS)
const char kLsbRelease[] =
"CHROMEOS_RELEASE_NAME=Chrome OS\n"
"CHROMEOS_RELEASE_VERSION=1.2.3.4\n";
#endif
} // namespace
TEST(ChromeNetworkDelegateStaticTest, IsAccessAllowed) {
......@@ -80,6 +93,16 @@ TEST(ChromeNetworkDelegateStaticTest, IsAccessAllowed) {
EXPECT_FALSE(IsAccessAllowed("/profile/GCache/v2", "/profile"));
EXPECT_FALSE(IsAccessAllowed("/home/chronos/user/GCache/v2/id/Logs", ""));
// $HOME/Downloads is allowed for linux-chromeos, but not on devices.
const std::string& home_downloads =
DownloadPrefs::GetDefaultDownloadDirectory().value();
EXPECT_TRUE(IsAccessAllowed(home_downloads, ""));
{
chromeos::ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease,
base::Time());
EXPECT_FALSE(IsAccessAllowed(home_downloads, ""));
}
#elif defined(OS_ANDROID)
// Android allows the following directories.
EXPECT_TRUE(IsAccessAllowed("/sdcard", ""));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment