| 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 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnBeginNavigation", | 2174 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnBeginNavigation", |
| 2175 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url", | 2175 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url", |
| 2176 common_params.url.possibly_invalid_spec()); | 2176 common_params.url.possibly_invalid_spec()); |
| 2177 | 2177 |
| 2178 CommonNavigationParams validated_params = common_params; | 2178 CommonNavigationParams validated_params = common_params; |
| 2179 GetProcess()->FilterURL(false, &validated_params.url); | 2179 GetProcess()->FilterURL(false, &validated_params.url); |
| 2180 | 2180 |
| 2181 BeginNavigationParams validated_begin_params = begin_params; | 2181 BeginNavigationParams validated_begin_params = begin_params; |
| 2182 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); | 2182 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); |
| 2183 | 2183 |
| 2184 if (!ValidateUploadParams(validated_params)) { |
| 2185 bad_message::ReceivedBadMessage(GetProcess(), |
| 2186 bad_message::RFH_ILLEGAL_UPLOAD_PARAMS); |
| 2187 return; |
| 2188 } |
| 2189 |
| 2184 if (waiting_for_init_) { | 2190 if (waiting_for_init_) { |
| 2185 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( | 2191 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( |
| 2186 validated_params, validated_begin_params); | 2192 validated_params, validated_begin_params); |
| 2187 return; | 2193 return; |
| 2188 } | 2194 } |
| 2189 | 2195 |
| 2190 frame_tree_node()->navigator()->OnBeginNavigation( | 2196 frame_tree_node()->navigator()->OnBeginNavigation( |
| 2191 frame_tree_node(), validated_params, validated_begin_params); | 2197 frame_tree_node(), validated_params, validated_begin_params); |
| 2192 } | 2198 } |
| 2193 | 2199 |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3956 | 3962 |
| 3957 last_committed_site_url_ = site_url; | 3963 last_committed_site_url_ = site_url; |
| 3958 | 3964 |
| 3959 if (!last_committed_site_url_.is_empty()) { | 3965 if (!last_committed_site_url_.is_empty()) { |
| 3960 RenderProcessHostImpl::AddFrameWithSite( | 3966 RenderProcessHostImpl::AddFrameWithSite( |
| 3961 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 3967 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
| 3962 GetProcess(), last_committed_site_url_); | 3968 GetProcess(), last_committed_site_url_); |
| 3963 } | 3969 } |
| 3964 } | 3970 } |
| 3965 | 3971 |
| 3972 bool RenderFrameHostImpl::ValidateUploadParams( |
| 3973 const CommonNavigationParams& common_params) { |
| 3974 if (!common_params.post_data.get()) |
| 3975 return true; |
| 3976 |
| 3977 // Check if the renderer is permitted to upload the requested files. |
| 3978 const std::vector<ResourceRequestBodyImpl::Element>* uploads = |
| 3979 common_params.post_data->elements(); |
| 3980 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; |
| 3981 ChildProcessSecurityPolicyImpl* security_policy = |
| 3982 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 3983 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
| 3984 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
| 3985 !security_policy->CanReadFile(GetProcess()->GetID(), iter->path())) { |
| 3986 return false; |
| 3987 } |
| 3988 if (iter->type() == |
| 3989 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { |
| 3990 StoragePartition* storage_partition = BrowserContext::GetStoragePartition( |
| 3991 GetSiteInstance()->GetBrowserContext(), GetSiteInstance()); |
| 3992 storage::FileSystemURL url = |
| 3993 storage_partition->GetFileSystemContext()->CrackURL( |
| 3994 iter->filesystem_url()); |
| 3995 if (!security_policy->CanReadFileSystemFile(GetProcess()->GetID(), url)) |
| 3996 return false; |
| 3997 } |
| 3998 } |
| 3999 return true; |
| 4000 } |
| 4001 |
| 3966 #if defined(OS_ANDROID) | 4002 #if defined(OS_ANDROID) |
| 3967 | 4003 |
| 3968 class RenderFrameHostImpl::JavaInterfaceProvider | 4004 class RenderFrameHostImpl::JavaInterfaceProvider |
| 3969 : public service_manager::mojom::InterfaceProvider { | 4005 : public service_manager::mojom::InterfaceProvider { |
| 3970 public: | 4006 public: |
| 3971 using BindCallback = | 4007 using BindCallback = |
| 3972 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; | 4008 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; |
| 3973 | 4009 |
| 3974 JavaInterfaceProvider( | 4010 JavaInterfaceProvider( |
| 3975 const BindCallback& bind_callback, | 4011 const BindCallback& bind_callback, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 } | 4056 } |
| 4021 | 4057 |
| 4022 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4058 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 4023 const std::string& interface_name, | 4059 const std::string& interface_name, |
| 4024 mojo::ScopedMessagePipeHandle pipe) { | 4060 mojo::ScopedMessagePipeHandle pipe) { |
| 4025 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4061 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 4026 } | 4062 } |
| 4027 #endif | 4063 #endif |
| 4028 | 4064 |
| 4029 } // namespace content | 4065 } // namespace content |
| OLD | NEW |