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

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

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: consolidate render->browser ipcs into one Created 5 years, 3 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/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 8f6c99c269f96de55707f4f34fffa855cced9901..1a4a07fc56bb71f225aeab46b0499bed662e998c 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -15,7 +15,6 @@
#include "content/browser/accessibility/ax_tree_id_registry.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
-#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/cross_site_transferring_request.h"
@@ -460,6 +459,8 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags,
OnDidChangeSandboxFlags)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties,
+ OnDidChangeFrameOwnerProperties)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
@@ -625,6 +626,7 @@ bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id,
params.parent_routing_id = parent_routing_id;
params.previous_sibling_routing_id = previous_sibling_routing_id;
params.replication_state = frame_tree_node()->current_replication_state();
+ params.frame_owner_properties = frame_tree_node()->frame_owner_properties();
if (render_widget_host_) {
params.widget_params.routing_id = render_widget_host_->GetRoutingID();
@@ -716,7 +718,8 @@ void RenderFrameHostImpl::OnCreateChildFrame(
int new_routing_id,
blink::WebTreeScopeType scope,
const std::string& frame_name,
- blink::WebSandboxFlags sandbox_flags) {
+ blink::WebSandboxFlags sandbox_flags,
+ const blink::WebFrameOwnerProperties& frame_owner_properties) {
// It is possible that while a new RenderFrameHost was committed, the
// RenderFrame corresponding to this host sent an IPC message to create a
// frame and it is delivered after this host is swapped out.
@@ -724,9 +727,9 @@ void RenderFrameHostImpl::OnCreateChildFrame(
if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT)
return;
- RenderFrameHostImpl* new_frame =
- frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(),
- new_routing_id, scope, frame_name, sandbox_flags);
+ RenderFrameHostImpl* new_frame = frame_tree_->AddFrame(
+ frame_tree_node_, GetProcess()->GetID(), new_routing_id, scope,
+ frame_name, sandbox_flags, frame_owner_properties);
if (!new_frame)
return;
@@ -1303,20 +1306,13 @@ void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) {
void RenderFrameHostImpl::OnDidChangeSandboxFlags(
int32 frame_routing_id,
blink::WebSandboxFlags flags) {
- FrameTree* frame_tree = frame_tree_node()->frame_tree();
- FrameTreeNode* child =
- frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id);
- if (!child)
- return;
-
// Ensure that a frame can only update sandbox flags for its immediate
// children. If this is not the case, the renderer is considered malicious
// and is killed.
- if (child->parent() != frame_tree_node()) {
- bad_message::ReceivedBadMessage(GetProcess(),
- bad_message::RFH_SANDBOX_FLAGS);
+ FrameTreeNode* child = CheckAndGetIfImmediateChild(
alexmos 2015/09/21 18:53:22 I'm wondering if there's a better name for this.
lazyboy 2015/09/22 02:38:54 EnsureIfImmediateChildAndReturn? or maybe just dro
alexmos 2015/09/22 16:56:52 I actually like what you currently have a bit more
+ frame_routing_id, bad_message::RFH_SANDBOX_FLAGS);
+ if (!child)
return;
- }
child->set_sandbox_flags(flags);
@@ -1332,6 +1328,36 @@ void RenderFrameHostImpl::OnDidChangeSandboxFlags(
}
}
+FrameTreeNode* RenderFrameHostImpl::CheckAndGetIfImmediateChild(
+ int32 child_frame_routing_id, bad_message::BadMessageReason reason) {
+ FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID(
+ GetProcess()->GetID(), child_frame_routing_id);
+ if (child && child->parent() != frame_tree_node()) {
+ bad_message::ReceivedBadMessage(GetProcess(), reason);
+ return nullptr;
+ }
+ return child;
+}
+
+void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties(
+ int32 frame_routing_id,
+ const blink::WebFrameOwnerProperties& frame_owner_properties) {
+ FrameTreeNode* child = CheckAndGetIfImmediateChild(
+ frame_routing_id, bad_message::RFH_OWNER_PROPERTY);
+ if (!child)
+ return;
+
+ child->SetFrameOwnerProperties(frame_owner_properties);
+
+ // Notify the RenderFrame if it lives in a different process from its
+ // parent.
+ RenderFrameHost* child_rfh = child->current_frame_host();
+ if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
+ child_rfh->Send(new FrameMsg_SetFrameOwnerProperties(
+ child_rfh->GetRoutingID(), child->frame_owner_properties()));
+ }
+}
+
void RenderFrameHostImpl::OnUpdateTitle(
const base::string16& title,
blink::WebTextDirection title_direction) {

Powered by Google App Engine
This is Rietveld 408576698