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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 366 } |
365 | 367 |
366 void RenderViewDevToolsAgentHost::DisconnectWebContents() { | 368 void RenderViewDevToolsAgentHost::DisconnectWebContents() { |
367 DisconnectRenderViewHost(); | 369 DisconnectRenderViewHost(); |
368 } | 370 } |
369 | 371 |
370 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { | 372 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { |
371 ConnectRenderViewHost(wc->GetRenderViewHost()); | 373 ConnectRenderViewHost(wc->GetRenderViewHost()); |
372 } | 374 } |
373 | 375 |
| 376 DevToolsAgentHost::Type RenderViewDevToolsAgentHost::GetType() { |
| 377 return AGENT_HOST_WEB_CONTENTS; |
| 378 } |
| 379 |
| 380 std::string RenderViewDevToolsAgentHost::GetTitle() { |
| 381 if (WebContents* web_contents = GetWebContents()) |
| 382 return base::UTF16ToUTF8(web_contents->GetTitle()); |
| 383 return ""; |
| 384 } |
| 385 |
| 386 GURL RenderViewDevToolsAgentHost::GetURL() { |
| 387 return render_view_host_ ? |
| 388 render_view_host_->GetMainFrame()->GetLastCommittedURL() : GURL(); |
| 389 } |
| 390 |
| 391 bool RenderViewDevToolsAgentHost::Activate() { |
| 392 if (render_view_host_) { |
| 393 render_view_host_->GetDelegate()->Activate(); |
| 394 return true; |
| 395 } |
| 396 return false; |
| 397 } |
| 398 |
| 399 bool RenderViewDevToolsAgentHost::Close() { |
| 400 if (render_view_host_) { |
| 401 render_view_host_->ClosePage(); |
| 402 return true; |
| 403 } |
| 404 return false; |
| 405 } |
| 406 |
374 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { | 407 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { |
375 SetRenderViewHost(rvh); | 408 SetRenderViewHost(rvh); |
376 if (IsAttached()) | 409 if (IsAttached()) |
377 Reattach(state_); | 410 Reattach(state_); |
378 } | 411 } |
379 | 412 |
380 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { | 413 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { |
381 ClientDetachedFromRenderer(); | 414 ClientDetachedFromRenderer(); |
382 ClearRenderViewHost(); | 415 ClearRenderViewHost(); |
383 } | 416 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 scoped_refptr<DevToolsProtocol::Notification> notification = | 477 scoped_refptr<DevToolsProtocol::Notification> notification = |
445 DevToolsProtocol::ParseNotification(message); | 478 DevToolsProtocol::ParseNotification(message); |
446 | 479 |
447 if (notification) { | 480 if (notification) { |
448 tracing_handler_->HandleNotification(notification); | 481 tracing_handler_->HandleNotification(notification); |
449 } | 482 } |
450 SendMessageToClient(message); | 483 SendMessageToClient(message); |
451 } | 484 } |
452 | 485 |
453 } // namespace content | 486 } // namespace content |
OLD | NEW |