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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1141283002: Replicate whether a frame is in a document or shadow tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Oops Created 5 years, 7 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 blink::WebFrame* previous_sibling_web_frame = nullptr; 588 blink::WebFrame* previous_sibling_web_frame = nullptr;
589 RenderFrameProxy* previous_sibling_proxy = 589 RenderFrameProxy* previous_sibling_proxy =
590 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); 590 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id);
591 if (previous_sibling_proxy) 591 if (previous_sibling_proxy)
592 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); 592 previous_sibling_web_frame = previous_sibling_proxy->web_frame();
593 593
594 // Create the RenderFrame and WebLocalFrame, linking the two. 594 // Create the RenderFrame and WebLocalFrame, linking the two.
595 render_frame = 595 render_frame =
596 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); 596 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
597 web_frame = parent_web_frame->createLocalChild( 597 web_frame = parent_web_frame->createLocalChild(
598 WebString::fromUTF8(replicated_state.name), 598 replicated_state.scope, WebString::fromUTF8(replicated_state.name),
599 ContentToWebSandboxFlags(replicated_state.sandbox_flags), render_frame, 599 ContentToWebSandboxFlags(replicated_state.sandbox_flags), render_frame,
600 previous_sibling_web_frame); 600 previous_sibling_web_frame);
601 } else { 601 } else {
602 RenderFrameProxy* proxy = 602 RenderFrameProxy* proxy =
603 RenderFrameProxy::FromRoutingID(proxy_routing_id); 603 RenderFrameProxy::FromRoutingID(proxy_routing_id);
604 CHECK(proxy); 604 CHECK(proxy);
605 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 605 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
606 web_frame = blink::WebLocalFrame::create(render_frame); 606 web_frame =
607 blink::WebLocalFrame::create(replicated_state.scope, render_frame);
607 render_frame->proxy_routing_id_ = proxy_routing_id; 608 render_frame->proxy_routing_id_ = proxy_routing_id;
608 web_frame->initializeToReplaceRemoteFrame( 609 web_frame->initializeToReplaceRemoteFrame(
609 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), 610 proxy->web_frame(), WebString::fromUTF8(replicated_state.name),
610 ContentToWebSandboxFlags(replicated_state.sandbox_flags)); 611 ContentToWebSandboxFlags(replicated_state.sandbox_flags));
611 } 612 }
612 render_frame->SetWebFrame(web_frame); 613 render_frame->SetWebFrame(web_frame);
613 614
614 if (widget_params.routing_id != MSG_ROUTING_NONE) { 615 if (widget_params.routing_id != MSG_ROUTING_NONE) {
615 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 616 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
616 switches::kSitePerProcess)); 617 switches::kSitePerProcess));
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 // a different process. This involves running the unload handler and 1167 // a different process. This involves running the unload handler and
1167 // clearing the page. We also allow this process to exit if there are no 1168 // clearing the page. We also allow this process to exit if there are no
1168 // other active RenderFrames in it. 1169 // other active RenderFrames in it.
1169 1170
1170 // Send an UpdateState message before we get swapped out. 1171 // Send an UpdateState message before we get swapped out.
1171 render_view_->SyncNavigationState(); 1172 render_view_->SyncNavigationState();
1172 1173
1173 // If we need a proxy to replace this, create it now so its routing id is 1174 // If we need a proxy to replace this, create it now so its routing id is
1174 // registered for receiving IPC messages. 1175 // registered for receiving IPC messages.
1175 if (proxy_routing_id != MSG_ROUTING_NONE) { 1176 if (proxy_routing_id != MSG_ROUTING_NONE) {
1176 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, 1177 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(
1177 proxy_routing_id); 1178 this, proxy_routing_id, replicated_frame_state.scope);
1178 } 1179 }
1179 1180
1180 // Synchronously run the unload handler before sending the ACK. 1181 // Synchronously run the unload handler before sending the ACK.
1181 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 1182 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
1182 // unload on subframes as well. 1183 // unload on subframes as well.
1183 if (is_main_frame) 1184 if (is_main_frame)
1184 frame_->dispatchUnloadEvent(); 1185 frame_->dispatchUnloadEvent();
1185 1186
1186 // Swap out and stop sending any IPC messages that are not ACKs. 1187 // Swap out and stop sending any IPC messages that are not ACKs.
1187 if (is_main_frame) 1188 if (is_main_frame)
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 2151 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2151 2152
2152 if (!navigation_state->request_committed()) { 2153 if (!navigation_state->request_committed()) {
2153 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2154 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2154 } 2155 }
2155 } 2156 }
2156 } 2157 }
2157 2158
2158 blink::WebFrame* RenderFrameImpl::createChildFrame( 2159 blink::WebFrame* RenderFrameImpl::createChildFrame(
2159 blink::WebLocalFrame* parent, 2160 blink::WebLocalFrame* parent,
2161 blink::WebTreeScopeType scope,
2160 const blink::WebString& name, 2162 const blink::WebString& name,
2161 blink::WebSandboxFlags sandbox_flags) { 2163 blink::WebSandboxFlags sandbox_flags) {
2162 // Synchronously notify the browser of a child frame creation to get the 2164 // Synchronously notify the browser of a child frame creation to get the
2163 // routing_id for the RenderFrame. 2165 // routing_id for the RenderFrame.
2164 int child_routing_id = MSG_ROUTING_NONE; 2166 int child_routing_id = MSG_ROUTING_NONE;
2165 Send(new FrameHostMsg_CreateChildFrame( 2167 Send(new FrameHostMsg_CreateChildFrame(
2166 routing_id_, base::UTF16ToUTF8(name), 2168 routing_id_, scope, base::UTF16ToUTF8(name),
2167 WebToContentSandboxFlags(sandbox_flags), &child_routing_id)); 2169 WebToContentSandboxFlags(sandbox_flags), &child_routing_id));
2168 2170
2169 // Allocation of routing id failed, so we can't create a child frame. This can 2171 // Allocation of routing id failed, so we can't create a child frame. This can
2170 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2172 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped
2171 // out state or synchronous IPC message above has failed. 2173 // out state or synchronous IPC message above has failed.
2172 if (child_routing_id == MSG_ROUTING_NONE) { 2174 if (child_routing_id == MSG_ROUTING_NONE) {
2173 NOTREACHED() << "Failed to allocate routing id for child frame."; 2175 NOTREACHED() << "Failed to allocate routing id for child frame.";
2174 return nullptr; 2176 return nullptr;
2175 } 2177 }
2176 2178
2177 // Create the RenderFrame and WebLocalFrame, linking the two. 2179 // Create the RenderFrame and WebLocalFrame, linking the two.
2178 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( 2180 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(
2179 render_view_.get(), child_routing_id); 2181 render_view_.get(), child_routing_id);
2180 blink::WebLocalFrame* web_frame = WebLocalFrame::create(child_render_frame); 2182 blink::WebLocalFrame* web_frame =
2183 WebLocalFrame::create(scope, child_render_frame);
2181 child_render_frame->SetWebFrame(web_frame); 2184 child_render_frame->SetWebFrame(web_frame);
2182 2185
2183 // Add the frame to the frame tree and initialize it. 2186 // Add the frame to the frame tree and initialize it.
2184 parent->appendChild(web_frame); 2187 parent->appendChild(web_frame);
2185 child_render_frame->Initialize(); 2188 child_render_frame->Initialize();
2186 2189
2187 return web_frame; 2190 return web_frame;
2188 } 2191 }
2189 2192
2193 blink::WebFrame* RenderFrameImpl::createChildFrame(
2194 blink::WebLocalFrame* parent,
2195 const blink::WebString& name,
2196 blink::WebSandboxFlags sandbox_flags) {
2197 return createChildFrame(parent, blink::WebTreeScopeType::Document, name,
2198 sandbox_flags);
2199 }
2200
2190 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) { 2201 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) {
2191 DCHECK(!frame_ || frame_ == frame); 2202 DCHECK(!frame_ || frame_ == frame);
2192 // We only need to notify the browser if the active, top-level frame clears 2203 // We only need to notify the browser if the active, top-level frame clears
2193 // its opener. We can ignore cases where a swapped out frame clears its 2204 // its opener. We can ignore cases where a swapped out frame clears its
2194 // opener after hearing about it from the browser, and the browser does not 2205 // opener after hearing about it from the browser, and the browser does not
2195 // (yet) care about subframe openers. 2206 // (yet) care about subframe openers.
2196 if (is_swapped_out_ || frame->parent()) 2207 if (is_swapped_out_ || frame->parent())
2197 return; 2208 return;
2198 2209
2199 // Notify WebContents and all its swapped out RenderViews. 2210 // Notify WebContents and all its swapped out RenderViews.
(...skipping 2766 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 #elif defined(ENABLE_BROWSER_CDMS) 4977 #elif defined(ENABLE_BROWSER_CDMS)
4967 cdm_manager_, 4978 cdm_manager_,
4968 #endif 4979 #endif
4969 this); 4980 this);
4970 } 4981 }
4971 4982
4972 return cdm_factory_; 4983 return cdm_factory_;
4973 } 4984 }
4974 4985
4975 } // namespace content 4986 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698