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 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/devtools_agent_host_client.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 | 18 |
17 class DevToolsExternalAgentProxyDelegate; | 19 class DevToolsExternalAgentProxyDelegate; |
18 class WebContents; | 20 class WebContents; |
19 | 21 |
20 // Describes interface for managing devtools agents from browser process. | 22 // Describes interface for managing devtools agents from browser process. |
21 class CONTENT_EXPORT DevToolsAgentHost | 23 class CONTENT_EXPORT DevToolsAgentHost |
22 : public base::RefCounted<DevToolsAgentHost> { | 24 : public base::RefCounted<DevToolsAgentHost> { |
23 public: | 25 public: |
(...skipping 18 matching lines...) Expand all Loading... |
42 // provided |delegate|. |delegate| ownership is passed to the created agent | 44 // provided |delegate|. |delegate| ownership is passed to the created agent |
43 // host. | 45 // host. |
44 static scoped_refptr<DevToolsAgentHost> Create( | 46 static scoped_refptr<DevToolsAgentHost> Create( |
45 DevToolsExternalAgentProxyDelegate* delegate); | 47 DevToolsExternalAgentProxyDelegate* delegate); |
46 | 48 |
47 static bool IsDebuggerAttached(WebContents* web_contents); | 49 static bool IsDebuggerAttached(WebContents* web_contents); |
48 | 50 |
49 // Returns a list of all existing WebContents that can be debugged. | 51 // Returns a list of all existing WebContents that can be debugged. |
50 static std::vector<WebContents*> GetInspectableWebContents(); | 52 static std::vector<WebContents*> GetInspectableWebContents(); |
51 | 53 |
| 54 // Client attaches to this agent host to start debugging it. |
| 55 virtual void AttachClient(DevToolsAgentHostClient* client) = 0; |
| 56 |
| 57 // Already attached client detaches from this agent host to stop debugging it. |
| 58 virtual void DetachClient() = 0; |
| 59 |
52 // Returns true if there is a client attached. | 60 // Returns true if there is a client attached. |
53 virtual bool IsAttached() = 0; | 61 virtual bool IsAttached() = 0; |
54 | 62 |
| 63 // Sends a message to the agent. |
| 64 virtual void DispatchProtocolMessage(const std::string& message) = 0; |
| 65 |
55 // Starts inspecting element at position (|x|, |y|) in the specified page. | 66 // Starts inspecting element at position (|x|, |y|) in the specified page. |
56 virtual void InspectElement(int x, int y) = 0; | 67 virtual void InspectElement(int x, int y) = 0; |
57 | 68 |
58 // Returns the unique id of the agent. | 69 // Returns the unique id of the agent. |
59 virtual std::string GetId() = 0; | 70 virtual std::string GetId() = 0; |
60 | 71 |
61 // Returns web contents instance for this host if any. | 72 // Returns web contents instance for this host if any. |
62 virtual WebContents* GetWebContents() = 0; | 73 virtual WebContents* GetWebContents() = 0; |
63 | 74 |
64 // Temporarily detaches render view host from this host. Must be followed by | 75 // Temporarily detaches render view host from this host. Must be followed by |
65 // a call to ConnectWebContents (may leak the host instance otherwise). | 76 // a call to ConnectWebContents (may leak the host instance otherwise). |
66 virtual void DisconnectWebContents() = 0; | 77 virtual void DisconnectWebContents() = 0; |
67 | 78 |
68 // Attaches render view host to this host. | 79 // Attaches render view host to this host. |
69 virtual void ConnectWebContents(WebContents* web_contents) = 0; | 80 virtual void ConnectWebContents(WebContents* web_contents) = 0; |
70 | 81 |
71 // Returns true if DevToolsAgentHost is for worker. | 82 // Returns true if DevToolsAgentHost is for worker. |
72 virtual bool IsWorker() const = 0; | 83 virtual bool IsWorker() const = 0; |
73 | 84 |
| 85 // Terminates all debugging sessions and detaches all clients. |
| 86 static void DetachAllClients(); |
| 87 |
| 88 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> |
| 89 AgentStateCallback; |
| 90 |
| 91 static void AddAgentStateCallback(const AgentStateCallback& callback); |
| 92 static void RemoveAgentStateCallback(const AgentStateCallback& callback); |
| 93 |
74 protected: | 94 protected: |
75 friend class base::RefCounted<DevToolsAgentHost>; | 95 friend class base::RefCounted<DevToolsAgentHost>; |
76 virtual ~DevToolsAgentHost() {} | 96 virtual ~DevToolsAgentHost() {} |
77 }; | 97 }; |
78 | 98 |
79 } // namespace content | 99 } // namespace content |
80 | 100 |
81 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 101 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |