| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 is_active_(!swapped_out), | 217 is_active_(!swapped_out), |
| 218 is_swapped_out_(swapped_out), | 218 is_swapped_out_(swapped_out), |
| 219 main_frame_routing_id_(main_frame_routing_id), | 219 main_frame_routing_id_(main_frame_routing_id), |
| 220 is_waiting_for_close_ack_(false), | 220 is_waiting_for_close_ack_(false), |
| 221 sudden_termination_allowed_(false), | 221 sudden_termination_allowed_(false), |
| 222 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 222 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 223 virtual_keyboard_requested_(false), | 223 virtual_keyboard_requested_(false), |
| 224 is_focused_element_editable_(false), | 224 is_focused_element_editable_(false), |
| 225 updating_web_preferences_(false), | 225 updating_web_preferences_(false), |
| 226 weak_factory_(this) { | 226 weak_factory_(this) { |
| 227 LOG(ERROR) << "RVH[" << this << "]::RVH:" |
| 228 << " routing_id:" << routing_id |
| 229 << " site:" << instance->GetId() << "," << instance->GetSiteURL(); |
| 230 |
| 227 DCHECK(instance_.get()); | 231 DCHECK(instance_.get()); |
| 228 CHECK(delegate_); // http://crbug.com/82827 | 232 CHECK(delegate_); // http://crbug.com/82827 |
| 229 | 233 |
| 230 GetProcess()->AddObserver(this); | 234 GetProcess()->AddObserver(this); |
| 231 GetProcess()->EnableSendQueue(); | 235 GetProcess()->EnableSendQueue(); |
| 232 | 236 |
| 233 if (ResourceDispatcherHostImpl::Get()) { | 237 if (ResourceDispatcherHostImpl::Get()) { |
| 234 bool has_active_audio = false; | 238 bool has_active_audio = false; |
| 235 if (has_initialized_audio_host) { | 239 if (has_initialized_audio_host) { |
| 236 scoped_refptr<AudioRendererHost> arh = | 240 scoped_refptr<AudioRendererHost> arh = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 256 if (ResourceDispatcherHostImpl::Get()) { | 260 if (ResourceDispatcherHostImpl::Get()) { |
| 257 BrowserThread::PostTask( | 261 BrowserThread::PostTask( |
| 258 BrowserThread::IO, FROM_HERE, | 262 BrowserThread::IO, FROM_HERE, |
| 259 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 263 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
| 260 base::Unretained(ResourceDispatcherHostImpl::Get()), | 264 base::Unretained(ResourceDispatcherHostImpl::Get()), |
| 261 GetProcess()->GetID(), GetRoutingID())); | 265 GetProcess()->GetID(), GetRoutingID())); |
| 262 } | 266 } |
| 263 | 267 |
| 264 delegate_->RenderViewDeleted(this); | 268 delegate_->RenderViewDeleted(this); |
| 265 GetProcess()->RemoveObserver(this); | 269 GetProcess()->RemoveObserver(this); |
| 270 LOG(ERROR) << "RVH[" << this << "]::~RVH"; |
| 266 } | 271 } |
| 267 | 272 |
| 268 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 273 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
| 269 return delegate_; | 274 return delegate_; |
| 270 } | 275 } |
| 271 | 276 |
| 272 SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { | 277 SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { |
| 273 return instance_.get(); | 278 return instance_.get(); |
| 274 } | 279 } |
| 275 | 280 |
| 276 bool RenderViewHostImpl::CreateRenderView( | 281 bool RenderViewHostImpl::CreateRenderView( |
| 277 const base::string16& frame_name, | 282 const base::string16& frame_name, |
| 278 int opener_route_id, | 283 int opener_route_id, |
| 279 int proxy_route_id, | 284 int proxy_route_id, |
| 280 int32 max_page_id, | 285 int32 max_page_id, |
| 281 const FrameReplicationState& replicated_frame_state, | 286 const FrameReplicationState& replicated_frame_state, |
| 282 bool window_was_created_with_opener) { | 287 bool window_was_created_with_opener) { |
| 283 TRACE_EVENT0("renderer_host,navigation", | 288 TRACE_EVENT0("renderer_host,navigation", |
| 284 "RenderViewHostImpl::CreateRenderView"); | 289 "RenderViewHostImpl::CreateRenderView"); |
| 285 DCHECK(!IsRenderViewLive()) << "Creating view twice"; | 290 DCHECK(!IsRenderViewLive()) << "Creating view twice"; |
| 286 | 291 |
| 292 LOG(ERROR) << "RVH[" << this << "]::CreateRenderView: "; |
| 293 |
| 287 // The process may (if we're sharing a process with another host that already | 294 // The process may (if we're sharing a process with another host that already |
| 288 // initialized it) or may not (we have our own process or the old process | 295 // initialized it) or may not (we have our own process or the old process |
| 289 // crashed) have been initialized. Calling Init multiple times will be | 296 // crashed) have been initialized. Calling Init multiple times will be |
| 290 // ignored, so this is safe. | 297 // ignored, so this is safe. |
| 291 if (!GetProcess()->Init()) | 298 if (!GetProcess()->Init()) { |
| 299 LOG(ERROR) << "RVH[" << this << "]::CreateRenderView: " |
| 300 << " failed to init process"; |
| 292 return false; | 301 return false; |
| 302 } |
| 293 DCHECK(GetProcess()->HasConnection()); | 303 DCHECK(GetProcess()->HasConnection()); |
| 294 DCHECK(GetProcess()->GetBrowserContext()); | 304 DCHECK(GetProcess()->GetBrowserContext()); |
| 295 | 305 |
| 306 LOG(ERROR) << "RVH[" << this << "]::CreateRenderView: " |
| 307 << " setting initialized to true"; |
| 308 |
| 296 set_renderer_initialized(true); | 309 set_renderer_initialized(true); |
| 297 | 310 |
| 298 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 311 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
| 299 surface_id(), GetCompositingSurface()); | 312 surface_id(), GetCompositingSurface()); |
| 300 | 313 |
| 301 // Ensure the RenderView starts with a next_page_id larger than any existing | 314 // Ensure the RenderView starts with a next_page_id larger than any existing |
| 302 // page ID it might be asked to render. | 315 // page ID it might be asked to render. |
| 303 int32 next_page_id = 1; | 316 int32 next_page_id = 1; |
| 304 if (max_page_id > -1) | 317 if (max_page_id > -1) |
| 305 next_page_id = max_page_id + 1; | 318 next_page_id = max_page_id + 1; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 324 params.proxy_routing_id = proxy_route_id; | 337 params.proxy_routing_id = proxy_route_id; |
| 325 params.hidden = is_hidden(); | 338 params.hidden = is_hidden(); |
| 326 params.never_visible = delegate_->IsNeverVisible(); | 339 params.never_visible = delegate_->IsNeverVisible(); |
| 327 params.window_was_created_with_opener = window_was_created_with_opener; | 340 params.window_was_created_with_opener = window_was_created_with_opener; |
| 328 params.next_page_id = next_page_id; | 341 params.next_page_id = next_page_id; |
| 329 params.enable_auto_resize = auto_resize_enabled(); | 342 params.enable_auto_resize = auto_resize_enabled(); |
| 330 params.min_size = min_size_for_auto_resize(); | 343 params.min_size = min_size_for_auto_resize(); |
| 331 params.max_size = max_size_for_auto_resize(); | 344 params.max_size = max_size_for_auto_resize(); |
| 332 GetResizeParams(¶ms.initial_size); | 345 GetResizeParams(¶ms.initial_size); |
| 333 | 346 |
| 334 if (!Send(new ViewMsg_New(params))) | 347 if (!Send(new ViewMsg_New(params))) { |
| 348 LOG(ERROR) << "RVH[" << this << "]::CreateRenderView: " |
| 349 << " failed to send ViewMsg_New"; |
| 335 return false; | 350 return false; |
| 351 } |
| 336 SetInitialRenderSizeParams(params.initial_size); | 352 SetInitialRenderSizeParams(params.initial_size); |
| 337 | 353 |
| 338 // If the RWHV has not yet been set, the surface ID namespace will get | 354 // If the RWHV has not yet been set, the surface ID namespace will get |
| 339 // passed down by the call to SetView(). | 355 // passed down by the call to SetView(). |
| 340 if (view_) { | 356 if (view_) { |
| 341 Send(new ViewMsg_SetSurfaceIdNamespace(GetRoutingID(), | 357 Send(new ViewMsg_SetSurfaceIdNamespace(GetRoutingID(), |
| 342 view_->GetSurfaceIdNamespace())); | 358 view_->GetSurfaceIdNamespace())); |
| 343 } | 359 } |
| 344 | 360 |
| 345 // If it's enabled, tell the renderer to set up the Javascript bindings for | 361 // If it's enabled, tell the renderer to set up the Javascript bindings for |
| 346 // sending messages back to the browser. | 362 // sending messages back to the browser. |
| 347 if (GetProcess()->IsForGuestsOnly()) | 363 if (GetProcess()->IsForGuestsOnly()) |
| 348 DCHECK_EQ(0, enabled_bindings_); | 364 DCHECK_EQ(0, enabled_bindings_); |
| 349 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | 365 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); |
| 350 // Let our delegate know that we created a RenderView. | 366 // Let our delegate know that we created a RenderView. |
| 351 delegate_->RenderViewCreated(this); | 367 delegate_->RenderViewCreated(this); |
| 352 | 368 |
| 353 // Since this method can create the main RenderFrame in the renderer process, | 369 // Since this method can create the main RenderFrame in the renderer process, |
| 354 // set the proper state on its corresponding RenderFrameHost. | 370 // set the proper state on its corresponding RenderFrameHost. |
| 355 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { | 371 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { |
| 372 LOG(ERROR) << "RVH[" << this << "]::CreateRenderView: " |
| 373 << " main_frame_routing_id_:" << main_frame_routing_id_ |
| 374 << " setting RFH as created"; |
| 356 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) | 375 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) |
| 357 ->SetRenderFrameCreated(true); | 376 ->SetRenderFrameCreated(true); |
| 358 } | 377 } |
| 359 | 378 |
| 360 return true; | 379 return true; |
| 361 } | 380 } |
| 362 | 381 |
| 363 bool RenderViewHostImpl::IsRenderViewLive() const { | 382 bool RenderViewHostImpl::IsRenderViewLive() const { |
| 364 return GetProcess()->HasConnection() && renderer_initialized(); | 383 return GetProcess()->HasConnection() && renderer_initialized(); |
| 365 } | 384 } |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 if (!policy->CanReadFile(GetProcess()->GetID(), file)) | 1447 if (!policy->CanReadFile(GetProcess()->GetID(), file)) |
| 1429 policy->GrantReadFile(GetProcess()->GetID(), file); | 1448 policy->GrantReadFile(GetProcess()->GetID(), file); |
| 1430 } | 1449 } |
| 1431 } | 1450 } |
| 1432 | 1451 |
| 1433 void RenderViewHostImpl::SelectWordAroundCaret() { | 1452 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1434 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1453 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1435 } | 1454 } |
| 1436 | 1455 |
| 1437 } // namespace content | 1456 } // namespace content |
| OLD | NEW |