| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 // a different process. This involves running the unload handler and | 1158 // a different process. This involves running the unload handler and |
| 1158 // clearing the page. We also allow this process to exit if there are no | 1159 // clearing the page. We also allow this process to exit if there are no |
| 1159 // other active RenderFrames in it. | 1160 // other active RenderFrames in it. |
| 1160 | 1161 |
| 1161 // Send an UpdateState message before we get swapped out. | 1162 // Send an UpdateState message before we get swapped out. |
| 1162 render_view_->SyncNavigationState(); | 1163 render_view_->SyncNavigationState(); |
| 1163 | 1164 |
| 1164 // If we need a proxy to replace this, create it now so its routing id is | 1165 // If we need a proxy to replace this, create it now so its routing id is |
| 1165 // registered for receiving IPC messages. | 1166 // registered for receiving IPC messages. |
| 1166 if (proxy_routing_id != MSG_ROUTING_NONE) { | 1167 if (proxy_routing_id != MSG_ROUTING_NONE) { |
| 1167 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, | 1168 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
| 1168 proxy_routing_id); | 1169 this, proxy_routing_id, replicated_frame_state.scope); |
| 1169 } | 1170 } |
| 1170 | 1171 |
| 1171 // Synchronously run the unload handler before sending the ACK. | 1172 // Synchronously run the unload handler before sending the ACK. |
| 1172 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1173 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
| 1173 // unload on subframes as well. | 1174 // unload on subframes as well. |
| 1174 if (is_main_frame) | 1175 if (is_main_frame) |
| 1175 frame_->dispatchUnloadEvent(); | 1176 frame_->dispatchUnloadEvent(); |
| 1176 | 1177 |
| 1177 // Swap out and stop sending any IPC messages that are not ACKs. | 1178 // Swap out and stop sending any IPC messages that are not ACKs. |
| 1178 if (is_main_frame) | 1179 if (is_main_frame) |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2111 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 2111 | 2112 |
| 2112 if (!navigation_state->request_committed()) { | 2113 if (!navigation_state->request_committed()) { |
| 2113 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); | 2114 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); |
| 2114 } | 2115 } |
| 2115 } | 2116 } |
| 2116 } | 2117 } |
| 2117 | 2118 |
| 2118 blink::WebFrame* RenderFrameImpl::createChildFrame( | 2119 blink::WebFrame* RenderFrameImpl::createChildFrame( |
| 2119 blink::WebLocalFrame* parent, | 2120 blink::WebLocalFrame* parent, |
| 2121 blink::WebTreeScopeType scope, |
| 2120 const blink::WebString& name, | 2122 const blink::WebString& name, |
| 2121 blink::WebSandboxFlags sandbox_flags) { | 2123 blink::WebSandboxFlags sandbox_flags) { |
| 2122 // Synchronously notify the browser of a child frame creation to get the | 2124 // Synchronously notify the browser of a child frame creation to get the |
| 2123 // routing_id for the RenderFrame. | 2125 // routing_id for the RenderFrame. |
| 2124 int child_routing_id = MSG_ROUTING_NONE; | 2126 int child_routing_id = MSG_ROUTING_NONE; |
| 2125 Send(new FrameHostMsg_CreateChildFrame( | 2127 Send(new FrameHostMsg_CreateChildFrame( |
| 2126 routing_id_, base::UTF16ToUTF8(name), | 2128 routing_id_, scope, base::UTF16ToUTF8(name), |
| 2127 WebToContentSandboxFlags(sandbox_flags), &child_routing_id)); | 2129 WebToContentSandboxFlags(sandbox_flags), &child_routing_id)); |
| 2128 | 2130 |
| 2129 // Allocation of routing id failed, so we can't create a child frame. This can | 2131 // Allocation of routing id failed, so we can't create a child frame. This can |
| 2130 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped | 2132 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped |
| 2131 // out state or synchronous IPC message above has failed. | 2133 // out state or synchronous IPC message above has failed. |
| 2132 if (child_routing_id == MSG_ROUTING_NONE) { | 2134 if (child_routing_id == MSG_ROUTING_NONE) { |
| 2133 NOTREACHED() << "Failed to allocate routing id for child frame."; | 2135 NOTREACHED() << "Failed to allocate routing id for child frame."; |
| 2134 return nullptr; | 2136 return nullptr; |
| 2135 } | 2137 } |
| 2136 | 2138 |
| 2137 // Create the RenderFrame and WebLocalFrame, linking the two. | 2139 // Create the RenderFrame and WebLocalFrame, linking the two. |
| 2138 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( | 2140 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( |
| 2139 render_view_.get(), child_routing_id); | 2141 render_view_.get(), child_routing_id); |
| 2140 blink::WebLocalFrame* web_frame = WebLocalFrame::create(child_render_frame); | 2142 blink::WebLocalFrame* web_frame = |
| 2143 WebLocalFrame::create(scope, child_render_frame); |
| 2141 child_render_frame->SetWebFrame(web_frame); | 2144 child_render_frame->SetWebFrame(web_frame); |
| 2142 | 2145 |
| 2143 // Add the frame to the frame tree and initialize it. | 2146 // Add the frame to the frame tree and initialize it. |
| 2144 parent->appendChild(web_frame); | 2147 parent->appendChild(web_frame); |
| 2145 child_render_frame->Initialize(); | 2148 child_render_frame->Initialize(); |
| 2146 | 2149 |
| 2147 return web_frame; | 2150 return web_frame; |
| 2148 } | 2151 } |
| 2149 | 2152 |
| 2153 blink::WebFrame* RenderFrameImpl::createChildFrame( |
| 2154 blink::WebLocalFrame* parent, |
| 2155 const blink::WebString& name, |
| 2156 blink::WebSandboxFlags sandbox_flags) { |
| 2157 return createChildFrame(parent, blink::WebTreeScopeType::Document, name, |
| 2158 sandbox_flags); |
| 2159 } |
| 2160 |
| 2150 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) { | 2161 void RenderFrameImpl::didDisownOpener(blink::WebLocalFrame* frame) { |
| 2151 DCHECK(!frame_ || frame_ == frame); | 2162 DCHECK(!frame_ || frame_ == frame); |
| 2152 // We only need to notify the browser if the active, top-level frame clears | 2163 // We only need to notify the browser if the active, top-level frame clears |
| 2153 // its opener. We can ignore cases where a swapped out frame clears its | 2164 // its opener. We can ignore cases where a swapped out frame clears its |
| 2154 // opener after hearing about it from the browser, and the browser does not | 2165 // opener after hearing about it from the browser, and the browser does not |
| 2155 // (yet) care about subframe openers. | 2166 // (yet) care about subframe openers. |
| 2156 if (is_swapped_out_ || frame->parent()) | 2167 if (is_swapped_out_ || frame->parent()) |
| 2157 return; | 2168 return; |
| 2158 | 2169 |
| 2159 // Notify WebContents and all its swapped out RenderViews. | 2170 // Notify WebContents and all its swapped out RenderViews. |
| (...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4913 #elif defined(ENABLE_BROWSER_CDMS) | 4924 #elif defined(ENABLE_BROWSER_CDMS) |
| 4914 cdm_manager_, | 4925 cdm_manager_, |
| 4915 #endif | 4926 #endif |
| 4916 this); | 4927 this); |
| 4917 } | 4928 } |
| 4918 | 4929 |
| 4919 return cdm_factory_; | 4930 return cdm_factory_; |
| 4920 } | 4931 } |
| 4921 | 4932 |
| 4922 } // namespace content | 4933 } // namespace content |
| OLD | NEW |