| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int routing_id; | 230 int routing_id; |
| 231 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), | 231 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), |
| 232 parent->identifier(), | 232 parent->identifier(), |
| 233 child_frame_identifier, | 233 child_frame_identifier, |
| 234 UTF16ToUTF8(name), | 234 UTF16ToUTF8(name), |
| 235 &routing_id)); | 235 &routing_id)); |
| 236 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); | 236 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); |
| 237 } | 237 } |
| 238 | 238 |
| 239 blink::WebFrame* web_frame = WebFrame::create(child_render_frame, | 239 blink::WebFrame* web_frame = WebFrame::create(child_render_frame, |
| 240 child_frame_identifier); | 240 child_frame_identifier); |
| 241 | 241 |
| 242 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 242 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| 243 g_child_frame_map.Get().insert( | 243 g_child_frame_map.Get().insert( |
| 244 std::make_pair(web_frame, child_render_frame)); | 244 std::make_pair(web_frame, child_render_frame)); |
| 245 } | 245 } |
| 246 | 246 |
| 247 return web_frame; | 247 return web_frame; |
| 248 } | 248 } |
| 249 | 249 |
| 250 void RenderFrameImpl::didDisownOpener(blink::WebFrame* frame) { | 250 void RenderFrameImpl::didDisownOpener(blink::WebFrame* frame) { |
| 251 render_view_->didDisownOpener(frame); | 251 render_view_->didDisownOpener(frame); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { | 254 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { |
| 255 // NOTE: This function is called on the frame that is being detached and not |
| 256 // the parent frame. This is different from createChildFrame() which is |
| 257 // called on the parent frame. |
| 258 CHECK(!is_detaching_); |
| 259 |
| 260 int64 parent_frame_id = -1; |
| 261 if (frame->parent()) |
| 262 parent_frame_id = frame->parent()->identifier(); |
| 263 |
| 264 Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, |
| 265 frame->identifier())); |
| 266 |
| 255 // Currently multiple WebCore::Frames can send frameDetached to a single | 267 // Currently multiple WebCore::Frames can send frameDetached to a single |
| 256 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served | 268 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served |
| 257 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also | 269 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also |
| 258 // prevents this class from entering the |is_detaching_| state because | 270 // prevents this class from entering the |is_detaching_| state because |
| 259 // even though one WebCore::Frame may have detached itself, others will | 271 // even though one WebCore::Frame may have detached itself, others will |
| 260 // still need to use this object. | 272 // still need to use this object. |
| 261 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 273 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| 262 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each | 274 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
| 263 // RenderFrameImpl is only used by one WebCore::Frame. | 275 // sent before setting |is_detaching_| to true. In contrast, Observers |
| 276 // should only be notified afterwards so they cannot call back into and |
| 277 // have IPCs fired off. |
| 264 is_detaching_ = true; | 278 is_detaching_ = true; |
| 265 } | 279 } |
| 266 | 280 |
| 267 int64 parent_frame_id = -1; | |
| 268 if (frame->parent()) | |
| 269 parent_frame_id = frame->parent()->identifier(); | |
| 270 | |
| 271 render_view_->Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, | |
| 272 frame->identifier())); | |
| 273 | |
| 274 // Call back to RenderViewImpl for observers to be notified. | 281 // Call back to RenderViewImpl for observers to be notified. |
| 275 // TODO(nasko): Remove once we have RenderFrameObserver. | 282 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 276 render_view_->frameDetached(frame); | 283 render_view_->frameDetached(frame); |
| 277 | 284 |
| 285 frame->close(); |
| 286 |
| 278 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 287 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| 279 FrameMap::iterator it = g_child_frame_map.Get().find(frame); | 288 // If the frame does not have a parent, it is the main frame. The main |
| 280 DCHECK(it != g_child_frame_map.Get().end()); | 289 // frame is owned by the containing RenderViewHost so it does not require |
| 281 DCHECK_EQ(it->second, this); | 290 // any cleanup here. |
| 282 delete it->second; | 291 if (frame->parent()) { |
| 283 g_child_frame_map.Get().erase(it); | 292 FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
| 293 DCHECK(it != g_child_frame_map.Get().end()); |
| 294 DCHECK_EQ(it->second, this); |
| 295 g_child_frame_map.Get().erase(it); |
| 296 delete this; |
| 297 // Object is invalid after this point. |
| 298 } |
| 284 } | 299 } |
| 285 | |
| 286 frame->close(); | |
| 287 } | 300 } |
| 288 | 301 |
| 289 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 302 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
| 290 // Call back to RenderViewImpl for observers to be notified. | 303 // Call back to RenderViewImpl for observers to be notified. |
| 291 // TODO(nasko): Remove once we have RenderFrameObserver. | 304 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 292 render_view_->willClose(frame); | 305 render_view_->willClose(frame); |
| 293 } | 306 } |
| 294 | 307 |
| 295 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, | 308 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, |
| 296 const blink::WebString& name) { | 309 const blink::WebString& name) { |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 | 962 |
| 950 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame, | 963 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame, |
| 951 int arb_robustness_status_code) { | 964 int arb_robustness_status_code) { |
| 952 render_view_->Send(new ViewHostMsg_DidLose3DContext( | 965 render_view_->Send(new ViewHostMsg_DidLose3DContext( |
| 953 GURL(frame->top()->document().securityOrigin().toString()), | 966 GURL(frame->top()->document().securityOrigin().toString()), |
| 954 THREE_D_API_TYPE_WEBGL, | 967 THREE_D_API_TYPE_WEBGL, |
| 955 arb_robustness_status_code)); | 968 arb_robustness_status_code)); |
| 956 } | 969 } |
| 957 | 970 |
| 958 } // namespace content | 971 } // namespace content |
| OLD | NEW |