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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) { | 218 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) { |
219 render_view_->didAccessInitialDocument(frame); | 219 render_view_->didAccessInitialDocument(frame); |
220 } | 220 } |
221 | 221 |
222 WebKit::WebFrame* RenderFrameImpl::createChildFrame( | 222 WebKit::WebFrame* RenderFrameImpl::createChildFrame( |
223 WebKit::WebFrame* parent, | 223 WebKit::WebFrame* parent, |
224 const WebKit::WebString& name) { | 224 const WebKit::WebString& name) { |
225 RenderFrameImpl* child_render_frame = this; | 225 RenderFrameImpl* child_render_frame = this; |
226 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); | 226 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); |
227 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 227 // Synchronously notify the browser of a child frame creation to get the |
228 // Synchronously notify the browser of a child frame creation to get the | 228 // routing_id for the RenderFrame. |
229 // routing_id for the RenderFrame. | 229 int routing_id; |
230 int routing_id; | 230 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), |
231 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), | 231 parent->identifier(), |
232 parent->identifier(), | 232 child_frame_identifier, |
233 child_frame_identifier, | 233 UTF16ToUTF8(name), |
234 UTF16ToUTF8(name), | 234 &routing_id)); |
235 &routing_id)); | 235 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); |
236 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); | |
237 } | |
238 | 236 |
239 WebKit::WebFrame* web_frame = WebFrame::create(child_render_frame, | 237 WebKit::WebFrame* web_frame = WebFrame::create(child_render_frame, |
240 child_frame_identifier); | 238 child_frame_identifier); |
241 | 239 |
242 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 240 g_child_frame_map.Get().insert( |
243 g_child_frame_map.Get().insert( | 241 std::make_pair(web_frame, child_render_frame)); |
244 std::make_pair(web_frame, child_render_frame)); | |
245 } | |
246 | 242 |
247 return web_frame; | 243 return web_frame; |
248 } | 244 } |
249 | 245 |
250 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) { | 246 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) { |
251 render_view_->didDisownOpener(frame); | 247 render_view_->didDisownOpener(frame); |
252 } | 248 } |
253 | 249 |
254 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) { | 250 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) { |
255 // Currently multiple WebCore::Frames can send frameDetached to a single | 251 // Currently multiple WebCore::Frames can send frameDetached to a single |
256 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served | 252 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served |
257 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also | 253 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also |
258 // prevents this class from entering the |is_detaching_| state because | 254 // prevents this class from entering the |is_detaching_| state because |
259 // even though one WebCore::Frame may have detached itself, others will | 255 // even though one WebCore::Frame may have detached itself, others will |
260 // still need to use this object. | 256 // still need to use this object. |
261 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 257 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each |
262 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each | 258 // RenderFrameImpl is only used by one WebCore::Frame. |
263 // RenderFrameImpl is only used by one WebCore::Frame. | 259 is_detaching_ = true; |
264 is_detaching_ = true; | |
265 } | |
266 | 260 |
267 int64 parent_frame_id = -1; | 261 int64 parent_frame_id = -1; |
268 if (frame->parent()) | 262 if (frame->parent()) |
269 parent_frame_id = frame->parent()->identifier(); | 263 parent_frame_id = frame->parent()->identifier(); |
270 | 264 |
271 render_view_->Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, | 265 render_view_->Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, |
272 frame->identifier())); | 266 frame->identifier())); |
273 | 267 |
274 // Call back to RenderViewImpl for observers to be notified. | 268 // Call back to RenderViewImpl for observers to be notified. |
275 // TODO(nasko): Remove once we have RenderFrameObserver. | 269 // TODO(nasko): Remove once we have RenderFrameObserver. |
276 render_view_->frameDetached(frame); | 270 render_view_->frameDetached(frame); |
277 | 271 |
278 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 272 FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
279 FrameMap::iterator it = g_child_frame_map.Get().find(frame); | 273 DCHECK(it != g_child_frame_map.Get().end()); |
280 DCHECK(it != g_child_frame_map.Get().end()); | 274 DCHECK_EQ(it->second, this); |
281 DCHECK_EQ(it->second, this); | 275 delete it->second; |
282 delete it->second; | 276 g_child_frame_map.Get().erase(it); |
283 g_child_frame_map.Get().erase(it); | |
284 } | |
285 | 277 |
286 frame->close(); | 278 frame->close(); |
287 } | 279 } |
288 | 280 |
289 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) { | 281 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) { |
290 // Call back to RenderViewImpl for observers to be notified. | 282 // Call back to RenderViewImpl for observers to be notified. |
291 // TODO(nasko): Remove once we have RenderFrameObserver. | 283 // TODO(nasko): Remove once we have RenderFrameObserver. |
292 render_view_->willClose(frame); | 284 render_view_->willClose(frame); |
293 } | 285 } |
294 | 286 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 | 941 |
950 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, | 942 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, |
951 int arb_robustness_status_code) { | 943 int arb_robustness_status_code) { |
952 render_view_->Send(new ViewHostMsg_DidLose3DContext( | 944 render_view_->Send(new ViewHostMsg_DidLose3DContext( |
953 GURL(frame->top()->document().securityOrigin().toString()), | 945 GURL(frame->top()->document().securityOrigin().toString()), |
954 THREE_D_API_TYPE_WEBGL, | 946 THREE_D_API_TYPE_WEBGL, |
955 arb_robustness_status_code)); | 947 arb_robustness_status_code)); |
956 } | 948 } |
957 | 949 |
958 } // namespace content | 950 } // namespace content |
OLD | NEW |