Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 2067493003: Moving (Can|Grant)AccessFilesOfPageState into RenderFrameHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grant-file-access-after-transfer
Patch Set: Pulling in some changes that got removed from the dependent CL. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_view_host_impl.cc
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 6cbc87ff851bc2a6bea7e1b57499547eaddece07..1d2af2624cc536e81f6360317fc046b32ec0db65 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -930,7 +930,9 @@ void RenderViewHostImpl::OnUpdateState(int32_t page_id,
// Without this check, the renderer can trick the browser into using
// filenames it can't access in a future session restore.
- if (!CanAccessFilesOfPageState(state)) {
+ auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
+ int child_id = GetProcess()->GetID();
+ if (!policy->CanReadAllFiles(child_id, state.GetReferencedFiles())) {
bad_message::ReceivedBadMessage(
GetProcess(), bad_message::RVH_CAN_ACCESS_FILES_OF_PAGE_STATE);
return;
@@ -1222,30 +1224,6 @@ void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) {
#endif
}
-bool RenderViewHostImpl::CanAccessFilesOfPageState(
- const PageState& state) const {
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
-
- const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
- for (const auto& file : file_paths) {
- if (!policy->CanReadFile(GetProcess()->GetID(), file))
- return false;
- }
- return true;
-}
-
-void RenderViewHostImpl::GrantFileAccessFromPageState(const PageState& state) {
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
-
- const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
- for (const auto& file : file_paths) {
- if (!policy->CanReadFile(GetProcess()->GetID(), file))
- policy->GrantReadFile(GetProcess()->GetID(), file);
- }
-}
-
void RenderViewHostImpl::SelectWordAroundCaret() {
Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID()));
}

Powered by Google App Engine
This is Rietveld 408576698