Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2446743002: Remove WebFileChooserParams::initialValue (Closed)
Patch Set: Remove defaultName from blink API Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 2325
2326 Send(new FrameHostMsg_RunJavaScriptMessage( 2326 Send(new FrameHostMsg_RunJavaScriptMessage(
2327 routing_id_, message, default_value, frame_url, type, &success, result)); 2327 routing_id_, message, default_value, frame_url, type, &success, result));
2328 return success; 2328 return success;
2329 } 2329 }
2330 2330
2331 bool RenderFrameImpl::ScheduleFileChooser( 2331 bool RenderFrameImpl::ScheduleFileChooser(
2332 const FileChooserParams& params, 2332 const FileChooserParams& params,
2333 blink::WebFileChooserCompletion* completion) { 2333 blink::WebFileChooserCompletion* completion) {
2334 static const size_t kMaximumPendingFileChooseRequests = 4; 2334 static const size_t kMaximumPendingFileChooseRequests = 4;
2335
2336 // Do not open the file dialog in a hidden RenderFrame.
2337 if (IsHidden())
2338 return false;
2339
2335 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { 2340 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) {
2336 // This sanity check prevents too many file choose requests from getting 2341 // This sanity check prevents too many file choose requests from getting
2337 // queued which could DoS the user. Getting these is most likely a 2342 // queued which could DoS the user. Getting these is most likely a
2338 // programming error (there are many ways to DoS the user so it's not 2343 // programming error (there are many ways to DoS the user so it's not
2339 // considered a "real" security check), either in JS requesting many file 2344 // considered a "real" security check), either in JS requesting many file
2340 // choosers to pop up, or in a plugin. 2345 // choosers to pop up, or in a plugin.
2341 // 2346 //
2342 // TODO(brettw): We might possibly want to require a user gesture to open 2347 // TODO(brettw): We might possibly want to require a user gesture to open
2343 // a file picker, which will address this issue in a better way. 2348 // a file picker, which will address this issue in a better way.
2344 return false; 2349 return false;
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
4011 base::string16 ignored_result; 4016 base::string16 ignored_result;
4012 Send(new FrameHostMsg_RunBeforeUnloadConfirm( 4017 Send(new FrameHostMsg_RunBeforeUnloadConfirm(
4013 routing_id_, frame_->document().url(), is_reload, &success, 4018 routing_id_, frame_->document().url(), is_reload, &success,
4014 &ignored_result)); 4019 &ignored_result));
4015 return success; 4020 return success;
4016 } 4021 }
4017 4022
4018 bool RenderFrameImpl::runFileChooser( 4023 bool RenderFrameImpl::runFileChooser(
4019 const blink::WebFileChooserParams& params, 4024 const blink::WebFileChooserParams& params,
4020 blink::WebFileChooserCompletion* chooser_completion) { 4025 blink::WebFileChooserCompletion* chooser_completion) {
4021 // Do not open the file dialog in a hidden RenderFrame.
4022 if (IsHidden())
4023 return false;
4024 4026
4025 FileChooserParams ipc_params; 4027 FileChooserParams ipc_params;
4026 if (params.directory) 4028 if (params.directory)
4027 ipc_params.mode = FileChooserParams::UploadFolder; 4029 ipc_params.mode = FileChooserParams::UploadFolder;
4028 else if (params.multiSelect) 4030 else if (params.multiSelect)
4029 ipc_params.mode = FileChooserParams::OpenMultiple; 4031 ipc_params.mode = FileChooserParams::OpenMultiple;
4030 else if (params.saveAs) 4032 else if (params.saveAs)
4031 ipc_params.mode = FileChooserParams::Save; 4033 ipc_params.mode = FileChooserParams::Save;
4032 else 4034 else
4033 ipc_params.mode = FileChooserParams::Open; 4035 ipc_params.mode = FileChooserParams::Open;
4034 ipc_params.title = params.title; 4036 ipc_params.title = params.title;
4035 ipc_params.default_file_name =
4036 blink::WebStringToFilePath(params.initialValue).BaseName();
4037 ipc_params.accept_types.reserve(params.acceptTypes.size()); 4037 ipc_params.accept_types.reserve(params.acceptTypes.size());
4038 for (const auto& type : params.acceptTypes) 4038 for (const auto& type : params.acceptTypes)
4039 ipc_params.accept_types.push_back(type); 4039 ipc_params.accept_types.push_back(type);
4040 ipc_params.need_local_path = params.needLocalPath; 4040 ipc_params.need_local_path = params.needLocalPath;
4041 #if defined(OS_ANDROID) 4041 #if defined(OS_ANDROID)
4042 ipc_params.capture = params.useMediaCapture; 4042 ipc_params.capture = params.useMediaCapture;
4043 #endif 4043 #endif
4044 ipc_params.requestor = params.requestor; 4044 ipc_params.requestor = params.requestor;
4045 4045
4046 return ScheduleFileChooser(ipc_params, chooser_completion); 4046 return ScheduleFileChooser(ipc_params, chooser_completion);
(...skipping 2527 matching lines...) Expand 10 before | Expand all | Expand 10 after
6574 // event target. Potentially a Pepper plugin will receive the event. 6574 // event target. Potentially a Pepper plugin will receive the event.
6575 // In order to tell whether a plugin gets the last mouse event and which it 6575 // In order to tell whether a plugin gets the last mouse event and which it
6576 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6576 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6577 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6577 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6578 // |pepper_last_mouse_event_target_|. 6578 // |pepper_last_mouse_event_target_|.
6579 pepper_last_mouse_event_target_ = nullptr; 6579 pepper_last_mouse_event_target_ = nullptr;
6580 #endif 6580 #endif
6581 } 6581 }
6582 6582
6583 } // namespace content 6583 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698