Merge pull request #2340 from atom/set_download_path_api

Implement setDownloadPath API.
This commit is contained in:
Cheng Zhao 2015-07-29 17:19:02 +08:00
commit 898a838ad7
11 changed files with 76 additions and 9 deletions

View file

@ -15,6 +15,7 @@
#include "base/files/file_path.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/file_chooser_file_info.h"
@ -23,8 +24,6 @@
namespace {
const char kSelectFileLastDirectory[] = "selectfile.last_directory";
file_dialog::Filters GetFileTypesFromAcceptType(
const std::vector<base::string16>& accept_types) {
file_dialog::Filters filters;
@ -112,7 +111,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
window_->web_contents()->GetBrowserContext());
base::FilePath default_file_path = browser_context->prefs()->GetFilePath(
kSelectFileLastDirectory).Append(params.default_file_name);
prefs::kSelectFileLastDirectory).Append(params.default_file_name);
if (file_dialog::ShowOpenDialog(window_,
base::UTF16ToUTF8(params.title),
default_file_path,
@ -126,7 +125,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
result.push_back(info);
}
if (!paths.empty()) {
browser_context->prefs()->SetFilePath(kSelectFileLastDirectory,
browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory,
paths[0].DirName());
}
}