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/devtools/render_view_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/devtools/devtools_manager_impl.h" | 10 #include "content/browser/devtools/devtools_manager_impl.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 WebContents* web_contents = WebContents::FromRenderViewHost(pending); | 100 WebContents* web_contents = WebContents::FromRenderViewHost(pending); |
101 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); | 101 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); |
102 if (!agent_host) | 102 if (!agent_host) |
103 return; | 103 return; |
104 agent_host->DisconnectRenderViewHost(); | 104 agent_host->DisconnectRenderViewHost(); |
105 agent_host->ConnectRenderViewHost(current); | 105 agent_host->ConnectRenderViewHost(current); |
106 } | 106 } |
107 | 107 |
108 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) | 108 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) |
109 : render_view_host_(NULL), | 109 : render_view_host_(NULL), |
110 overrides_handler_(new RendererOverridesHandler(this)), | 110 overrides_handler_(new RendererOverridesHandler()), |
111 tracing_handler_( | 111 tracing_handler_( |
112 new DevToolsTracingHandler(DevToolsTracingHandler::Renderer)), | 112 new DevToolsTracingHandler(DevToolsTracingHandler::Renderer)), |
113 power_handler_(new DevToolsPowerHandler()), | 113 power_handler_(new DevToolsPowerHandler()), |
114 reattaching_(false) { | 114 reattaching_(false) { |
115 SetRenderViewHost(rvh); | 115 SetRenderViewHost(rvh); |
116 DevToolsProtocol::Notifier notifier(base::Bind( | 116 DevToolsProtocol::Notifier notifier(base::Bind( |
117 &RenderViewDevToolsAgentHost::OnDispatchOnInspectorFrontend, | 117 &RenderViewDevToolsAgentHost::OnDispatchOnInspectorFrontend, |
118 base::Unretained(this))); | 118 base::Unretained(this))); |
119 overrides_handler_->SetNotifier(notifier); | 119 overrides_handler_->SetNotifier(notifier); |
120 tracing_handler_->SetNotifier(notifier); | 120 tracing_handler_->SetNotifier(notifier); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 this); | 247 this); |
248 if (it != g_instances.Get().end()) | 248 if (it != g_instances.Get().end()) |
249 g_instances.Get().erase(it); | 249 g_instances.Get().erase(it); |
250 } | 250 } |
251 | 251 |
252 void RenderViewDevToolsAgentHost::AboutToNavigateRenderView( | 252 void RenderViewDevToolsAgentHost::AboutToNavigateRenderView( |
253 RenderViewHost* dest_rvh) { | 253 RenderViewHost* dest_rvh) { |
254 if (!render_view_host_) | 254 if (!render_view_host_) |
255 return; | 255 return; |
256 | 256 |
257 if (render_view_host_ == dest_rvh && static_cast<RenderViewHostImpl*>( | 257 if (render_view_host_ == dest_rvh && |
258 render_view_host_)->render_view_termination_status() == | 258 render_view_host_->render_view_termination_status() == |
259 base::TERMINATION_STATUS_STILL_RUNNING) | 259 base::TERMINATION_STATUS_STILL_RUNNING) |
260 return; | 260 return; |
261 ReattachToRenderViewHost(dest_rvh); | 261 ReattachToRenderViewHost(dest_rvh); |
262 } | 262 } |
263 | 263 |
264 void RenderViewDevToolsAgentHost::RenderViewHostChanged( | 264 void RenderViewDevToolsAgentHost::RenderViewHostChanged( |
265 RenderViewHost* old_host, | 265 RenderViewHost* old_host, |
266 RenderViewHost* new_host) { | 266 RenderViewHost* new_host) { |
267 if (new_host != render_view_host_) { | 267 if (new_host != render_view_host_) { |
268 // AboutToNavigateRenderView was not called for renderer-initiated | 268 // AboutToNavigateRenderView was not called for renderer-initiated |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 const NotificationSource& source, | 335 const NotificationSource& source, |
336 const NotificationDetails& details) { | 336 const NotificationDetails& details) { |
337 if (type == content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED) { | 337 if (type == content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED) { |
338 bool visible = *Details<bool>(details).ptr(); | 338 bool visible = *Details<bool>(details).ptr(); |
339 overrides_handler_->OnVisibilityChanged(visible); | 339 overrides_handler_->OnVisibilityChanged(visible); |
340 } | 340 } |
341 } | 341 } |
342 | 342 |
343 void RenderViewDevToolsAgentHost::SetRenderViewHost(RenderViewHost* rvh) { | 343 void RenderViewDevToolsAgentHost::SetRenderViewHost(RenderViewHost* rvh) { |
344 DCHECK(!render_view_host_); | 344 DCHECK(!render_view_host_); |
345 render_view_host_ = rvh; | 345 render_view_host_ = static_cast<RenderViewHostImpl*>(rvh); |
346 | 346 |
347 WebContentsObserver::Observe(WebContents::FromRenderViewHost(rvh)); | 347 WebContentsObserver::Observe(WebContents::FromRenderViewHost(rvh)); |
348 overrides_handler_->OnRenderViewHostChanged(); | 348 overrides_handler_->SetRenderViewHost(render_view_host_); |
349 | 349 |
350 registrar_.Add( | 350 registrar_.Add( |
351 this, | 351 this, |
352 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 352 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
353 content::Source<RenderWidgetHost>(render_view_host_)); | 353 content::Source<RenderWidgetHost>(render_view_host_)); |
354 } | 354 } |
355 | 355 |
356 void RenderViewDevToolsAgentHost::ClearRenderViewHost() { | 356 void RenderViewDevToolsAgentHost::ClearRenderViewHost() { |
357 DCHECK(render_view_host_); | 357 DCHECK(render_view_host_); |
358 registrar_.Remove( | 358 registrar_.Remove( |
359 this, | 359 this, |
360 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 360 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
361 content::Source<RenderWidgetHost>(render_view_host_)); | 361 content::Source<RenderWidgetHost>(render_view_host_)); |
362 render_view_host_ = NULL; | 362 render_view_host_ = NULL; |
| 363 overrides_handler_->ClearRenderViewHost(); |
363 } | 364 } |
364 | 365 |
365 void RenderViewDevToolsAgentHost::DisconnectWebContents() { | 366 void RenderViewDevToolsAgentHost::DisconnectWebContents() { |
366 DisconnectRenderViewHost(); | 367 DisconnectRenderViewHost(); |
367 } | 368 } |
368 | 369 |
369 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { | 370 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { |
370 ConnectRenderViewHost(wc->GetRenderViewHost()); | 371 ConnectRenderViewHost(wc->GetRenderViewHost()); |
371 } | 372 } |
372 | 373 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DevToolsProtocol::ParseNotification(message); | 446 DevToolsProtocol::ParseNotification(message); |
446 | 447 |
447 if (notification) { | 448 if (notification) { |
448 tracing_handler_->HandleNotification(notification); | 449 tracing_handler_->HandleNotification(notification); |
449 } | 450 } |
450 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( | 451 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( |
451 this, message); | 452 this, message); |
452 } | 453 } |
453 | 454 |
454 } // namespace content | 455 } // namespace content |
OLD | NEW |