OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 void RenderViewHostImpl::OnUpdateState(int32_t page_id, | 923 void RenderViewHostImpl::OnUpdateState(int32_t page_id, |
924 const PageState& state) { | 924 const PageState& state) { |
925 // If the following DCHECK fails, you have encountered a tricky edge-case that | 925 // If the following DCHECK fails, you have encountered a tricky edge-case that |
926 // has evaded reproduction for a very long time. Please report what you were | 926 // has evaded reproduction for a very long time. Please report what you were |
927 // doing on http://crbug.com/407376, whether or not you can reproduce the | 927 // doing on http://crbug.com/407376, whether or not you can reproduce the |
928 // failure. | 928 // failure. |
929 DCHECK_EQ(page_id, page_id_); | 929 DCHECK_EQ(page_id, page_id_); |
930 | 930 |
931 // Without this check, the renderer can trick the browser into using | 931 // Without this check, the renderer can trick the browser into using |
932 // filenames it can't access in a future session restore. | 932 // filenames it can't access in a future session restore. |
933 if (!CanAccessFilesOfPageState(state)) { | 933 auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); |
| 934 int child_id = GetProcess()->GetID(); |
| 935 if (!policy->CanReadAllFiles(child_id, state.GetReferencedFiles())) { |
934 bad_message::ReceivedBadMessage( | 936 bad_message::ReceivedBadMessage( |
935 GetProcess(), bad_message::RVH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 937 GetProcess(), bad_message::RVH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
936 return; | 938 return; |
937 } | 939 } |
938 | 940 |
939 delegate_->UpdateState(this, page_id, state); | 941 delegate_->UpdateState(this, page_id, state); |
940 } | 942 } |
941 | 943 |
942 void RenderViewHostImpl::OnUpdateTargetURL(const GURL& url) { | 944 void RenderViewHostImpl::OnUpdateTargetURL(const GURL& url) { |
943 if (is_active_) | 945 if (is_active_) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 POINT cursor_pos = {}; | 1217 POINT cursor_pos = {}; |
1216 ::GetCursorPos(&cursor_pos); | 1218 ::GetCursorPos(&cursor_pos); |
1217 float scale = GetScaleFactorForView(GetWidget()->GetView()); | 1219 float scale = GetScaleFactorForView(GetWidget()->GetView()); |
1218 gfx::Point location_dips_screen = | 1220 gfx::Point location_dips_screen = |
1219 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos)); | 1221 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos)); |
1220 if (GetWidget()->GetView()) | 1222 if (GetWidget()->GetView()) |
1221 GetWidget()->GetView()->FocusedNodeTouched(location_dips_screen, editable); | 1223 GetWidget()->GetView()->FocusedNodeTouched(location_dips_screen, editable); |
1222 #endif | 1224 #endif |
1223 } | 1225 } |
1224 | 1226 |
1225 bool RenderViewHostImpl::CanAccessFilesOfPageState( | |
1226 const PageState& state) const { | |
1227 ChildProcessSecurityPolicyImpl* policy = | |
1228 ChildProcessSecurityPolicyImpl::GetInstance(); | |
1229 | |
1230 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | |
1231 for (const auto& file : file_paths) { | |
1232 if (!policy->CanReadFile(GetProcess()->GetID(), file)) | |
1233 return false; | |
1234 } | |
1235 return true; | |
1236 } | |
1237 | |
1238 void RenderViewHostImpl::GrantFileAccessFromPageState(const PageState& state) { | |
1239 ChildProcessSecurityPolicyImpl* policy = | |
1240 ChildProcessSecurityPolicyImpl::GetInstance(); | |
1241 | |
1242 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | |
1243 for (const auto& file : file_paths) { | |
1244 if (!policy->CanReadFile(GetProcess()->GetID(), file)) | |
1245 policy->GrantReadFile(GetProcess()->GetID(), file); | |
1246 } | |
1247 } | |
1248 | |
1249 void RenderViewHostImpl::SelectWordAroundCaret() { | 1227 void RenderViewHostImpl::SelectWordAroundCaret() { |
1250 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1228 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1251 } | 1229 } |
1252 | 1230 |
1253 void RenderViewHostImpl::PostRenderViewReady() { | 1231 void RenderViewHostImpl::PostRenderViewReady() { |
1254 if (GetProcess()->IsReady()) { | 1232 if (GetProcess()->IsReady()) { |
1255 BrowserThread::PostTask( | 1233 BrowserThread::PostTask( |
1256 BrowserThread::UI, | 1234 BrowserThread::UI, |
1257 FROM_HERE, | 1235 FROM_HERE, |
1258 base::Bind(&RenderViewHostImpl::RenderViewReady, | 1236 base::Bind(&RenderViewHostImpl::RenderViewReady, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 // Note: We are using the origin URL provided by the sender here. It may be | 1322 // Note: We are using the origin URL provided by the sender here. It may be |
1345 // different from the receiver's. | 1323 // different from the receiver's. |
1346 file_system_file.url = | 1324 file_system_file.url = |
1347 GURL(storage::GetIsolatedFileSystemRootURIString( | 1325 GURL(storage::GetIsolatedFileSystemRootURIString( |
1348 file_system_url.origin(), filesystem_id, std::string()) | 1326 file_system_url.origin(), filesystem_id, std::string()) |
1349 .append(register_name)); | 1327 .append(register_name)); |
1350 } | 1328 } |
1351 } | 1329 } |
1352 | 1330 |
1353 } // namespace content | 1331 } // namespace content |
OLD | NEW |