From 715ac3567291baeab15bc0de2e58f2163acdeff0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Jan 2015 18:02:44 -0800 Subject: [PATCH] Update to new FilesSelectedInChooser API --- atom/browser/web_dialog_helper.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index df600c37f149..94b26d099d09 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -12,6 +12,7 @@ #include "base/strings/utf_string_conversions.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" #include "ui/shell_dialogs/selected_file_info.h" namespace atom { @@ -26,15 +27,19 @@ WebDialogHelper::~WebDialogHelper() { void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, const content::FileChooserParams& params) { - std::vector result; + std::vector result; if (params.mode == content::FileChooserParams::Save) { base::FilePath path; if (file_dialog::ShowSaveDialog(window_, base::UTF16ToUTF8(params.title), params.default_file_name, file_dialog::Filters(), - &path)) - result.push_back(ui::SelectedFileInfo(path, path)); + &path)) { + content::FileChooserFileInfo info; + info.file_path = path; + info.display_name = path.BaseName().value(); + result.push_back(info); + } } else { int flags = file_dialog::FILE_DIALOG_CREATE_DIRECTORY; switch (params.mode) { @@ -57,8 +62,12 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, file_dialog::Filters(), flags, &paths)) - for (auto& path : paths) - result.push_back(ui::SelectedFileInfo(path, path)); + for (auto& path : paths) { + content::FileChooserFileInfo info; + info.file_path = path; + info.display_name = path.BaseName().value(); + result.push_back(info); + } } web_contents->GetRenderViewHost()->FilesSelectedInChooser(