| 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 "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 10 #include "content/browser/devtools/devtools_manager_impl.h" | 11 #include "content/browser/devtools/devtools_manager_impl.h" |
| 11 #include "content/browser/devtools/devtools_power_handler.h" | 12 #include "content/browser/devtools/devtools_power_handler.h" |
| 12 #include "content/browser/devtools/devtools_protocol.h" | 13 #include "content/browser/devtools/devtools_protocol.h" |
| 13 #include "content/browser/devtools/devtools_protocol_constants.h" | 14 #include "content/browser/devtools/devtools_protocol_constants.h" |
| 14 #include "content/browser/devtools/devtools_tracing_handler.h" | 15 #include "content/browser/devtools/devtools_tracing_handler.h" |
| 15 #include "content/browser/devtools/renderer_overrides_handler.h" | 16 #include "content/browser/devtools/renderer_overrides_handler.h" |
| 16 #include "content/browser/renderer_host/render_process_host_impl.h" | 17 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 17 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 18 #include "content/browser/site_instance_impl.h" | 19 #include "content/browser/site_instance_impl.h" |
| 19 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
| 20 #include "content/common/devtools_messages.h" | 21 #include "content/common/devtools_messages.h" |
| 21 #include "content/common/view_messages.h" | 22 #include "content/common/view_messages.h" |
| 22 #include "content/public/browser/content_browser_client.h" | 23 #include "content/public/browser/content_browser_client.h" |
| 23 #include "content/public/browser/devtools_manager_delegate.h" | 24 #include "content/public/browser/devtools_manager_delegate.h" |
| 24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_widget_host_iterator.h" | 27 #include "content/public/browser/render_widget_host_iterator.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" |
| 27 | 29 |
| 28 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
| 29 #include "content/browser/power_save_blocker_impl.h" | 31 #include "content/browser/power_save_blocker_impl.h" |
| 30 #include "content/public/browser/render_widget_host_view.h" | 32 #include "content/public/browser/render_widget_host_view.h" |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 namespace content { | 35 namespace content { |
| 34 | 36 |
| 35 typedef std::vector<RenderViewDevToolsAgentHost*> Instances; | 37 typedef std::vector<RenderViewDevToolsAgentHost*> Instances; |
| 36 | 38 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 return FindAgentHost(web_contents) != NULL; | 67 return FindAgentHost(web_contents) != NULL; |
| 66 } | 68 } |
| 67 | 69 |
| 68 // static | 70 // static |
| 69 bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) { | 71 bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) { |
| 70 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); | 72 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); |
| 71 return agent_host && agent_host->IsAttached(); | 73 return agent_host && agent_host->IsAttached(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 //static | 76 //static |
| 75 std::vector<WebContents*> DevToolsAgentHost::GetInspectableWebContents() { | 77 std::vector<WebContents*> DevToolsAgentHostImpl::GetInspectableWebContents() { |
| 76 std::set<WebContents*> set; | 78 std::set<WebContents*> set; |
| 77 scoped_ptr<RenderWidgetHostIterator> widgets( | 79 scoped_ptr<RenderWidgetHostIterator> widgets( |
| 78 RenderWidgetHost::GetRenderWidgetHosts()); | 80 RenderWidgetHost::GetRenderWidgetHosts()); |
| 79 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 81 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 80 // Ignore processes that don't have a connection, such as crashed contents. | 82 // Ignore processes that don't have a connection, such as crashed contents. |
| 81 if (!widget->GetProcess()->HasConnection()) | 83 if (!widget->GetProcess()->HasConnection()) |
| 82 continue; | 84 continue; |
| 83 if (!widget->IsRenderView()) | 85 if (!widget->IsRenderView()) |
| 84 continue; | 86 continue; |
| 85 | 87 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 365 } |
| 364 | 366 |
| 365 void RenderViewDevToolsAgentHost::DisconnectWebContents() { | 367 void RenderViewDevToolsAgentHost::DisconnectWebContents() { |
| 366 DisconnectRenderViewHost(); | 368 DisconnectRenderViewHost(); |
| 367 } | 369 } |
| 368 | 370 |
| 369 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { | 371 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { |
| 370 ConnectRenderViewHost(wc->GetRenderViewHost()); | 372 ConnectRenderViewHost(wc->GetRenderViewHost()); |
| 371 } | 373 } |
| 372 | 374 |
| 375 std::string RenderViewDevToolsAgentHost::GetType() { |
| 376 return kAgentHostTypePage; |
| 377 } |
| 378 |
| 379 std::string RenderViewDevToolsAgentHost::GetTitle() { |
| 380 if (WebContents* web_contents = GetWebContents()) |
| 381 return base::UTF16ToUTF8(web_contents->GetTitle()); |
| 382 return ""; |
| 383 } |
| 384 |
| 385 GURL RenderViewDevToolsAgentHost::GetURL() { |
| 386 if (WebContents* web_contents = GetWebContents()) |
| 387 return web_contents->GetURL(); |
| 388 return GURL(); |
| 389 } |
| 390 |
| 391 bool RenderViewDevToolsAgentHost::Activate() { |
| 392 if (WebContents* web_contents = GetWebContents()) { |
| 393 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 394 return true; |
| 395 } |
| 396 return false; |
| 397 } |
| 398 |
| 399 bool RenderViewDevToolsAgentHost::Close() { |
| 400 if (WebContents* web_contents = GetWebContents()) { |
| 401 web_contents->GetRenderViewHost()->ClosePage(); |
| 402 return true; |
| 403 } |
| 404 return false; |
| 405 } |
| 406 |
| 373 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { | 407 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { |
| 374 SetRenderViewHost(rvh); | 408 SetRenderViewHost(rvh); |
| 375 if (IsAttached()) | 409 if (IsAttached()) |
| 376 Reattach(state_); | 410 Reattach(state_); |
| 377 } | 411 } |
| 378 | 412 |
| 379 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { | 413 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { |
| 380 ClientDetachedFromRenderer(); | 414 ClientDetachedFromRenderer(); |
| 381 ClearRenderViewHost(); | 415 ClearRenderViewHost(); |
| 382 } | 416 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 DevToolsProtocol::ParseNotification(message); | 479 DevToolsProtocol::ParseNotification(message); |
| 446 | 480 |
| 447 if (notification) { | 481 if (notification) { |
| 448 tracing_handler_->HandleNotification(notification); | 482 tracing_handler_->HandleNotification(notification); |
| 449 } | 483 } |
| 450 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( | 484 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( |
| 451 this, message); | 485 this, message); |
| 452 } | 486 } |
| 453 | 487 |
| 454 } // namespace content | 488 } // namespace content |
| OLD | NEW |