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 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "content/browser/debugger/devtools_agent_host.h" | 13 #include "content/browser/debugger/devtools_agent_host.h" |
14 #include "content/browser/debugger/devtools_client_host.h" | 14 #include "content/browser/debugger/devtools_client_host.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/devtools/devtools_manager.h" |
16 | 17 |
17 class DevToolsAgentHost; | 18 class DevToolsAgentHost; |
18 class GURL; | 19 class GURL; |
19 class RenderViewHost; | 20 class RenderViewHost; |
20 class TabContents; | 21 class TabContents; |
21 | 22 |
22 namespace IPC { | 23 namespace IPC { |
23 class Message; | 24 class Message; |
24 } | 25 } |
25 | 26 |
26 // This class is a singleton that manages DevToolsClientHost instances and | 27 // This class is a singleton that manages DevToolsClientHost instances and |
27 // routes messages between developer tools clients and agents. | 28 // routes messages between developer tools clients and agents. |
28 // | 29 // |
29 // Methods below that accept inspected RenderViewHost as a parameter are | 30 // Methods below that accept inspected RenderViewHost as a parameter are |
30 // just convenience methods that call corresponding methods accepting | 31 // just convenience methods that call corresponding methods accepting |
31 // DevToolAgentHost. | 32 // DevToolAgentHost. |
32 class CONTENT_EXPORT DevToolsManager | 33 class CONTENT_EXPORT DevToolsManager |
33 : public DevToolsClientHost::CloseListener, | 34 : public DevToolsClientHost::CloseListener, |
34 public DevToolsAgentHost::CloseListener { | 35 public DevToolsAgentHost::CloseListener, |
| 36 public content::DevToolsManager { |
35 public: | 37 public: |
36 static DevToolsManager* GetInstance(); | 38 static DevToolsManager* GetInstance(); |
37 | 39 |
38 DevToolsManager(); | 40 DevToolsManager(); |
39 virtual ~DevToolsManager(); | 41 virtual ~DevToolsManager(); |
40 | 42 |
41 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if | 43 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if |
42 // there is no alive DevToolsClientHost registered for |inspected_rvh|. | 44 // there is no alive DevToolsClientHost registered for |inspected_rvh|. |
43 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); | 45 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
44 | 46 |
45 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no | 47 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no |
46 // other DevToolsClientHosts registered for the RenderViewHost at the moment. | 48 // other DevToolsClientHosts registered for the RenderViewHost at the moment. |
47 void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh, | |
48 DevToolsClientHost* client_host); | |
49 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); | 49 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
50 | 50 |
51 bool ForwardToDevToolsAgent(DevToolsClientHost* from, | 51 virtual bool ForwardToDevToolsAgent(DevToolsClientHost* from, |
52 const IPC::Message& message); | 52 const IPC::Message& message) OVERRIDE; |
53 void ForwardToDevToolsClient(DevToolsAgentHost* agent_host, | 53 void ForwardToDevToolsClient(DevToolsAgentHost* agent_host, |
54 const IPC::Message& message); | 54 const IPC::Message& message); |
55 | 55 |
56 void SaveAgentRuntimeState(DevToolsAgentHost* agent_host, | 56 void SaveAgentRuntimeState(DevToolsAgentHost* agent_host, |
57 const std::string& state); | 57 const std::string& state); |
58 | 58 |
59 // Sends 'Attach' message to the agent using |dest_rvh| in case | 59 // Sends 'Attach' message to the agent using |dest_rvh| in case |
60 // there is a DevToolsClientHost registered for the |inspected_rvh|. | 60 // there is a DevToolsClientHost registered for the |inspected_rvh|. |
61 void OnNavigatingToPendingEntry(RenderViewHost* inspected_rvh, | 61 void OnNavigatingToPendingEntry(RenderViewHost* inspected_rvh, |
62 RenderViewHost* dest_rvh, | 62 RenderViewHost* dest_rvh, |
63 const GURL& gurl); | 63 const GURL& gurl); |
64 void OnCancelPendingNavigation(RenderViewHost* pending, | 64 void OnCancelPendingNavigation(RenderViewHost* pending, |
65 RenderViewHost* current); | 65 RenderViewHost* current); |
66 | 66 |
67 // Invoked when a tab is replaced by another tab. This is triggered by | 67 // Invoked when a tab is replaced by another tab. This is triggered by |
68 // TabStripModel::ReplaceTabContentsAt. | 68 // TabStripModel::ReplaceTabContentsAt. |
69 void TabReplaced(TabContents* old_tab, TabContents* new_tab); | 69 virtual void TabReplaced(TabContents* old_tab, TabContents* new_tab) OVERRIDE; |
70 | 70 |
71 // Detaches client host and returns cookie that can be used in | 71 // Detaches client host and returns cookie that can be used in |
72 // AttachClientHost. | 72 // AttachClientHost. |
73 int DetachClientHost(RenderViewHost* from_rvh); | 73 int DetachClientHost(RenderViewHost* from_rvh); |
74 | 74 |
75 // Attaches orphan client host to new render view host. | 75 // Attaches orphan client host to new render view host. |
76 void AttachClientHost(int client_host_cookie, | 76 void AttachClientHost(int client_host_cookie, |
77 RenderViewHost* to_rvh); | 77 RenderViewHost* to_rvh); |
78 | 78 |
79 // Closes all open developer tools windows. | 79 // Closes all open developer tools windows. |
80 void CloseAllClientHosts(); | 80 virtual void CloseAllClientHosts() OVERRIDE; |
81 | 81 |
82 void AttachClientHost(int client_host_cookie, | 82 virtual void AttachClientHost(int client_host_cookie, |
83 DevToolsAgentHost* to_agent); | 83 DevToolsAgentHost* to_agent) OVERRIDE; |
84 DevToolsClientHost* GetDevToolsClientHostFor(DevToolsAgentHost* agent_host); | 84 virtual DevToolsClientHost* GetDevToolsClientHostFor( |
85 void RegisterDevToolsClientHostFor(DevToolsAgentHost* agent_host, | 85 DevToolsAgentHost* agent_host) OVERRIDE; |
86 DevToolsClientHost* client_host); | 86 virtual void RegisterDevToolsClientHostFor( |
87 void UnregisterDevToolsClientHostFor(DevToolsAgentHost* agent_host); | 87 DevToolsAgentHost* agent_host, |
88 int DetachClientHost(DevToolsAgentHost* from_agent); | 88 DevToolsClientHost* client_host) OVERRIDE; |
| 89 virtual void UnregisterDevToolsClientHostFor( |
| 90 DevToolsAgentHost* agent_host) OVERRIDE; |
| 91 virtual int DetachClientHost(DevToolsAgentHost* from_agent) OVERRIDE; |
89 | 92 |
90 private: | 93 private: |
91 // DevToolsClientHost::CloseListener override. | 94 // DevToolsClientHost::CloseListener override. |
92 // This method will remove all references from the manager to the | 95 // This method will remove all references from the manager to the |
93 // DevToolsClientHost and unregister all listeners related to the | 96 // DevToolsClientHost and unregister all listeners related to the |
94 // DevToolsClientHost. | 97 // DevToolsClientHost. |
95 virtual void ClientHostClosing(DevToolsClientHost* host) OVERRIDE; | 98 virtual void ClientHostClosing(DevToolsClientHost* host) OVERRIDE; |
96 | 99 |
97 // DevToolsAgentHost::CloseListener implementation. | 100 // DevToolsAgentHost::CloseListener implementation. |
98 virtual void AgentHostClosing(DevToolsAgentHost* host) OVERRIDE; | 101 virtual void AgentHostClosing(DevToolsAgentHost* host) OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
124 | 127 |
125 typedef std::map<int, std::pair<DevToolsClientHost*, std::string> > | 128 typedef std::map<int, std::pair<DevToolsClientHost*, std::string> > |
126 OrphanClientHosts; | 129 OrphanClientHosts; |
127 OrphanClientHosts orphan_client_hosts_; | 130 OrphanClientHosts orphan_client_hosts_; |
128 int last_orphan_cookie_; | 131 int last_orphan_cookie_; |
129 | 132 |
130 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); | 133 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
131 }; | 134 }; |
132 | 135 |
133 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 136 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
OLD | NEW |