| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/child/appcache/appcache_dispatcher.h" | 10 #include "content/child/appcache/appcache_dispatcher.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return render_view_->cookieJar(frame); | 192 return render_view_->cookieJar(frame); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) { | 195 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) { |
| 196 render_view_->didAccessInitialDocument(frame); | 196 render_view_->didAccessInitialDocument(frame); |
| 197 } | 197 } |
| 198 | 198 |
| 199 WebKit::WebFrame* RenderFrameImpl::createChildFrame( | 199 WebKit::WebFrame* RenderFrameImpl::createChildFrame( |
| 200 WebKit::WebFrame* parent, | 200 WebKit::WebFrame* parent, |
| 201 const WebKit::WebString& name) { | 201 const WebKit::WebString& name) { |
| 202 RenderFrameImpl* child_render_frame = this; | |
| 203 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); | 202 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); |
| 204 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 203 // Synchronously notify the browser of a child frame creation to get the |
| 205 // Synchronously notify the browser of a child frame creation to get the | 204 // routing_id for the RenderFrame. |
| 206 // routing_id for the RenderFrame. | 205 int routing_id; |
| 207 int routing_id; | 206 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), |
| 208 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), | 207 parent->identifier(), |
| 209 parent->identifier(), | 208 child_frame_identifier, |
| 210 child_frame_identifier, | 209 UTF16ToUTF8(name), |
| 211 UTF16ToUTF8(name), | 210 &routing_id)); |
| 212 &routing_id)); | 211 RenderFrameImpl* child_render_frame = |
| 213 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); | 212 RenderFrameImpl::Create(render_view_, routing_id); |
| 214 } | |
| 215 | 213 |
| 216 WebKit::WebFrame* web_frame = WebFrame::create(child_render_frame, | 214 WebKit::WebFrame* web_frame = WebFrame::create(child_render_frame, |
| 217 child_frame_identifier); | 215 child_frame_identifier); |
| 218 | 216 |
| 219 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 217 g_child_frame_map.Get().insert( |
| 220 g_child_frame_map.Get().insert( | 218 std::make_pair(web_frame, child_render_frame)); |
| 221 std::make_pair(web_frame, child_render_frame)); | |
| 222 } | |
| 223 | 219 |
| 224 return web_frame; | 220 return web_frame; |
| 225 } | 221 } |
| 226 | 222 |
| 227 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) { | 223 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) { |
| 228 render_view_->didDisownOpener(frame); | 224 render_view_->didDisownOpener(frame); |
| 229 } | 225 } |
| 230 | 226 |
| 231 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) { | 227 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) { |
| 232 // Currently multiple WebCore::Frames can send frameDetached to a single | |
| 233 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served | |
| 234 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also | |
| 235 // prevents this class from entering the |is_detaching_| state because | |
| 236 // even though one WebCore::Frame may have detached itself, others will | |
| 237 // still need to use this object. | |
| 238 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | |
| 239 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each | |
| 240 // RenderFrameImpl is only used by one WebCore::Frame. | |
| 241 is_detaching_ = true; | |
| 242 } | |
| 243 | |
| 244 int64 parent_frame_id = -1; | 228 int64 parent_frame_id = -1; |
| 245 if (frame->parent()) | 229 if (frame->parent()) |
| 246 parent_frame_id = frame->parent()->identifier(); | 230 parent_frame_id = frame->parent()->identifier(); |
| 247 | 231 |
| 248 render_view_->Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, | 232 Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, |
| 249 frame->identifier())); | 233 frame->identifier())); |
| 234 |
| 235 // Mark ourselves as officially detaching after the message has been sent |
| 236 // to the browser. This will disable sending of any further messages |
| 237 // from this object. |
| 238 CHECK(!is_detaching_); |
| 239 // is_detaching_ = true; |
| 250 | 240 |
| 251 // Call back to RenderViewImpl for observers to be notified. | 241 // Call back to RenderViewImpl for observers to be notified. |
| 252 // TODO(nasko): Remove once we have RenderFrameObserver. | 242 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 253 render_view_->frameDetached(frame); | 243 render_view_->frameDetached(frame); |
| 254 | 244 |
| 255 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 245 // The main frame's RenderFrameImpl is allocated manually by RenderViewImpl so |
| 246 // it is not recorded in this map. |
| 247 // |
| 248 // TODO(ajwong): Use english when writing this comment. |
| 249 if(frame->parent()) { |
| 256 FrameMap::iterator it = g_child_frame_map.Get().find(frame); | 250 FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
| 257 DCHECK(it != g_child_frame_map.Get().end()); | 251 DCHECK(it != g_child_frame_map.Get().end()); |
| 258 DCHECK_EQ(it->second, this); | 252 DCHECK_EQ(it->second, this); |
| 259 delete it->second; | |
| 260 g_child_frame_map.Get().erase(it); | 253 g_child_frame_map.Get().erase(it); |
| 254 delete this; |
| 261 } | 255 } |
| 262 | 256 |
| 263 frame->close(); | 257 frame->close(); |
| 264 } | 258 } |
| 265 | 259 |
| 266 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) { | 260 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) { |
| 267 // Call back to RenderViewImpl for observers to be notified. | 261 // Call back to RenderViewImpl for observers to be notified. |
| 268 // TODO(nasko): Remove once we have RenderFrameObserver. | 262 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 269 render_view_->willClose(frame); | 263 render_view_->willClose(frame); |
| 270 } | 264 } |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 920 |
| 927 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, | 921 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, |
| 928 int arb_robustness_status_code) { | 922 int arb_robustness_status_code) { |
| 929 render_view_->Send(new ViewHostMsg_DidLose3DContext( | 923 render_view_->Send(new ViewHostMsg_DidLose3DContext( |
| 930 GURL(frame->top()->document().securityOrigin().toString()), | 924 GURL(frame->top()->document().securityOrigin().toString()), |
| 931 THREE_D_API_TYPE_WEBGL, | 925 THREE_D_API_TYPE_WEBGL, |
| 932 arb_robustness_status_code)); | 926 arb_robustness_status_code)); |
| 933 } | 927 } |
| 934 | 928 |
| 935 } // namespace content | 929 } // namespace content |
| OLD | NEW |