| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/debugger/devtools_manager.h" | 5 #include "content/browser/debugger/devtools_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "content/browser/browsing_instance.h" | 11 #include "content/browser/browsing_instance.h" |
| 12 #include "content/browser/child_process_security_policy.h" | 12 #include "content/browser/child_process_security_policy.h" |
| 13 #include "content/browser/debugger/devtools_client_host.h" | 13 #include "content/browser/debugger/devtools_client_host.h" |
| 14 #include "content/browser/debugger/devtools_netlog_observer.h" | 14 #include "content/browser/debugger/devtools_netlog_observer.h" |
| 15 #include "content/browser/debugger/render_view_devtools_agent_host.h" | 15 #include "content/browser/debugger/render_view_devtools_agent_host.h" |
| 16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 namespace content { |
| 25 |
| 26 // static |
| 27 DevToolsManager* DevToolsManager::GetInstance() { |
| 28 return ::DevToolsManager::GetInstance(); |
| 29 } |
| 30 |
| 31 } // namespace |
| 32 |
| 24 // static | 33 // static |
| 25 DevToolsManager* DevToolsManager::GetInstance() { | 34 DevToolsManager* DevToolsManager::GetInstance() { |
| 26 return content::GetContentClient()->browser()->GetDevToolsManager(); | 35 return content::GetContentClient()->browser()->GetDevToolsManager(); |
| 27 } | 36 } |
| 28 | 37 |
| 29 DevToolsManager::DevToolsManager() | 38 DevToolsManager::DevToolsManager() |
| 30 : last_orphan_cookie_(0) { | 39 : last_orphan_cookie_(0) { |
| 31 } | 40 } |
| 32 | 41 |
| 33 DevToolsManager::~DevToolsManager() { | 42 DevToolsManager::~DevToolsManager() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 | 56 |
| 48 DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( | 57 DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( |
| 49 DevToolsAgentHost* agent_host) { | 58 DevToolsAgentHost* agent_host) { |
| 50 AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); | 59 AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); |
| 51 if (it != agent_to_client_host_.end()) | 60 if (it != agent_to_client_host_.end()) |
| 52 return it->second; | 61 return it->second; |
| 53 return NULL; | 62 return NULL; |
| 54 } | 63 } |
| 55 | 64 |
| 56 void DevToolsManager::RegisterDevToolsClientHostFor( | 65 void DevToolsManager::RegisterDevToolsClientHostFor( |
| 57 RenderViewHost* inspected_rvh, | |
| 58 DevToolsClientHost* client_host) { | |
| 59 DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); | |
| 60 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( | |
| 61 inspected_rvh); | |
| 62 RegisterDevToolsClientHostFor(agent_host, client_host); | |
| 63 } | |
| 64 | |
| 65 void DevToolsManager::RegisterDevToolsClientHostFor( | |
| 66 DevToolsAgentHost* agent_host, | 66 DevToolsAgentHost* agent_host, |
| 67 DevToolsClientHost* client_host) { | 67 DevToolsClientHost* client_host) { |
| 68 BindClientHost(agent_host, client_host); | 68 BindClientHost(agent_host, client_host); |
| 69 agent_host->Attach(); | 69 agent_host->Attach(); |
| 70 client_host->set_close_listener(this); | 70 client_host->set_close_listener(this); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, | 73 bool DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, |
| 74 const IPC::Message& message) { | 74 const IPC::Message& message) { |
| 75 DevToolsAgentHost* agent_host = GetAgentHost(from); | 75 DevToolsAgentHost* agent_host = GetAgentHost(from); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 for (AgentToClientHostMap::iterator it = | 288 for (AgentToClientHostMap::iterator it = |
| 289 agent_to_client_host_.begin(); | 289 agent_to_client_host_.begin(); |
| 290 it != agent_to_client_host_.end(); ++it) { | 290 it != agent_to_client_host_.end(); ++it) { |
| 291 agents.push_back(it->first); | 291 agents.push_back(it->first); |
| 292 } | 292 } |
| 293 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); | 293 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); |
| 294 it != agents.end(); ++it) { | 294 it != agents.end(); ++it) { |
| 295 UnregisterDevToolsClientHostFor(*it); | 295 UnregisterDevToolsClientHostFor(*it); |
| 296 } | 296 } |
| 297 } | 297 } |
| OLD | NEW |