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 313d5ee53e953b57bcb3dd52e8718a26dc8e5ef5..dc9b56286e7cb50886b42b29bad8c9a964b5c944 100644 |
| --- a/chrome/browser/ui/webui/net_export_ui.cc |
| +++ b/chrome/browser/ui/webui/net_export_ui.cc |
| @@ -9,11 +9,13 @@ |
| #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" |
| #include "base/values.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/download/download_prefs.h" |
| #include "chrome/browser/platform_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/chrome_select_file_policy.h" |
| @@ -41,6 +43,9 @@ using content::WebUIMessageHandler; |
| namespace { |
| +base::LazyInstance<base::FilePath>::Leaky |
| + last_save_dir = LAZY_INSTANCE_INITIALIZER; |
|
mmenke
2016/11/17 18:50:50
Comment that this may only be accessed on the UI t
wangyix
2016/11/17 19:46:15
Done.
|
| + |
| content::WebUIDataSource* CreateNetExportHTMLSource() { |
| content::WebUIDataSource* source = |
| content::WebUIDataSource::Create(chrome::kChromeUINetExportHost); |
| @@ -194,10 +199,13 @@ 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() ? |
| + DownloadPrefs::FromBrowserContext( |
| + web_ui()->GetWebContents()->GetBrowserContext())->DownloadPath() : |
| + *last_save_dir.Pointer(); |
| + base::FilePath initial_path = |
| + initial_dir.Append(FILE_PATH_LITERAL("chrome-net-export-log.json")); |
| + ShowSelectFileDialog(initial_path); |
| } |
| } |
| @@ -335,6 +343,7 @@ void NetExportMessageHandler::FileSelected(const base::FilePath& path, |
| DCHECK(select_file_dialog_); |
| select_file_dialog_ = nullptr; |
| + *last_save_dir.Pointer() = path.DirName(); |
| BrowserThread::PostTaskAndReply( |
| BrowserThread::FILE_USER_BLOCKING, FROM_HERE, |
| base::Bind(&net_log::NetLogFileWriter::SetUpNetExportLogPath, |