Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: chrome/browser/file_select_helper.cc

Issue 2450543002: Directory upload: remember the last directory chosen, not its parent (Closed)
Patch Set: Tweak test file paths Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | chrome/browser/file_select_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_select_helper.cc
diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc
index 0d0d8c9372252f1eec11bcde5de14479ab2d6746..0dec597754601110936646b820112a339b69a2f8 100644
--- a/chrome/browser/file_select_helper.cc
+++ b/chrome/browser/file_select_helper.cc
@@ -85,6 +85,9 @@ void DeleteFiles(const std::vector<base::FilePath>& paths) {
bool IsValidProfile(Profile* profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ // No profile manager in unit tests.
+ if (!g_browser_process->profile_manager())
+ return true;
return g_browser_process->profile_manager()->IsValidProfile(profile);
}
@@ -174,8 +177,12 @@ void FileSelectHelper::FileSelectedWithExtraInfo(
const ui::SelectedFileInfo& file,
int index,
void* params) {
- if (IsValidProfile(profile_))
- profile_->set_last_selected_directory(file.file_path.DirName());
+ if (IsValidProfile(profile_)) {
+ base::FilePath path = file.file_path;
+ if (dialog_mode_ != FileChooserParams::UploadFolder)
+ path = path.DirName();
+ profile_->set_last_selected_directory(path);
+ }
if (!render_frame_host_) {
RunFileChooserEnd();
@@ -214,9 +221,12 @@ void FileSelectHelper::MultiFilesSelected(
void FileSelectHelper::MultiFilesSelectedWithExtraInfo(
const std::vector<ui::SelectedFileInfo>& files,
void* params) {
- if (!files.empty() && IsValidProfile(profile_))
- profile_->set_last_selected_directory(files[0].file_path.DirName());
-
+ if (!files.empty() && IsValidProfile(profile_)) {
+ base::FilePath path = files[0].file_path;
+ if (dialog_mode_ != FileChooserParams::UploadFolder)
+ path = path.DirName();
+ profile_->set_last_selected_directory(path);
+ }
#if defined(OS_MACOSX)
content::BrowserThread::PostTask(
content::BrowserThread::FILE_USER_BLOCKING,
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | chrome/browser/file_select_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698