Update to new FilesSelectedInChooser API

This commit is contained in:
Cheng Zhao 2015-01-09 18:02:44 -08:00
parent 750db6aed8
commit 715ac35672

View file

@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.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" #include "ui/shell_dialogs/selected_file_info.h"
namespace atom { namespace atom {
@ -26,15 +27,19 @@ WebDialogHelper::~WebDialogHelper() {
void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
const content::FileChooserParams& params) { const content::FileChooserParams& params) {
std::vector<ui::SelectedFileInfo> result; std::vector<content::FileChooserFileInfo> result;
if (params.mode == content::FileChooserParams::Save) { if (params.mode == content::FileChooserParams::Save) {
base::FilePath path; base::FilePath path;
if (file_dialog::ShowSaveDialog(window_, if (file_dialog::ShowSaveDialog(window_,
base::UTF16ToUTF8(params.title), base::UTF16ToUTF8(params.title),
params.default_file_name, params.default_file_name,
file_dialog::Filters(), file_dialog::Filters(),
&path)) &path)) {
result.push_back(ui::SelectedFileInfo(path, path)); content::FileChooserFileInfo info;
info.file_path = path;
info.display_name = path.BaseName().value();
result.push_back(info);
}
} else { } else {
int flags = file_dialog::FILE_DIALOG_CREATE_DIRECTORY; int flags = file_dialog::FILE_DIALOG_CREATE_DIRECTORY;
switch (params.mode) { switch (params.mode) {
@ -57,8 +62,12 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents,
file_dialog::Filters(), file_dialog::Filters(),
flags, flags,
&paths)) &paths))
for (auto& path : paths) for (auto& path : paths) {
result.push_back(ui::SelectedFileInfo(path, path)); content::FileChooserFileInfo info;
info.file_path = path;
info.display_name = path.BaseName().value();
result.push_back(info);
}
} }
web_contents->GetRenderViewHost()->FilesSelectedInChooser( web_contents->GetRenderViewHost()->FilesSelectedInChooser(