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 "url/gurl.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 |
22 extern const char kAgentHostTypePage[]; | |
yurys
2014/08/13 07:33:47
Let's make it an enum.
vkuzkokov
2014/08/13 08:21:06
We still need string constants to serialize these
| |
23 extern const char kAgentHostTypeWorker[]; | |
24 extern const char kAgentHostTypeServiceWorker[]; | |
25 | |
20 // Describes interface for managing devtools agents from browser process. | 26 // Describes interface for managing devtools agents from browser process. |
21 class CONTENT_EXPORT DevToolsAgentHost | 27 class CONTENT_EXPORT DevToolsAgentHost |
22 : public base::RefCounted<DevToolsAgentHost> { | 28 : public base::RefCounted<DevToolsAgentHost> { |
23 public: | 29 public: |
24 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. | 30 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. |
25 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); | 31 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); |
26 | 32 |
27 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. | 33 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. |
28 // New DevToolsAgentHost will be created if it does not exist. | 34 // New DevToolsAgentHost will be created if it does not exist. |
29 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( | 35 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( |
30 WebContents* web_contents); | 36 WebContents* web_contents); |
31 | 37 |
32 // Returns true iff an instance of DevToolsAgentHost for the |web_contents| | 38 // Returns true iff an instance of DevToolsAgentHost for the |web_contents| |
33 // does exist. | 39 // does exist. |
34 static bool HasFor(WebContents* web_contents); | 40 static bool HasFor(WebContents* web_contents); |
35 | 41 |
36 // Returns DevToolsAgentHost that can be used for inspecting shared worker | 42 // Returns DevToolsAgentHost that can be used for inspecting shared worker |
37 // with given worker process host id and routing id. | 43 // with given worker process host id and routing id. |
38 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, | 44 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, |
39 int worker_route_id); | 45 int worker_route_id); |
40 | 46 |
41 // Creates DevToolsAgentHost that communicates to the target by means of | 47 // Creates DevToolsAgentHost that communicates to the target by means of |
42 // provided |delegate|. |delegate| ownership is passed to the created agent | 48 // provided |delegate|. |delegate| ownership is passed to the created agent |
43 // host. | 49 // host. |
44 static scoped_refptr<DevToolsAgentHost> Create( | 50 static scoped_refptr<DevToolsAgentHost> Create( |
45 DevToolsExternalAgentProxyDelegate* delegate); | 51 DevToolsExternalAgentProxyDelegate* delegate); |
46 | 52 |
47 static bool IsDebuggerAttached(WebContents* web_contents); | 53 static bool IsDebuggerAttached(WebContents* web_contents); |
48 | 54 |
49 // Returns a list of all existing WebContents that can be debugged. | 55 typedef std::vector<scoped_refptr<DevToolsAgentHost> > List; |
50 static std::vector<WebContents*> GetInspectableWebContents(); | 56 |
57 // Returns all possible DevToolsAgentHosts | |
58 static List GetOrCreateAll(); | |
51 | 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 |
55 // Starts inspecting element at position (|x|, |y|) in the specified page. | 63 // Starts inspecting element at position (|x|, |y|) in the specified page. |
56 virtual void InspectElement(int x, int y) = 0; | 64 virtual void InspectElement(int x, int y) = 0; |
57 | 65 |
58 // Returns the unique id of the agent. | 66 // Returns the unique id of the agent. |
59 virtual std::string GetId() = 0; | 67 virtual std::string GetId() = 0; |
60 | 68 |
61 // Returns web contents instance for this host if any. | 69 // Returns web contents instance for this host if any. |
62 virtual WebContents* GetWebContents() = 0; | 70 virtual WebContents* GetWebContents() = 0; |
63 | 71 |
64 // Temporarily detaches render view host from this host. Must be followed by | 72 // Temporarily detaches render view host from this host. Must be followed by |
65 // a call to ConnectWebContents (may leak the host instance otherwise). | 73 // a call to ConnectWebContents (may leak the host instance otherwise). |
66 virtual void DisconnectWebContents() = 0; | 74 virtual void DisconnectWebContents() = 0; |
67 | 75 |
68 // Attaches render view host to this host. | 76 // Attaches render view host to this host. |
69 virtual void ConnectWebContents(WebContents* web_contents) = 0; | 77 virtual void ConnectWebContents(WebContents* web_contents) = 0; |
70 | 78 |
71 // Returns true if DevToolsAgentHost is for worker. | 79 // Returns true if DevToolsAgentHost is for worker. |
72 virtual bool IsWorker() const = 0; | 80 virtual bool IsWorker() const = 0; |
73 | 81 |
82 // Returns agent host type. | |
83 virtual std::string GetType() = 0; | |
84 | |
85 // Returns agent host title. | |
86 virtual std::string GetTitle() = 0; | |
87 | |
88 // Returns url associated with agent host. | |
89 virtual GURL GetURL() = 0; | |
90 | |
91 // Activates agent host. Returns false if the operation failed. | |
92 virtual bool Activate() = 0; | |
93 | |
94 // Closes agent host. Returns false if the operation failed. | |
95 virtual bool Close() = 0; | |
96 | |
97 // Terminates all debugging sessions and detaches all clients. | |
98 static void DetachAllClients(); | |
yurys
2014/08/13 07:33:47
We shouldn't be detaching clients that we don't co
vkuzkokov
2014/08/13 08:21:06
It's part of an unsuccessful rebase. Removed.
| |
99 | |
100 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> | |
101 AgentStateCallback; | |
102 | |
103 static void AddAgentStateCallback(const AgentStateCallback& callback); | |
yurys
2014/08/13 07:33:47
I don't think it should be a part of this CL.
vkuzkokov
2014/08/13 08:21:06
Ditto.
| |
104 static void RemoveAgentStateCallback(const AgentStateCallback& callback); | |
105 | |
74 protected: | 106 protected: |
75 friend class base::RefCounted<DevToolsAgentHost>; | 107 friend class base::RefCounted<DevToolsAgentHost>; |
76 virtual ~DevToolsAgentHost() {} | 108 virtual ~DevToolsAgentHost() {} |
77 }; | 109 }; |
78 | 110 |
79 } // namespace content | 111 } // namespace content |
80 | 112 |
81 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 113 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |