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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 params.referrer = Referrer( 470 params.referrer = Referrer(
471 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 471 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
472 request->referrerPolicy()); 472 request->referrerPolicy());
473 params.transition = extra_data->transition_type(); 473 params.transition = extra_data->transition_type();
474 return params; 474 return params;
475 } 475 }
476 476
477 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = 477 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl =
478 nullptr; 478 nullptr;
479 479
480 // Check that blink::WebSandboxFlags is kept in sync with
Charlie Reis 2015/01/08 22:17:26 I haven't dealt with these much before, but it loo
alexmos 2015/01/09 20:43:25 Done. I put them as static functions in RenderFra
481 // content::SandboxFlags.
482 COMPILE_ASSERT(blink::WebSandboxNone ==
483 static_cast<blink::WebSandboxFlags>(
484 content::SandboxFlags::NONE),
485 enum_values_must_match_for_sandbox_flags);
486 COMPILE_ASSERT(blink::WebSandboxNavigation ==
487 static_cast<blink::WebSandboxFlags>(
488 content::SandboxFlags::NAVIGATION),
489 enum_values_must_match_for_sandbox_flags);
490 COMPILE_ASSERT(blink::WebSandboxPlugins ==
491 static_cast<blink::WebSandboxFlags>(
492 content::SandboxFlags::PLUGINS),
493 enum_values_must_match_for_sandbox_flags);
494 COMPILE_ASSERT(blink::WebSandboxOrigin ==
495 static_cast<blink::WebSandboxFlags>(
496 content::SandboxFlags::ORIGIN),
497 enum_values_must_match_for_sandbox_flags);
498 COMPILE_ASSERT(blink::WebSandboxForms ==
499 static_cast<blink::WebSandboxFlags>(
500 content::SandboxFlags::FORMS),
501 enum_values_must_match_for_sandbox_flags);
502 COMPILE_ASSERT(blink::WebSandboxScripts ==
503 static_cast<blink::WebSandboxFlags>(
504 content::SandboxFlags::SCRIPTS),
505 enum_values_must_match_for_sandbox_flags);
506 COMPILE_ASSERT(blink::WebSandboxTopNavigation ==
507 static_cast<blink::WebSandboxFlags>(
508 content::SandboxFlags::TOP_NAVIGATION),
509 enum_values_must_match_for_sandbox_flags);
510 COMPILE_ASSERT(blink::WebSandboxPopups ==
511 static_cast<blink::WebSandboxFlags>(
512 content::SandboxFlags::POPUPS),
513 enum_values_must_match_for_sandbox_flags);
514 COMPILE_ASSERT(
515 blink::WebSandboxAutomaticFeatures ==
516 static_cast<blink::WebSandboxFlags>(
517 content::SandboxFlags::AUTOMATIC_FEATURES),
518 enum_values_must_match_for_sandbox_flags);
519 COMPILE_ASSERT(blink::WebSandboxPointerLock ==
520 static_cast<blink::WebSandboxFlags>(
521 content::SandboxFlags::POINTER_LOCK),
522 enum_values_must_match_for_sandbox_flags);
523 COMPILE_ASSERT(blink::WebSandboxDocumentDomain ==
524 static_cast<blink::WebSandboxFlags>(
525 content::SandboxFlags::DOCUMENT_DOMAIN),
526 enum_values_must_match_for_sandbox_flags);
527 COMPILE_ASSERT(blink::WebSandboxOrientationLock ==
528 static_cast<blink::WebSandboxFlags>(
529 content::SandboxFlags::ORIENTATION_LOCK),
530 enum_values_must_match_for_sandbox_flags);
531 COMPILE_ASSERT(blink::WebSandboxAll ==
532 static_cast<blink::WebSandboxFlags>(
533 content::SandboxFlags::ALL),
534 enum_values_must_match_for_sandbox_flags);
480 } // namespace 535 } // namespace
481 536
482 537
483 // static 538 // static
484 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 539 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
485 int32 routing_id) { 540 int32 routing_id) {
486 DCHECK(routing_id != MSG_ROUTING_NONE); 541 DCHECK(routing_id != MSG_ROUTING_NONE);
487 542
488 if (g_create_render_frame_impl) 543 if (g_create_render_frame_impl)
489 return g_create_render_frame_impl(render_view, routing_id); 544 return g_create_render_frame_impl(render_view, routing_id);
490 else 545 else
491 return new RenderFrameImpl(render_view, routing_id); 546 return new RenderFrameImpl(render_view, routing_id);
492 } 547 }
493 548
494 // static 549 // static
495 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { 550 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) {
496 RoutingIDFrameMap::iterator iter = 551 RoutingIDFrameMap::iterator iter =
497 g_routing_id_frame_map.Get().find(routing_id); 552 g_routing_id_frame_map.Get().find(routing_id);
498 if (iter != g_routing_id_frame_map.Get().end()) 553 if (iter != g_routing_id_frame_map.Get().end())
499 return iter->second; 554 return iter->second;
500 return NULL; 555 return NULL;
501 } 556 }
502 557
503 // static 558 // static
504 void RenderFrameImpl::CreateFrame(int routing_id, 559 void RenderFrameImpl::CreateFrame(
505 int parent_routing_id, 560 int routing_id,
506 int proxy_routing_id) { 561 int parent_routing_id,
562 int proxy_routing_id,
563 const FrameReplicationState& replicated_state) {
507 // TODO(nasko): For now, this message is only sent for subframes, as the 564 // TODO(nasko): For now, this message is only sent for subframes, as the
508 // top level frame is created when the RenderView is created through the 565 // top level frame is created when the RenderView is created through the
509 // ViewMsg_New IPC. 566 // ViewMsg_New IPC.
510 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id); 567 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
511 568
512 blink::WebLocalFrame* web_frame; 569 blink::WebLocalFrame* web_frame;
513 RenderFrameImpl* render_frame; 570 RenderFrameImpl* render_frame;
514 if (proxy_routing_id == MSG_ROUTING_NONE) { 571 if (proxy_routing_id == MSG_ROUTING_NONE) {
515 RenderFrameProxy* parent_proxy = 572 RenderFrameProxy* parent_proxy =
516 RenderFrameProxy::FromRoutingID(parent_routing_id); 573 RenderFrameProxy::FromRoutingID(parent_routing_id);
517 // If the browser is sending a valid parent routing id, it should already 574 // If the browser is sending a valid parent routing id, it should already
518 // be created and registered. 575 // be created and registered.
519 CHECK(parent_proxy); 576 CHECK(parent_proxy);
520 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); 577 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame();
521 578
522 // Create the RenderFrame and WebLocalFrame, linking the two. 579 // Create the RenderFrame and WebLocalFrame, linking the two.
523 render_frame = 580 render_frame =
524 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); 581 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
525 web_frame = parent_web_frame->createLocalChild("", render_frame); 582 web_frame = parent_web_frame->createLocalChild("",
583 static_cast<blink::WebSandboxFlags>(replicated_state.sandbox_flags),
584 render_frame);
526 } else { 585 } else {
527 RenderFrameProxy* proxy = 586 RenderFrameProxy* proxy =
528 RenderFrameProxy::FromRoutingID(proxy_routing_id); 587 RenderFrameProxy::FromRoutingID(proxy_routing_id);
529 CHECK(proxy); 588 CHECK(proxy);
530 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 589 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
531 web_frame = blink::WebLocalFrame::create(render_frame); 590 web_frame = blink::WebLocalFrame::create(render_frame);
532 render_frame->proxy_routing_id_ = proxy_routing_id; 591 render_frame->proxy_routing_id_ = proxy_routing_id;
533 web_frame->initializeToReplaceRemoteFrame(proxy->web_frame()); 592 web_frame->initializeToReplaceRemoteFrame(proxy->web_frame());
534 } 593 }
535 render_frame->SetWebFrame(web_frame); 594 render_frame->SetWebFrame(web_frame);
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 } 1976 }
1918 1977
1919 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) { 1978 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) {
1920 DCHECK(!frame_ || frame_ == frame); 1979 DCHECK(!frame_ || frame_ == frame);
1921 // Notify the browser process that it is no longer safe to show the pending 1980 // Notify the browser process that it is no longer safe to show the pending
1922 // URL of the main frame, since a URL spoof is now possible. 1981 // URL of the main frame, since a URL spoof is now possible.
1923 if (!frame->parent() && render_view_->page_id_ == -1) 1982 if (!frame->parent() && render_view_->page_id_ == -1)
1924 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 1983 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
1925 } 1984 }
1926 1985
1986 // TODO(alexmos): Remove once Blink is updated to use the version that takes
1987 // sandboxFlags.
1988 blink::WebFrame* RenderFrameImpl::createChildFrame(
1989 blink::WebLocalFrame* parent,
1990 const blink::WebString& name) {
1991 return createChildFrame(parent, name, blink::WebSandboxNone);
1992 }
1993
1927 blink::WebFrame* RenderFrameImpl::createChildFrame( 1994 blink::WebFrame* RenderFrameImpl::createChildFrame(
1928 blink::WebLocalFrame* parent, 1995 blink::WebLocalFrame* parent,
1929 const blink::WebString& name) { 1996 const blink::WebString& name,
1997 blink::WebSandboxFlags sandbox_flags) {
1930 // Synchronously notify the browser of a child frame creation to get the 1998 // Synchronously notify the browser of a child frame creation to get the
1931 // routing_id for the RenderFrame. 1999 // routing_id for the RenderFrame.
1932 int child_routing_id = MSG_ROUTING_NONE; 2000 int child_routing_id = MSG_ROUTING_NONE;
1933 Send(new FrameHostMsg_CreateChildFrame(routing_id_, 2001 Send(new FrameHostMsg_CreateChildFrame(
1934 base::UTF16ToUTF8(name), 2002 routing_id_,
1935 &child_routing_id)); 2003 base::UTF16ToUTF8(name),
2004 static_cast<content::SandboxFlags>(sandbox_flags),
2005 &child_routing_id));
1936 // Allocation of routing id failed, so we can't create a child frame. This can 2006 // Allocation of routing id failed, so we can't create a child frame. This can
1937 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2007 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped
1938 // out state. 2008 // out state.
1939 if (child_routing_id == MSG_ROUTING_NONE) { 2009 if (child_routing_id == MSG_ROUTING_NONE) {
1940 #if !defined(OS_LINUX) 2010 #if !defined(OS_LINUX)
1941 // DumpWithoutCrashing() crashes on Linux in renderer processes when 2011 // DumpWithoutCrashing() crashes on Linux in renderer processes when
1942 // breakpad and sandboxing are enabled: crbug.com/349600 2012 // breakpad and sandboxing are enabled: crbug.com/349600
1943 base::debug::Alias(parent); 2013 base::debug::Alias(parent);
1944 base::debug::Alias(&routing_id_); 2014 base::debug::Alias(&routing_id_);
1945 bool render_view_is_swapped_out = GetRenderWidget()->is_swapped_out(); 2015 bool render_view_is_swapped_out = GetRenderWidget()->is_swapped_out();
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4315 4385
4316 #if defined(ENABLE_BROWSER_CDMS) 4386 #if defined(ENABLE_BROWSER_CDMS)
4317 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4387 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4318 if (!cdm_manager_) 4388 if (!cdm_manager_)
4319 cdm_manager_ = new RendererCdmManager(this); 4389 cdm_manager_ = new RendererCdmManager(this);
4320 return cdm_manager_; 4390 return cdm_manager_;
4321 } 4391 }
4322 #endif // defined(ENABLE_BROWSER_CDMS) 4392 #endif // defined(ENABLE_BROWSER_CDMS)
4323 4393
4324 } // namespace content 4394 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698