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 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 GetProcess()->FilterURL(false, &validated_params.url); | 2201 GetProcess()->FilterURL(false, &validated_params.url); |
2202 if (!validated_params.base_url_for_data_url.is_empty()) { | 2202 if (!validated_params.base_url_for_data_url.is_empty()) { |
2203 // Kills the process. http://crbug.com/726142 | 2203 // Kills the process. http://crbug.com/726142 |
2204 bad_message::ReceivedBadMessage( | 2204 bad_message::ReceivedBadMessage( |
2205 GetProcess(), bad_message::RFH_BASE_URL_FOR_DATA_URL_SPECIFIED); | 2205 GetProcess(), bad_message::RFH_BASE_URL_FOR_DATA_URL_SPECIFIED); |
2206 } | 2206 } |
2207 | 2207 |
2208 BeginNavigationParams validated_begin_params = begin_params; | 2208 BeginNavigationParams validated_begin_params = begin_params; |
2209 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); | 2209 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); |
2210 | 2210 |
2211 if (!ValidateUploadParams(validated_params)) { | 2211 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadRequestBody( |
| 2212 GetSiteInstance(), validated_params.post_data)) { |
2212 bad_message::ReceivedBadMessage(GetProcess(), | 2213 bad_message::ReceivedBadMessage(GetProcess(), |
2213 bad_message::RFH_ILLEGAL_UPLOAD_PARAMS); | 2214 bad_message::RFH_ILLEGAL_UPLOAD_PARAMS); |
2214 return; | 2215 return; |
2215 } | 2216 } |
2216 | 2217 |
2217 if (waiting_for_init_) { | 2218 if (waiting_for_init_) { |
2218 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( | 2219 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( |
2219 validated_params, validated_begin_params); | 2220 validated_params, validated_begin_params); |
2220 return; | 2221 return; |
2221 } | 2222 } |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4000 | 4001 |
4001 last_committed_site_url_ = site_url; | 4002 last_committed_site_url_ = site_url; |
4002 | 4003 |
4003 if (!last_committed_site_url_.is_empty()) { | 4004 if (!last_committed_site_url_.is_empty()) { |
4004 RenderProcessHostImpl::AddFrameWithSite( | 4005 RenderProcessHostImpl::AddFrameWithSite( |
4005 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 4006 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
4006 GetProcess(), last_committed_site_url_); | 4007 GetProcess(), last_committed_site_url_); |
4007 } | 4008 } |
4008 } | 4009 } |
4009 | 4010 |
4010 bool RenderFrameHostImpl::ValidateUploadParams( | |
4011 const CommonNavigationParams& common_params) { | |
4012 if (!common_params.post_data.get()) | |
4013 return true; | |
4014 | |
4015 // Check if the renderer is permitted to upload the requested files. | |
4016 const std::vector<ResourceRequestBodyImpl::Element>* uploads = | |
4017 common_params.post_data->elements(); | |
4018 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; | |
4019 ChildProcessSecurityPolicyImpl* security_policy = | |
4020 ChildProcessSecurityPolicyImpl::GetInstance(); | |
4021 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | |
4022 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && | |
4023 !security_policy->CanReadFile(GetProcess()->GetID(), iter->path())) { | |
4024 return false; | |
4025 } | |
4026 if (iter->type() == | |
4027 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { | |
4028 StoragePartition* storage_partition = BrowserContext::GetStoragePartition( | |
4029 GetSiteInstance()->GetBrowserContext(), GetSiteInstance()); | |
4030 storage::FileSystemURL url = | |
4031 storage_partition->GetFileSystemContext()->CrackURL( | |
4032 iter->filesystem_url()); | |
4033 if (!security_policy->CanReadFileSystemFile(GetProcess()->GetID(), url)) | |
4034 return false; | |
4035 } | |
4036 } | |
4037 return true; | |
4038 } | |
4039 | |
4040 #if defined(OS_ANDROID) | 4011 #if defined(OS_ANDROID) |
4041 | 4012 |
4042 class RenderFrameHostImpl::JavaInterfaceProvider | 4013 class RenderFrameHostImpl::JavaInterfaceProvider |
4043 : public service_manager::mojom::InterfaceProvider { | 4014 : public service_manager::mojom::InterfaceProvider { |
4044 public: | 4015 public: |
4045 using BindCallback = | 4016 using BindCallback = |
4046 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; | 4017 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; |
4047 | 4018 |
4048 JavaInterfaceProvider( | 4019 JavaInterfaceProvider( |
4049 const BindCallback& bind_callback, | 4020 const BindCallback& bind_callback, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4094 } | 4065 } |
4095 | 4066 |
4096 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4067 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
4097 const std::string& interface_name, | 4068 const std::string& interface_name, |
4098 mojo::ScopedMessagePipeHandle pipe) { | 4069 mojo::ScopedMessagePipeHandle pipe) { |
4099 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4070 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
4100 } | 4071 } |
4101 #endif | 4072 #endif |
4102 | 4073 |
4103 } // namespace content | 4074 } // namespace content |
OLD | NEW |