Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: content/public/browser/devtools_agent_host.h

Issue 2263843002: DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 3 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/time/time.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/public/browser/devtools_agent_host_client.h" 16 #include "content/public/browser/devtools_agent_host_client.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace base { 19 namespace base {
19 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
20 } 21 }
21 22
22 namespace net { 23 namespace net {
23 class ServerSocket; 24 class ServerSocket;
24 } 25 }
25 26
26 namespace content { 27 namespace content {
27 28
28 class BrowserContext; 29 class BrowserContext;
29 class DevToolsExternalAgentProxyDelegate; 30 class DevToolsExternalAgentProxyDelegate;
30 class RenderFrameHost; 31 class RenderFrameHost;
31 class WebContents; 32 class WebContents;
32 33
33 // Describes interface for managing devtools agents from browser process. 34 // Describes interface for managing devtools agents from browser process.
34 class CONTENT_EXPORT DevToolsAgentHost 35 class CONTENT_EXPORT DevToolsAgentHost
35 : public base::RefCounted<DevToolsAgentHost> { 36 : public base::RefCounted<DevToolsAgentHost> {
36 public: 37 public:
37 enum Type { 38 static char kTypePage[];
38 // Agent host associated with WebContents. 39 static char kTypeFrame[];
39 TYPE_WEB_CONTENTS, 40 static char kTypeSharedWorker[];
40 41 static char kTypeServiceWorker[];
41 // Agent host associated with RenderFrameHost. 42 static char kTypeExternal[];
42 TYPE_FRAME, 43 static char kTypeBrowser[];
43 44 static char kTypeOther[];
44 // Agent host associated with shared worker.
45 TYPE_SHARED_WORKER,
46
47 // Agent host associated with service worker.
48 TYPE_SERVICE_WORKER,
49
50 // Agent host associated with DevToolsExternalAgentProxyDelegate.
51 TYPE_EXTERNAL,
52
53 // Agent host associated with browser.
54 TYPE_BROWSER,
55 };
56 45
57 // Latest DevTools protocol version supported. 46 // Latest DevTools protocol version supported.
58 static std::string GetProtocolVersion(); 47 static std::string GetProtocolVersion();
59 48
60 // Returns whether particular version of DevTools protocol is supported. 49 // Returns whether particular version of DevTools protocol is supported.
61 static bool IsSupportedProtocolVersion(const std::string& version); 50 static bool IsSupportedProtocolVersion(const std::string& version);
62 51
63 // Returns DevToolsAgentHost with a given |id| or nullptr of it doesn't exist. 52 // Returns DevToolsAgentHost with a given |id| or nullptr of it doesn't exist.
64 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); 53 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
65 54
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const std::string& message) = 0; 118 const std::string& message) = 0;
130 119
131 // Starts inspecting element at position (|x|, |y|). 120 // Starts inspecting element at position (|x|, |y|).
132 virtual void InspectElement(DevToolsAgentHostClient* client, 121 virtual void InspectElement(DevToolsAgentHostClient* client,
133 int x, 122 int x,
134 int y) = 0; 123 int y) = 0;
135 124
136 // Returns the unique id of the agent. 125 // Returns the unique id of the agent.
137 virtual std::string GetId() = 0; 126 virtual std::string GetId() = 0;
138 127
128 // Returns the id of the parent host, or empty string if no parent.
129 virtual std::string GetParentId() = 0;
130
139 // Returns web contents instance for this host if any. 131 // Returns web contents instance for this host if any.
140 virtual WebContents* GetWebContents() = 0; 132 virtual WebContents* GetWebContents() = 0;
141 133
142 // Returns related browser context instance if available. 134 // Returns related browser context instance if available.
143 virtual BrowserContext* GetBrowserContext() = 0; 135 virtual BrowserContext* GetBrowserContext() = 0;
144 136
145 // Temporarily detaches WebContents from this host. Must be followed by 137 // Temporarily detaches WebContents from this host. Must be followed by
146 // a call to ConnectWebContents (may leak the host instance otherwise). 138 // a call to ConnectWebContents (may leak the host instance otherwise).
147 virtual void DisconnectWebContents() = 0; 139 virtual void DisconnectWebContents() = 0;
148 140
149 // Attaches render view host to this host. 141 // Attaches render view host to this host.
150 virtual void ConnectWebContents(WebContents* web_contents) = 0; 142 virtual void ConnectWebContents(WebContents* web_contents) = 0;
151 143
152 // Returns agent host type. 144 // Returns agent host type.
153 virtual Type GetType() = 0; 145 virtual std::string GetType() = 0;
154 146
155 // Returns agent host title. 147 // Returns agent host title.
156 virtual std::string GetTitle() = 0; 148 virtual std::string GetTitle() = 0;
157 149
150 // Returns the host description.
151 virtual std::string GetDescription() = 0;
152
153 // Override host description.
154 virtual void SetDescriptionOverride(const std::string& description) = 0;
155
158 // Returns url associated with agent host. 156 // Returns url associated with agent host.
159 virtual GURL GetURL() = 0; 157 virtual GURL GetURL() = 0;
160 158
159 // Returns the favicon url for this host.
160 virtual GURL GetFaviconURL() = 0;
161
161 // Activates agent host. Returns false if the operation failed. 162 // Activates agent host. Returns false if the operation failed.
162 virtual bool Activate() = 0; 163 virtual bool Activate() = 0;
163 164
165 // Opens devtools for this agent host. Returns false if the operation failed.
166 virtual bool Inspect() = 0;
167
168 // Reloads the host.
169 virtual void Reload() = 0;
170
164 // Closes agent host. Returns false if the operation failed. 171 // Closes agent host. Returns false if the operation failed.
165 virtual bool Close() = 0; 172 virtual bool Close() = 0;
166 173
174 // Returns the time when the host was last active.
175 virtual base::TimeTicks GetLastActivityTime() = 0;
176
167 // Terminates all debugging sessions and detaches all clients. 177 // Terminates all debugging sessions and detaches all clients.
168 static void DetachAllClients(); 178 static void DetachAllClients();
169 179
170 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> 180 typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
171 AgentStateCallback; 181 AgentStateCallback;
172 182
173 static void AddAgentStateCallback(const AgentStateCallback& callback); 183 static void AddAgentStateCallback(const AgentStateCallback& callback);
174 static void RemoveAgentStateCallback(const AgentStateCallback& callback); 184 static void RemoveAgentStateCallback(const AgentStateCallback& callback);
175 185
176 protected: 186 protected:
177 friend class base::RefCounted<DevToolsAgentHost>; 187 friend class base::RefCounted<DevToolsAgentHost>;
178 virtual ~DevToolsAgentHost() {} 188 virtual ~DevToolsAgentHost() {}
179 }; 189 };
180 190
181 } // namespace content 191 } // namespace content
182 192
183 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 193 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698