Chromium Code Reviews| 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 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2163 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnBeforeNavigation", | 2163 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnBeforeNavigation", |
| 2164 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url", | 2164 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url", |
| 2165 common_params.url.possibly_invalid_spec()); | 2165 common_params.url.possibly_invalid_spec()); |
| 2166 | 2166 |
| 2167 CommonNavigationParams validated_params = common_params; | 2167 CommonNavigationParams validated_params = common_params; |
| 2168 GetProcess()->FilterURL(false, &validated_params.url); | 2168 GetProcess()->FilterURL(false, &validated_params.url); |
| 2169 | 2169 |
| 2170 BeginNavigationParams validated_begin_params = begin_params; | 2170 BeginNavigationParams validated_begin_params = begin_params; |
| 2171 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); | 2171 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); |
| 2172 | 2172 |
| 2173 if (!ValidateUploadParams(validated_params)) { | |
| 2174 bad_message::ReceivedBadMessage(GetProcess(), | |
| 2175 bad_message::RFH_ILLEGAL_UPLOAD_PARAMS); | |
| 2176 return; | |
| 2177 } | |
| 2178 | |
|
Łukasz Anforowicz
2017/05/24 20:24:10
This is unrelated to the bug you are fixing and th
| |
| 2173 if (waiting_for_init_) { | 2179 if (waiting_for_init_) { |
| 2174 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( | 2180 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( |
| 2175 validated_params, validated_begin_params); | 2181 validated_params, validated_begin_params); |
| 2176 return; | 2182 return; |
| 2177 } | 2183 } |
| 2178 | 2184 |
| 2179 frame_tree_node()->navigator()->OnBeginNavigation( | 2185 frame_tree_node()->navigator()->OnBeginNavigation( |
| 2180 frame_tree_node(), validated_params, validated_begin_params); | 2186 frame_tree_node(), validated_params, validated_begin_params); |
| 2181 } | 2187 } |
| 2182 | 2188 |
| (...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3919 false); // is_form_submission | 3925 false); // is_form_submission |
| 3920 } | 3926 } |
| 3921 | 3927 |
| 3922 void RenderFrameHostImpl::BeforeUnloadTimeout() { | 3928 void RenderFrameHostImpl::BeforeUnloadTimeout() { |
| 3923 if (render_view_host_->GetDelegate()->ShouldIgnoreUnresponsiveRenderer()) | 3929 if (render_view_host_->GetDelegate()->ShouldIgnoreUnresponsiveRenderer()) |
| 3924 return; | 3930 return; |
| 3925 | 3931 |
| 3926 SimulateBeforeUnloadAck(); | 3932 SimulateBeforeUnloadAck(); |
| 3927 } | 3933 } |
| 3928 | 3934 |
| 3935 bool RenderFrameHostImpl::ValidateUploadParams( | |
| 3936 const CommonNavigationParams& common_params) { | |
| 3937 if (!common_params.post_data.get()) | |
| 3938 return true; | |
| 3939 | |
| 3940 // Check if the renderer is permitted to upload the requested files. | |
|
Łukasz Anforowicz
2017/05/24 20:24:10
Is there any chance the code below can be abstract
| |
| 3941 const std::vector<ResourceRequestBodyImpl::Element>* uploads = | |
| 3942 common_params.post_data->elements(); | |
| 3943 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; | |
| 3944 ChildProcessSecurityPolicyImpl* security_policy = | |
| 3945 ChildProcessSecurityPolicyImpl::GetInstance(); | |
| 3946 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | |
| 3947 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && | |
| 3948 !security_policy->CanReadFile(GetProcess()->GetID(), iter->path())) { | |
| 3949 return false; | |
| 3950 } | |
| 3951 if (iter->type() == | |
| 3952 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { | |
| 3953 StoragePartition* storage_partition = BrowserContext::GetStoragePartition( | |
| 3954 GetSiteInstance()->GetBrowserContext(), GetSiteInstance()); | |
| 3955 storage::FileSystemURL url = | |
| 3956 storage_partition->GetFileSystemContext()->CrackURL( | |
| 3957 iter->filesystem_url()); | |
| 3958 if (!security_policy->CanReadFileSystemFile(GetProcess()->GetID(), url)) | |
| 3959 return false; | |
| 3960 } | |
| 3961 } | |
| 3962 return true; | |
| 3963 } | |
| 3964 | |
| 3929 #if defined(OS_ANDROID) | 3965 #if defined(OS_ANDROID) |
| 3930 | 3966 |
| 3931 class RenderFrameHostImpl::JavaInterfaceProvider | 3967 class RenderFrameHostImpl::JavaInterfaceProvider |
| 3932 : public service_manager::mojom::InterfaceProvider { | 3968 : public service_manager::mojom::InterfaceProvider { |
| 3933 public: | 3969 public: |
| 3934 using BindCallback = | 3970 using BindCallback = |
| 3935 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; | 3971 base::Callback<void(const std::string&, mojo::ScopedMessagePipeHandle)>; |
| 3936 | 3972 |
| 3937 JavaInterfaceProvider( | 3973 JavaInterfaceProvider( |
| 3938 const BindCallback& bind_callback, | 3974 const BindCallback& bind_callback, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3983 } | 4019 } |
| 3984 | 4020 |
| 3985 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4021 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 3986 const std::string& interface_name, | 4022 const std::string& interface_name, |
| 3987 mojo::ScopedMessagePipeHandle pipe) { | 4023 mojo::ScopedMessagePipeHandle pipe) { |
| 3988 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4024 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 3989 } | 4025 } |
| 3990 #endif | 4026 #endif |
| 3991 | 4027 |
| 3992 } // namespace content | 4028 } // namespace content |
| OLD | NEW |