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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1103253003: PlzNavigate: properly set file access permissions on the RFH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 57ba8e25e3fd7eb743d7353b2d3916aae34a1f5e..0e5979ed268550a9d6dd1162e562949dbb5bfa7a 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1601,27 +1601,8 @@ void RenderFrameHostImpl::Navigate(
const StartNavigationParams& start_params,
const RequestNavigationParams& request_params) {
TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate");
- // Browser plugin guests are not allowed to navigate outside web-safe schemes,
- // so do not grant them the ability to request additional URLs.
- if (!GetProcess()->IsIsolatedGuest()) {
- ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
- GetProcess()->GetID(), common_params.url);
- if (common_params.url.SchemeIs(url::kDataScheme) &&
- common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) {
- // If 'data:' is used, and we have a 'file:' base url, grant access to
- // local files.
- ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
- GetProcess()->GetID(), common_params.base_url_for_data_url);
- }
- }
- // We may be returning to an existing NavigationEntry that had been granted
- // file access. If this is a different process, we will need to grant the
- // access again. The files listed in the page state are validated when they
- // are received from the renderer to prevent abuse.
- if (request_params.page_state.IsValid()) {
- render_view_host_->GrantFileAccessFromPageState(request_params.page_state);
- }
+ UpdatePermissionsForNavigation(common_params, request_params);
// Only send the message if we aren't suspended at the start of a cross-site
// request.
@@ -1783,8 +1764,7 @@ void RenderFrameHostImpl::CommitNavigation(
const RequestNavigationParams& request_params) {
DCHECK((response && body.get()) ||
!NavigationRequest::ShouldMakeNetworkRequest(common_params.url));
- // TODO(clamy): Check if we have to add security checks for the browser plugin
- // guests.
+ UpdatePermissionsForNavigation(common_params, request_params);
// Get back to a clean state, in case we start a new navigation without
// completing a RFH swap or unload handler.
@@ -2072,4 +2052,30 @@ void RenderFrameHostImpl::DidUseGeolocationPermission() {
->GetLastCommittedURL().GetOrigin());
}
+void RenderFrameHostImpl::UpdatePermissionsForNavigation(
+ const CommonNavigationParams& common_params,
+ const RequestNavigationParams& request_params) {
+ // Browser plugin guests are not allowed to navigate outside web-safe schemes,
+ // so do not grant them the ability to request additional URLs.
+ if (!GetProcess()->IsIsolatedGuest()) {
+ ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
+ GetProcess()->GetID(), common_params.url);
+ if (common_params.url.SchemeIs(url::kDataScheme) &&
+ common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) {
+ // If 'data:' is used, and we have a 'file:' base url, grant access to
+ // local files.
+ ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
+ GetProcess()->GetID(), common_params.base_url_for_data_url);
+ }
+ }
+
+ // We may be returning to an existing NavigationEntry that had been granted
+ // file access. If this is a different process, we will need to grant the
+ // access again. The files listed in the page state are validated when they
+ // are received from the renderer to prevent abuse.
+ if (request_params.page_state.IsValid()) {
+ render_view_host_->GrantFileAccessFromPageState(request_params.page_state);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698