Chromium Code Reviews| Index: chrome/browser/ui/webui/net_export_ui.cc |
| diff --git a/chrome/browser/ui/webui/net_export_ui.cc b/chrome/browser/ui/webui/net_export_ui.cc |
| index 8ac8368d50813a077127c3847534ffaed689375e..8caf3f16282486f503db69c8b69a383e28e5c916 100644 |
| --- a/chrome/browser/ui/webui/net_export_ui.cc |
| +++ b/chrome/browser/ui/webui/net_export_ui.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/bind.h" |
| #include "base/files/file_util.h" |
| +#include "base/lazy_instance.h" |
| #include "base/macros.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -41,6 +42,9 @@ using content::WebUIMessageHandler; |
| namespace { |
| +base::LazyInstance<base::FilePath>::Leaky |
| + last_save_dir = LAZY_INSTANCE_INITIALIZER; |
| + |
| content::WebUIDataSource* CreateNetExportHTMLSource() { |
| content::WebUIDataSource* source = |
| content::WebUIDataSource::Create(chrome::kChromeUINetExportHost); |
| @@ -194,10 +198,12 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) { |
| if (UsingMobileUI()) { |
| StartNetLog(); |
| } else { |
| - base::FilePath home_dir = base::GetHomeDir(); |
| - base::FilePath default_path = |
| - home_dir.Append(FILE_PATH_LITERAL("chrome-net-export-log.json")); |
| - ShowSelectFileDialog(default_path); |
| + base::FilePath initial_dir = |
| + last_save_dir.Pointer()->empty() ? base::GetHomeDir() |
| + : *last_save_dir.Pointer(); |
| + base::FilePath initial_path = |
| + initial_dir.Append(FILE_PATH_LITERAL("chrome-net-export-log.json")); |
| + ShowSelectFileDialog(initial_path); |
|
mmenke
2016/10/24 17:04:55
This will show the home directory every time Chrom
wangyix
2016/10/24 23:35:15
I'm working on Goobuntu, and the behavior is the f
|
| } |
| } |
| @@ -327,6 +333,7 @@ void NetExportMessageHandler::ShowSelectFileDialog( |
| gfx::NativeWindow owning_window = |
| webcontents ? webcontents->GetTopLevelNativeWindow() |
| : nullptr; |
| + |
| select_file_dialog_->SelectFile( |
| ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(), default_path, |
| &file_type_info, 0, base::FilePath::StringType(), owning_window, nullptr); |
| @@ -336,6 +343,8 @@ void NetExportMessageHandler::FileSelected(const base::FilePath& path, |
| int index, |
| void* params) { |
| select_file_dialog_ = nullptr; |
| + *last_save_dir.Pointer() = path.DirName(); |
| + |
| BrowserThread::PostTaskAndReply( |
| BrowserThread::FILE_USER_BLOCKING, FROM_HERE, |
| base::Bind(&net_log::NetLogFileWriter::SetUpNetExportLogPath, |