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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 837283003: Start replicating sandbox flags for OOPIF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add conversion functions for SandboxFlags Created 5 years, 11 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/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 7258dbb97d8338997e601ae19c18429750a3aa09..52b08922ac5fcedef2ed07c86f7c6a02d12de2d7 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -489,8 +489,63 @@ media::Context3D GetSharedMainThreadContext3D() {
RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl =
nullptr;
-} // namespace
+// Check that blink::WebSandboxFlags is kept in sync with
+// content::SandboxFlags.
+COMPILE_ASSERT(blink::WebSandboxFlags::None ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::NONE),
Charlie Reis 2015/01/12 20:25:12 nit: No need for content:: here since we're alread
alexmos 2015/01/14 19:35:19 Done. Removed unnecessary content::, but couldn't
Charlie Reis 2015/01/14 19:46:45 Huh, I guess that's why people cast both sides to
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Navigation ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::NAVIGATION),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Plugins ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::PLUGINS),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Origin ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::ORIGIN),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Forms ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::FORMS),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Scripts ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::SCRIPTS),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::TopNavigation ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::TOP_NAVIGATION),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::Popups ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::POPUPS),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(
+ blink::WebSandboxFlags::AutomaticFeatures ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::AUTOMATIC_FEATURES),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::PointerLock ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::POINTER_LOCK),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::DocumentDomain ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::DOCUMENT_DOMAIN),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::OrientationLock ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::ORIENTATION_LOCK),
+ enum_values_must_match_for_sandbox_flags);
+COMPILE_ASSERT(blink::WebSandboxFlags::All ==
+ static_cast<blink::WebSandboxFlags>(
+ content::SandboxFlags::ALL),
+ enum_values_must_match_for_sandbox_flags);
+} // namespace
// static
RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
@@ -513,9 +568,11 @@ RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) {
}
// static
-void RenderFrameImpl::CreateFrame(int routing_id,
- int parent_routing_id,
- int proxy_routing_id) {
+void RenderFrameImpl::CreateFrame(
+ int routing_id,
+ int parent_routing_id,
+ int proxy_routing_id,
+ const FrameReplicationState& replicated_state) {
// TODO(nasko): For now, this message is only sent for subframes, as the
// top level frame is created when the RenderView is created through the
// ViewMsg_New IPC.
@@ -534,7 +591,9 @@ void RenderFrameImpl::CreateFrame(int routing_id,
// Create the RenderFrame and WebLocalFrame, linking the two.
render_frame =
RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
- web_frame = parent_web_frame->createLocalChild("", render_frame);
+ web_frame = parent_web_frame->createLocalChild("",
+ ContentToWebSandboxFlags(replicated_state.sandbox_flags),
+ render_frame);
} else {
RenderFrameProxy* proxy =
RenderFrameProxy::FromRoutingID(proxy_routing_id);
@@ -568,6 +627,19 @@ void RenderFrameImpl::InstallCreateHook(
g_create_render_frame_impl = create_render_frame_impl;
}
+// static
+content::SandboxFlags RenderFrameImpl::WebToContentSandboxFlags(
+ blink::WebSandboxFlags flags) {
+ return static_cast<content::SandboxFlags>(flags);
+}
+
+// static
+blink::WebSandboxFlags RenderFrameImpl::ContentToWebSandboxFlags(
+ content::SandboxFlags flags) {
+ return static_cast<blink::WebSandboxFlags>(flags);
+}
+
+
// RenderFrameImpl ----------------------------------------------------------
RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id)
: frame_(NULL),
@@ -1937,15 +2009,26 @@ void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) {
Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
}
+// TODO(alexmos): Remove once Blink is updated to use the version that takes
+// sandbox flags.
blink::WebFrame* RenderFrameImpl::createChildFrame(
blink::WebLocalFrame* parent,
const blink::WebString& name) {
+ return createChildFrame(parent, name, blink::WebSandboxFlags::None);
+}
+
+blink::WebFrame* RenderFrameImpl::createChildFrame(
+ blink::WebLocalFrame* parent,
+ const blink::WebString& name,
+ blink::WebSandboxFlags sandbox_flags) {
// Synchronously notify the browser of a child frame creation to get the
// routing_id for the RenderFrame.
int child_routing_id = MSG_ROUTING_NONE;
- CHECK(Send(new FrameHostMsg_CreateChildFrame(routing_id_,
- base::UTF16ToUTF8(name),
- &child_routing_id)));
+ CHECK(Send(new FrameHostMsg_CreateChildFrame(
+ routing_id_,
+ base::UTF16ToUTF8(name),
+ WebToContentSandboxFlags(sandbox_flags),
+ &child_routing_id)));
// Allocation of routing id failed, so we can't create a child frame. This can
// happen if this RenderFrameImpl's IPCs are being filtered when in swapped

Powered by Google App Engine
This is Rietveld 408576698