| OLD | NEW |
| 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 3199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 return frame_tree_node_->render_manager()->GetProxyCount(); | 3210 return frame_tree_node_->render_manager()->GetProxyCount(); |
| 3211 } | 3211 } |
| 3212 | 3212 |
| 3213 void RenderFrameHostImpl::FilesSelectedInChooser( | 3213 void RenderFrameHostImpl::FilesSelectedInChooser( |
| 3214 const std::vector<content::FileChooserFileInfo>& files, | 3214 const std::vector<content::FileChooserFileInfo>& files, |
| 3215 FileChooserParams::Mode permissions) { | 3215 FileChooserParams::Mode permissions) { |
| 3216 storage::FileSystemContext* const file_system_context = | 3216 storage::FileSystemContext* const file_system_context = |
| 3217 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), | 3217 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), |
| 3218 GetSiteInstance()) | 3218 GetSiteInstance()) |
| 3219 ->GetFileSystemContext(); | 3219 ->GetFileSystemContext(); |
| 3220 |
| 3221 // Exclude files whose paths can't be converted into WebStrings, which we can |
| 3222 // approximate with AsUTF8Unsafe. Blink won't be able to handle these, and we |
| 3223 // would kill the renderer when it claims to have chosen an empty file path. |
| 3224 std::vector<content::FileChooserFileInfo> filtered_files; |
| 3225 for (const auto& file : files) { |
| 3226 if (!file.file_path.AsUTF8Unsafe().empty()) |
| 3227 filtered_files.push_back(file); |
| 3228 } |
| 3229 |
| 3220 // Grant the security access requested to the given files. | 3230 // Grant the security access requested to the given files. |
| 3221 for (const auto& file : files) { | 3231 for (const auto& file : filtered_files) { |
| 3222 if (permissions == FileChooserParams::Save) { | 3232 if (permissions == FileChooserParams::Save) { |
| 3223 ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile( | 3233 ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile( |
| 3224 GetProcess()->GetID(), file.file_path); | 3234 GetProcess()->GetID(), file.file_path); |
| 3225 } else { | 3235 } else { |
| 3226 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 3236 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 3227 GetProcess()->GetID(), file.file_path); | 3237 GetProcess()->GetID(), file.file_path); |
| 3228 } | 3238 } |
| 3229 if (file.file_system_url.is_valid()) { | 3239 if (file.file_system_url.is_valid()) { |
| 3230 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( | 3240 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( |
| 3231 GetProcess()->GetID(), | 3241 GetProcess()->GetID(), |
| 3232 file_system_context->CrackURL(file.file_system_url) | 3242 file_system_context->CrackURL(file.file_system_url) |
| 3233 .mount_filesystem_id()); | 3243 .mount_filesystem_id()); |
| 3234 } | 3244 } |
| 3235 } | 3245 } |
| 3236 | 3246 |
| 3237 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); | 3247 Send(new FrameMsg_RunFileChooserResponse(routing_id_, filtered_files)); |
| 3238 } | 3248 } |
| 3239 | 3249 |
| 3240 bool RenderFrameHostImpl::HasSelection() { | 3250 bool RenderFrameHostImpl::HasSelection() { |
| 3241 return has_selection_; | 3251 return has_selection_; |
| 3242 } | 3252 } |
| 3243 | 3253 |
| 3244 void RenderFrameHostImpl::GetInterfaceProvider( | 3254 void RenderFrameHostImpl::GetInterfaceProvider( |
| 3245 service_manager::mojom::InterfaceProviderRequest interfaces) { | 3255 service_manager::mojom::InterfaceProviderRequest interfaces) { |
| 3246 service_manager::InterfaceProviderSpec browser_spec, renderer_spec; | 3256 service_manager::InterfaceProviderSpec browser_spec, renderer_spec; |
| 3247 // TODO(beng): CHECK these return true. | 3257 // TODO(beng): CHECK these return true. |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3698 } | 3708 } |
| 3699 | 3709 |
| 3700 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 3710 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 3701 const std::string& interface_name, | 3711 const std::string& interface_name, |
| 3702 mojo::ScopedMessagePipeHandle pipe) { | 3712 mojo::ScopedMessagePipeHandle pipe) { |
| 3703 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 3713 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 3704 } | 3714 } |
| 3705 #endif | 3715 #endif |
| 3706 | 3716 |
| 3707 } // namespace content | 3717 } // namespace content |
| OLD | NEW |