OLD | NEW |
---|---|
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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 482 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
483 if (!provider) | 483 if (!provider) |
484 return media::Context3D(); | 484 return media::Context3D(); |
485 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 485 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
486 } | 486 } |
487 #endif | 487 #endif |
488 | 488 |
489 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = | 489 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = |
490 nullptr; | 490 nullptr; |
491 | 491 |
492 // Check that blink::WebSandboxFlags is kept in sync with | |
493 // content::SandboxFlags. | |
494 COMPILE_ASSERT(blink::WebSandboxFlags::None == | |
495 static_cast<blink::WebSandboxFlags>( | |
496 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
| |
497 enum_values_must_match_for_sandbox_flags); | |
498 COMPILE_ASSERT(blink::WebSandboxFlags::Navigation == | |
499 static_cast<blink::WebSandboxFlags>( | |
500 content::SandboxFlags::NAVIGATION), | |
501 enum_values_must_match_for_sandbox_flags); | |
502 COMPILE_ASSERT(blink::WebSandboxFlags::Plugins == | |
503 static_cast<blink::WebSandboxFlags>( | |
504 content::SandboxFlags::PLUGINS), | |
505 enum_values_must_match_for_sandbox_flags); | |
506 COMPILE_ASSERT(blink::WebSandboxFlags::Origin == | |
507 static_cast<blink::WebSandboxFlags>( | |
508 content::SandboxFlags::ORIGIN), | |
509 enum_values_must_match_for_sandbox_flags); | |
510 COMPILE_ASSERT(blink::WebSandboxFlags::Forms == | |
511 static_cast<blink::WebSandboxFlags>( | |
512 content::SandboxFlags::FORMS), | |
513 enum_values_must_match_for_sandbox_flags); | |
514 COMPILE_ASSERT(blink::WebSandboxFlags::Scripts == | |
515 static_cast<blink::WebSandboxFlags>( | |
516 content::SandboxFlags::SCRIPTS), | |
517 enum_values_must_match_for_sandbox_flags); | |
518 COMPILE_ASSERT(blink::WebSandboxFlags::TopNavigation == | |
519 static_cast<blink::WebSandboxFlags>( | |
520 content::SandboxFlags::TOP_NAVIGATION), | |
521 enum_values_must_match_for_sandbox_flags); | |
522 COMPILE_ASSERT(blink::WebSandboxFlags::Popups == | |
523 static_cast<blink::WebSandboxFlags>( | |
524 content::SandboxFlags::POPUPS), | |
525 enum_values_must_match_for_sandbox_flags); | |
526 COMPILE_ASSERT( | |
527 blink::WebSandboxFlags::AutomaticFeatures == | |
528 static_cast<blink::WebSandboxFlags>( | |
529 content::SandboxFlags::AUTOMATIC_FEATURES), | |
530 enum_values_must_match_for_sandbox_flags); | |
531 COMPILE_ASSERT(blink::WebSandboxFlags::PointerLock == | |
532 static_cast<blink::WebSandboxFlags>( | |
533 content::SandboxFlags::POINTER_LOCK), | |
534 enum_values_must_match_for_sandbox_flags); | |
535 COMPILE_ASSERT(blink::WebSandboxFlags::DocumentDomain == | |
536 static_cast<blink::WebSandboxFlags>( | |
537 content::SandboxFlags::DOCUMENT_DOMAIN), | |
538 enum_values_must_match_for_sandbox_flags); | |
539 COMPILE_ASSERT(blink::WebSandboxFlags::OrientationLock == | |
540 static_cast<blink::WebSandboxFlags>( | |
541 content::SandboxFlags::ORIENTATION_LOCK), | |
542 enum_values_must_match_for_sandbox_flags); | |
543 COMPILE_ASSERT(blink::WebSandboxFlags::All == | |
544 static_cast<blink::WebSandboxFlags>( | |
545 content::SandboxFlags::ALL), | |
546 enum_values_must_match_for_sandbox_flags); | |
547 | |
492 } // namespace | 548 } // namespace |
493 | 549 |
494 | |
495 // static | 550 // static |
496 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 551 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
497 int32 routing_id) { | 552 int32 routing_id) { |
498 DCHECK(routing_id != MSG_ROUTING_NONE); | 553 DCHECK(routing_id != MSG_ROUTING_NONE); |
499 | 554 |
500 if (g_create_render_frame_impl) | 555 if (g_create_render_frame_impl) |
501 return g_create_render_frame_impl(render_view, routing_id); | 556 return g_create_render_frame_impl(render_view, routing_id); |
502 else | 557 else |
503 return new RenderFrameImpl(render_view, routing_id); | 558 return new RenderFrameImpl(render_view, routing_id); |
504 } | 559 } |
505 | 560 |
506 // static | 561 // static |
507 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { | 562 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { |
508 RoutingIDFrameMap::iterator iter = | 563 RoutingIDFrameMap::iterator iter = |
509 g_routing_id_frame_map.Get().find(routing_id); | 564 g_routing_id_frame_map.Get().find(routing_id); |
510 if (iter != g_routing_id_frame_map.Get().end()) | 565 if (iter != g_routing_id_frame_map.Get().end()) |
511 return iter->second; | 566 return iter->second; |
512 return NULL; | 567 return NULL; |
513 } | 568 } |
514 | 569 |
515 // static | 570 // static |
516 void RenderFrameImpl::CreateFrame(int routing_id, | 571 void RenderFrameImpl::CreateFrame( |
517 int parent_routing_id, | 572 int routing_id, |
518 int proxy_routing_id) { | 573 int parent_routing_id, |
574 int proxy_routing_id, | |
575 const FrameReplicationState& replicated_state) { | |
519 // TODO(nasko): For now, this message is only sent for subframes, as the | 576 // TODO(nasko): For now, this message is only sent for subframes, as the |
520 // top level frame is created when the RenderView is created through the | 577 // top level frame is created when the RenderView is created through the |
521 // ViewMsg_New IPC. | 578 // ViewMsg_New IPC. |
522 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id); | 579 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id); |
523 | 580 |
524 blink::WebLocalFrame* web_frame; | 581 blink::WebLocalFrame* web_frame; |
525 RenderFrameImpl* render_frame; | 582 RenderFrameImpl* render_frame; |
526 if (proxy_routing_id == MSG_ROUTING_NONE) { | 583 if (proxy_routing_id == MSG_ROUTING_NONE) { |
527 RenderFrameProxy* parent_proxy = | 584 RenderFrameProxy* parent_proxy = |
528 RenderFrameProxy::FromRoutingID(parent_routing_id); | 585 RenderFrameProxy::FromRoutingID(parent_routing_id); |
529 // If the browser is sending a valid parent routing id, it should already | 586 // If the browser is sending a valid parent routing id, it should already |
530 // be created and registered. | 587 // be created and registered. |
531 CHECK(parent_proxy); | 588 CHECK(parent_proxy); |
532 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); | 589 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); |
533 | 590 |
534 // Create the RenderFrame and WebLocalFrame, linking the two. | 591 // Create the RenderFrame and WebLocalFrame, linking the two. |
535 render_frame = | 592 render_frame = |
536 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); | 593 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); |
537 web_frame = parent_web_frame->createLocalChild("", render_frame); | 594 web_frame = parent_web_frame->createLocalChild("", |
595 ContentToWebSandboxFlags(replicated_state.sandbox_flags), | |
596 render_frame); | |
538 } else { | 597 } else { |
539 RenderFrameProxy* proxy = | 598 RenderFrameProxy* proxy = |
540 RenderFrameProxy::FromRoutingID(proxy_routing_id); | 599 RenderFrameProxy::FromRoutingID(proxy_routing_id); |
541 CHECK(proxy); | 600 CHECK(proxy); |
542 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); | 601 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); |
543 web_frame = blink::WebLocalFrame::create(render_frame); | 602 web_frame = blink::WebLocalFrame::create(render_frame); |
544 render_frame->proxy_routing_id_ = proxy_routing_id; | 603 render_frame->proxy_routing_id_ = proxy_routing_id; |
545 web_frame->initializeToReplaceRemoteFrame(proxy->web_frame()); | 604 web_frame->initializeToReplaceRemoteFrame(proxy->web_frame()); |
546 } | 605 } |
547 render_frame->SetWebFrame(web_frame); | 606 render_frame->SetWebFrame(web_frame); |
(...skipping 13 matching lines...) Expand all Loading... | |
561 return NULL; | 620 return NULL; |
562 } | 621 } |
563 | 622 |
564 // static | 623 // static |
565 void RenderFrameImpl::InstallCreateHook( | 624 void RenderFrameImpl::InstallCreateHook( |
566 CreateRenderFrameImplFunction create_render_frame_impl) { | 625 CreateRenderFrameImplFunction create_render_frame_impl) { |
567 CHECK(!g_create_render_frame_impl); | 626 CHECK(!g_create_render_frame_impl); |
568 g_create_render_frame_impl = create_render_frame_impl; | 627 g_create_render_frame_impl = create_render_frame_impl; |
569 } | 628 } |
570 | 629 |
630 // static | |
631 content::SandboxFlags RenderFrameImpl::WebToContentSandboxFlags( | |
632 blink::WebSandboxFlags flags) { | |
633 return static_cast<content::SandboxFlags>(flags); | |
634 } | |
635 | |
636 // static | |
637 blink::WebSandboxFlags RenderFrameImpl::ContentToWebSandboxFlags( | |
638 content::SandboxFlags flags) { | |
639 return static_cast<blink::WebSandboxFlags>(flags); | |
640 } | |
641 | |
642 | |
571 // RenderFrameImpl ---------------------------------------------------------- | 643 // RenderFrameImpl ---------------------------------------------------------- |
572 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) | 644 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) |
573 : frame_(NULL), | 645 : frame_(NULL), |
574 render_view_(render_view->AsWeakPtr()), | 646 render_view_(render_view->AsWeakPtr()), |
575 routing_id_(routing_id), | 647 routing_id_(routing_id), |
576 is_swapped_out_(false), | 648 is_swapped_out_(false), |
577 render_frame_proxy_(NULL), | 649 render_frame_proxy_(NULL), |
578 is_detaching_(false), | 650 is_detaching_(false), |
579 proxy_routing_id_(MSG_ROUTING_NONE), | 651 proxy_routing_id_(MSG_ROUTING_NONE), |
580 #if defined(ENABLE_PLUGINS) | 652 #if defined(ENABLE_PLUGINS) |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1930 } | 2002 } |
1931 | 2003 |
1932 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) { | 2004 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) { |
1933 DCHECK(!frame_ || frame_ == frame); | 2005 DCHECK(!frame_ || frame_ == frame); |
1934 // Notify the browser process that it is no longer safe to show the pending | 2006 // Notify the browser process that it is no longer safe to show the pending |
1935 // URL of the main frame, since a URL spoof is now possible. | 2007 // URL of the main frame, since a URL spoof is now possible. |
1936 if (!frame->parent() && render_view_->page_id_ == -1) | 2008 if (!frame->parent() && render_view_->page_id_ == -1) |
1937 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); | 2009 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); |
1938 } | 2010 } |
1939 | 2011 |
2012 // TODO(alexmos): Remove once Blink is updated to use the version that takes | |
2013 // sandbox flags. | |
2014 blink::WebFrame* RenderFrameImpl::createChildFrame( | |
2015 blink::WebLocalFrame* parent, | |
2016 const blink::WebString& name) { | |
2017 return createChildFrame(parent, name, blink::WebSandboxFlags::None); | |
2018 } | |
2019 | |
1940 blink::WebFrame* RenderFrameImpl::createChildFrame( | 2020 blink::WebFrame* RenderFrameImpl::createChildFrame( |
1941 blink::WebLocalFrame* parent, | 2021 blink::WebLocalFrame* parent, |
1942 const blink::WebString& name) { | 2022 const blink::WebString& name, |
2023 blink::WebSandboxFlags sandbox_flags) { | |
1943 // Synchronously notify the browser of a child frame creation to get the | 2024 // Synchronously notify the browser of a child frame creation to get the |
1944 // routing_id for the RenderFrame. | 2025 // routing_id for the RenderFrame. |
1945 int child_routing_id = MSG_ROUTING_NONE; | 2026 int child_routing_id = MSG_ROUTING_NONE; |
1946 CHECK(Send(new FrameHostMsg_CreateChildFrame(routing_id_, | 2027 CHECK(Send(new FrameHostMsg_CreateChildFrame( |
1947 base::UTF16ToUTF8(name), | 2028 routing_id_, |
1948 &child_routing_id))); | 2029 base::UTF16ToUTF8(name), |
2030 WebToContentSandboxFlags(sandbox_flags), | |
2031 &child_routing_id))); | |
1949 | 2032 |
1950 // Allocation of routing id failed, so we can't create a child frame. This can | 2033 // Allocation of routing id failed, so we can't create a child frame. This can |
1951 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped | 2034 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped |
1952 // out state. | 2035 // out state. |
1953 if (child_routing_id == MSG_ROUTING_NONE) { | 2036 if (child_routing_id == MSG_ROUTING_NONE) { |
1954 #if !defined(OS_LINUX) | 2037 #if !defined(OS_LINUX) |
1955 // DumpWithoutCrashing() crashes on Linux in renderer processes when | 2038 // DumpWithoutCrashing() crashes on Linux in renderer processes when |
1956 // breakpad and sandboxing are enabled: crbug.com/349600 | 2039 // breakpad and sandboxing are enabled: crbug.com/349600 |
1957 base::debug::Alias(parent); | 2040 base::debug::Alias(parent); |
1958 base::debug::Alias(&routing_id_); | 2041 base::debug::Alias(&routing_id_); |
(...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4331 | 4414 |
4332 #if defined(ENABLE_BROWSER_CDMS) | 4415 #if defined(ENABLE_BROWSER_CDMS) |
4333 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4416 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4334 if (!cdm_manager_) | 4417 if (!cdm_manager_) |
4335 cdm_manager_ = new RendererCdmManager(this); | 4418 cdm_manager_ = new RendererCdmManager(this); |
4336 return cdm_manager_; | 4419 return cdm_manager_; |
4337 } | 4420 } |
4338 #endif // defined(ENABLE_BROWSER_CDMS) | 4421 #endif // defined(ENABLE_BROWSER_CDMS) |
4339 | 4422 |
4340 } // namespace content | 4423 } // namespace content |
OLD | NEW |