Commit 16e6852d authored by reillyg's avatar reillyg Committed by Commit bot

Move absolute path conversion back to the FILE thread.

In commit 3576d464 the conversion of
the selected directory to an absolute path was moved from
FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread to
FilesSelected. As the latter runs on the UI thread this violated I/O
restrictions and results in a DCHECK. This was not caught by tests
because in the test environment I/O appears to be allowed on the main
thread.

This change splits the call to IsUnderNonNativeLocalPath from the
conversion to an absolute path.

BUG=457841

Review URL: https://codereview.chromium.org/1023793002

Cr-Commit-Position: refs/heads/master@{#321510}
parent e8caff36
...@@ -639,13 +639,10 @@ void FileSystemChooseEntryFunction::FilesSelected( ...@@ -639,13 +639,10 @@ void FileSystemChooseEntryFunction::FilesSelected(
content::WebContents* web_contents = app_window->web_contents(); content::WebContents* web_contents = app_window->web_contents();
DCHECK_EQ(paths.size(), 1u); DCHECK_EQ(paths.size(), 1u);
bool non_native_path = false;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
base::FilePath check_path = non_native_path =
file_manager::util::IsUnderNonNativeLocalPath(GetProfile(), paths[0]) file_manager::util::IsUnderNonNativeLocalPath(GetProfile(), paths[0]);
? paths[0]
: base::MakeAbsoluteFilePath(paths[0]);
#else
base::FilePath check_path = base::MakeAbsoluteFilePath(paths[0]);
#endif #endif
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
...@@ -654,7 +651,7 @@ void FileSystemChooseEntryFunction::FilesSelected( ...@@ -654,7 +651,7 @@ void FileSystemChooseEntryFunction::FilesSelected(
base::Bind( base::Bind(
&FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread, &FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread,
this, this,
check_path, non_native_path,
paths, paths,
web_contents)); web_contents));
return; return;
...@@ -669,9 +666,11 @@ void FileSystemChooseEntryFunction::FileSelectionCanceled() { ...@@ -669,9 +666,11 @@ void FileSystemChooseEntryFunction::FileSelectionCanceled() {
} }
void FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread( void FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread(
const base::FilePath& check_path, bool non_native_path,
const std::vector<base::FilePath>& paths, const std::vector<base::FilePath>& paths,
content::WebContents* web_contents) { content::WebContents* web_contents) {
const base::FilePath check_path =
non_native_path ? paths[0] : base::MakeAbsoluteFilePath(paths[0]);
if (check_path.empty()) { if (check_path.empty()) {
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, content::BrowserThread::UI,
......
...@@ -159,13 +159,13 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction { ...@@ -159,13 +159,13 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction {
void FilesSelected(const std::vector<base::FilePath>& path); void FilesSelected(const std::vector<base::FilePath>& path);
void FileSelectionCanceled(); void FileSelectionCanceled();
// Check if |check_path|, the canonicalized form of the chosen directory // Check if the chosen directory is or is an ancestor of a sensitive
// |paths|, is or is an ancestor of a sensitive directory. If so, show a // directory. If so, show a dialog to confirm that the user wants to open the
// dialog to confirm that the user wants to open the directory. // directory. Calls OnDirectoryAccessConfirmed if the directory isn't
// Calls OnDirectoryAccessConfirmed if the directory isn't sensitive or the // sensitive or the user chooses to open it. Otherwise, calls
// user chooses to open it. Otherwise, calls FileSelectionCanceled. // FileSelectionCanceled.
void ConfirmDirectoryAccessOnFileThread( void ConfirmDirectoryAccessOnFileThread(
const base::FilePath& check_path, bool non_native_path,
const std::vector<base::FilePath>& paths, const std::vector<base::FilePath>& paths,
content::WebContents* web_contents); content::WebContents* web_contents);
void OnDirectoryAccessConfirmed(const std::vector<base::FilePath>& paths); void OnDirectoryAccessConfirmed(const std::vector<base::FilePath>& paths);
......
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