OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 | 271 |
272 SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { | 272 SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { |
273 return instance_.get(); | 273 return instance_.get(); |
274 } | 274 } |
275 | 275 |
276 bool RenderViewHostImpl::CreateRenderView( | 276 bool RenderViewHostImpl::CreateRenderView( |
277 const base::string16& frame_name, | 277 const base::string16& frame_name, |
278 int opener_route_id, | 278 int opener_route_id, |
279 int proxy_route_id, | 279 int proxy_route_id, |
280 int32 max_page_id, | 280 int32 max_page_id, |
281 const FrameReplicationState& replicated_frame_state, | |
281 bool window_was_created_with_opener) { | 282 bool window_was_created_with_opener) { |
282 TRACE_EVENT0("renderer_host,navigation", | 283 TRACE_EVENT0("renderer_host,navigation", |
283 "RenderViewHostImpl::CreateRenderView"); | 284 "RenderViewHostImpl::CreateRenderView"); |
284 DCHECK(!IsRenderViewLive()) << "Creating view twice"; | 285 DCHECK(!IsRenderViewLive()) << "Creating view twice"; |
285 | 286 |
286 // The process may (if we're sharing a process with another host that already | 287 // The process may (if we're sharing a process with another host that already |
287 // initialized it) or may not (we have our own process or the old process | 288 // initialized it) or may not (we have our own process or the old process |
288 // crashed) have been initialized. Calling Init multiple times will be | 289 // crashed) have been initialized. Calling Init multiple times will be |
289 // ignored, so this is safe. | 290 // ignored, so this is safe. |
290 if (!GetProcess()->Init()) | 291 if (!GetProcess()->Init()) |
(...skipping 21 matching lines...) Expand all Loading... | |
312 params.web_preferences = GetWebkitPreferences(); | 313 params.web_preferences = GetWebkitPreferences(); |
313 params.view_id = GetRoutingID(); | 314 params.view_id = GetRoutingID(); |
314 params.main_frame_routing_id = main_frame_routing_id_; | 315 params.main_frame_routing_id = main_frame_routing_id_; |
315 params.surface_id = surface_id(); | 316 params.surface_id = surface_id(); |
316 params.session_storage_namespace_id = | 317 params.session_storage_namespace_id = |
317 delegate_->GetSessionStorageNamespace(instance_.get())->id(); | 318 delegate_->GetSessionStorageNamespace(instance_.get())->id(); |
318 params.frame_name = frame_name; | 319 params.frame_name = frame_name; |
319 // Ensure the RenderView sets its opener correctly. | 320 // Ensure the RenderView sets its opener correctly. |
320 params.opener_route_id = opener_route_id; | 321 params.opener_route_id = opener_route_id; |
321 params.swapped_out = !is_active_; | 322 params.swapped_out = !is_active_; |
323 params.replicated_frame_state = replicated_frame_state; | |
322 params.proxy_routing_id = proxy_route_id; | 324 params.proxy_routing_id = proxy_route_id; |
323 params.hidden = is_hidden(); | 325 params.hidden = is_hidden(); |
324 params.never_visible = delegate_->IsNeverVisible(); | 326 params.never_visible = delegate_->IsNeverVisible(); |
325 params.window_was_created_with_opener = window_was_created_with_opener; | 327 params.window_was_created_with_opener = window_was_created_with_opener; |
326 params.next_page_id = next_page_id; | 328 params.next_page_id = next_page_id; |
327 params.enable_auto_resize = auto_resize_enabled(); | 329 params.enable_auto_resize = auto_resize_enabled(); |
328 params.min_size = min_size_for_auto_resize(); | 330 params.min_size = min_size_for_auto_resize(); |
329 params.max_size = max_size_for_auto_resize(); | 331 params.max_size = max_size_for_auto_resize(); |
330 GetResizeParams(¶ms.initial_size); | 332 GetResizeParams(¶ms.initial_size); |
331 if (!is_active_) { | |
332 params.replicated_frame_state = | |
333 static_cast<RenderFrameHostImpl*>(GetMainFrame())->frame_tree_node() | |
334 ->current_replication_state(); | |
335 } | |
336 | 333 |
337 if (!Send(new ViewMsg_New(params))) | 334 if (!Send(new ViewMsg_New(params))) |
338 return false; | 335 return false; |
339 SetInitialRenderSizeParams(params.initial_size); | 336 SetInitialRenderSizeParams(params.initial_size); |
340 | 337 |
341 // If the RWHV has not yet been set, the surface ID namespace will get | 338 // If the RWHV has not yet been set, the surface ID namespace will get |
342 // passed down by the call to SetView(). | 339 // passed down by the call to SetView(). |
343 if (view_) { | 340 if (view_) { |
344 Send(new ViewMsg_SetSurfaceIdNamespace(GetRoutingID(), | 341 Send(new ViewMsg_SetSurfaceIdNamespace(GetRoutingID(), |
345 view_->GetSurfaceIdNamespace())); | 342 view_->GetSurfaceIdNamespace())); |
346 } | 343 } |
347 | 344 |
348 // If it's enabled, tell the renderer to set up the Javascript bindings for | 345 // If it's enabled, tell the renderer to set up the Javascript bindings for |
349 // sending messages back to the browser. | 346 // sending messages back to the browser. |
350 if (GetProcess()->IsIsolatedGuest()) | 347 if (GetProcess()->IsIsolatedGuest()) |
351 DCHECK_EQ(0, enabled_bindings_); | 348 DCHECK_EQ(0, enabled_bindings_); |
352 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | 349 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); |
353 // Let our delegate know that we created a RenderView. | 350 // Let our delegate know that we created a RenderView. |
354 delegate_->RenderViewCreated(this); | 351 delegate_->RenderViewCreated(this); |
355 | 352 |
356 // Since this method creates the main RenderFrame in the renderer process, | 353 // Since this method can create the main RenderFrame in the renderer process, |
357 // set the proper state on its corresponding RenderFrameHost. | 354 // set the proper state on its corresponding RenderFrameHost. |
358 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) | 355 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { |
359 ->SetRenderFrameCreated(true); | 356 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) |
357 ->SetRenderFrameCreated(true); | |
358 } | |
360 | 359 |
361 return true; | 360 return true; |
362 } | 361 } |
363 | 362 |
364 bool RenderViewHostImpl::IsRenderViewLive() const { | 363 bool RenderViewHostImpl::IsRenderViewLive() const { |
365 return GetProcess()->HasConnection() && renderer_initialized(); | 364 return GetProcess()->HasConnection() && renderer_initialized(); |
366 } | 365 } |
367 | 366 |
368 void RenderViewHostImpl::SyncRendererPrefs() { | 367 void RenderViewHostImpl::SyncRendererPrefs() { |
369 RendererPreferences renderer_preferences = | 368 RendererPreferences renderer_preferences = |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 | 871 |
873 /////////////////////////////////////////////////////////////////////////////// | 872 /////////////////////////////////////////////////////////////////////////////// |
874 // RenderViewHostImpl, IPC message handlers: | 873 // RenderViewHostImpl, IPC message handlers: |
875 | 874 |
876 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { | 875 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
877 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 876 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
878 return true; | 877 return true; |
879 | 878 |
880 // Filter out most IPC messages if this renderer is swapped out. | 879 // Filter out most IPC messages if this renderer is swapped out. |
881 // We still want to handle certain ACKs to keep our state consistent. | 880 // We still want to handle certain ACKs to keep our state consistent. |
882 if (is_swapped_out_) { | 881 if (is_swapped_out_ || main_frame_routing_id_ == MSG_ROUTING_NONE) { |
Charlie Reis
2015/06/04 22:27:31
This means subframes can't send (most) IPCs throug
nasko
2015/06/04 23:38:36
Ah, good catch! I was trying to be more defensive
Charlie Reis
2015/06/05 18:28:45
Acknowledged.
| |
883 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { | 882 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
884 // If this is a synchronous message and we decided not to handle it, | 883 // If this is a synchronous message and we decided not to handle it, |
885 // we must send an error reply, or else the renderer will be stuck | 884 // we must send an error reply, or else the renderer will be stuck |
886 // and won't respond to future requests. | 885 // and won't respond to future requests. |
887 if (msg.is_sync()) { | 886 if (msg.is_sync()) { |
888 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 887 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
889 reply->set_reply_error(); | 888 reply->set_reply_error(); |
890 Send(reply); | 889 Send(reply); |
891 } | 890 } |
892 // Don't continue looking for someone to handle it. | 891 // Don't continue looking for someone to handle it. |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 if (!policy->CanReadFile(GetProcess()->GetID(), file)) | 1431 if (!policy->CanReadFile(GetProcess()->GetID(), file)) |
1433 policy->GrantReadFile(GetProcess()->GetID(), file); | 1432 policy->GrantReadFile(GetProcess()->GetID(), file); |
1434 } | 1433 } |
1435 } | 1434 } |
1436 | 1435 |
1437 void RenderViewHostImpl::SelectWordAroundCaret() { | 1436 void RenderViewHostImpl::SelectWordAroundCaret() { |
1438 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1437 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1439 } | 1438 } |
1440 | 1439 |
1441 } // namespace content | 1440 } // namespace content |
OLD | NEW |