Commit e9f2732b authored by hirono's avatar hirono Committed by Commit bot

Pass needLocalPath flag to file chooser dialog.

blink::WebFileChooserParams has a flag to show whether the receiver
(WebFileChooserCompletion) needs local paths of files or not.

The CL conveys the flag to the file chooser dialog so that the dialog does not
create snapshot file when the receiver does not need local paths.

BUG=126902

Review URL: https://codereview.chromium.org/663293002

Cr-Commit-Position: refs/heads/master@{#300648}
parent d01014df
...@@ -413,6 +413,7 @@ void FileSelectHelper::RunFileChooser(RenderViewHost* render_view_host, ...@@ -413,6 +413,7 @@ void FileSelectHelper::RunFileChooser(RenderViewHost* render_view_host,
void FileSelectHelper::RunFileChooserOnFileThread( void FileSelectHelper::RunFileChooserOnFileThread(
const FileChooserParams& params) { const FileChooserParams& params) {
select_file_types_ = GetFileTypesFromAcceptType(params.accept_types); select_file_types_ = GetFileTypesFromAcceptType(params.accept_types);
select_file_types_->support_drive = !params.need_local_path;
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
......
...@@ -186,6 +186,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::FileChooserParams) ...@@ -186,6 +186,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::FileChooserParams)
IPC_STRUCT_TRAITS_MEMBER(title) IPC_STRUCT_TRAITS_MEMBER(title)
IPC_STRUCT_TRAITS_MEMBER(default_file_name) IPC_STRUCT_TRAITS_MEMBER(default_file_name)
IPC_STRUCT_TRAITS_MEMBER(accept_types) IPC_STRUCT_TRAITS_MEMBER(accept_types)
IPC_STRUCT_TRAITS_MEMBER(need_local_path)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
IPC_STRUCT_TRAITS_MEMBER(capture) IPC_STRUCT_TRAITS_MEMBER(capture)
#endif #endif
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace content { namespace content {
FileChooserParams::FileChooserParams() : mode(Open) { FileChooserParams::FileChooserParams() : mode(Open), need_local_path(true) {
} }
FileChooserParams::~FileChooserParams() { FileChooserParams::~FileChooserParams() {
......
...@@ -46,6 +46,9 @@ struct CONTENT_EXPORT FileChooserParams { ...@@ -46,6 +46,9 @@ struct CONTENT_EXPORT FileChooserParams {
// input element. It is used to restrict selectable files to such types. // input element. It is used to restrict selectable files to such types.
std::vector<base::string16> accept_types; std::vector<base::string16> accept_types;
// Whether the caller needs native file path or not.
bool need_local_path;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// See http://www.w3.org/TR/html-media-capture for more information. // See http://www.w3.org/TR/html-media-capture for more information.
// If true, the data should be obtained using the device's camera/mic/etc. // If true, the data should be obtained using the device's camera/mic/etc.
......
...@@ -141,13 +141,14 @@ int32_t PepperFileChooserHost::OnShow( ...@@ -141,13 +141,14 @@ int32_t PepperFileChooserHost::OnShow(
} else { } else {
params.multiSelect = open_multiple; params.multiSelect = open_multiple;
} }
std::vector<blink::WebString> mine_types(accept_mime_types.size()); std::vector<blink::WebString> mime_types(accept_mime_types.size());
for (size_t i = 0; i < accept_mime_types.size(); i++) { for (size_t i = 0; i < accept_mime_types.size(); i++) {
mine_types[i] = blink::WebString::fromUTF8(accept_mime_types[i].data(), mime_types[i] = blink::WebString::fromUTF8(accept_mime_types[i].data(),
accept_mime_types[i].size()); accept_mime_types[i].size());
} }
params.acceptTypes = mine_types; params.acceptTypes = mime_types;
params.directory = false; params.directory = false;
params.needLocalPath = true;
handler_ = new CompletionHandler(AsWeakPtr()); handler_ = new CompletionHandler(AsWeakPtr());
RenderViewImpl* render_view = static_cast<RenderViewImpl*>( RenderViewImpl* render_view = static_cast<RenderViewImpl*>(
......
...@@ -1807,6 +1807,7 @@ bool RenderViewImpl::runFileChooser( ...@@ -1807,6 +1807,7 @@ bool RenderViewImpl::runFileChooser(
ipc_params.accept_types.reserve(params.acceptTypes.size()); ipc_params.accept_types.reserve(params.acceptTypes.size());
for (size_t i = 0; i < params.acceptTypes.size(); ++i) for (size_t i = 0; i < params.acceptTypes.size(); ++i)
ipc_params.accept_types.push_back(params.acceptTypes[i]); ipc_params.accept_types.push_back(params.acceptTypes[i]);
ipc_params.need_local_path = params.needLocalPath;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
ipc_params.capture = params.useMediaCapture; ipc_params.capture = params.useMediaCapture;
#endif #endif
...@@ -3022,6 +3023,12 @@ void RenderViewImpl::OnFileChooserResponse( ...@@ -3022,6 +3023,12 @@ void RenderViewImpl::OnFileChooserResponse(
selected_file.path = files[i].file_path.AsUTF16Unsafe(); selected_file.path = files[i].file_path.AsUTF16Unsafe();
selected_file.displayName = selected_file.displayName =
base::FilePath(files[i].display_name).AsUTF16Unsafe(); base::FilePath(files[i].display_name).AsUTF16Unsafe();
if (files[i].file_system_url.is_valid()) {
selected_file.fileSystemURL = files[i].file_system_url;
selected_file.length = files[i].length;
selected_file.modificationTime = files[i].modification_time.ToDoubleT();
selected_file.isDirectory = files[i].is_directory;
}
selected_files[i] = selected_file; selected_files[i] = selected_file;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment