Chromium Code Reviews| 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 <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 Loading... | |
| 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 target, 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 target description. | |
|
dgozman
2016/08/22 23:09:07
target -> agent host
| |
| 151 virtual std::string GetDescription() = 0; | |
| 152 | |
| 158 // Returns url associated with agent host. | 153 // Returns url associated with agent host. |
| 159 virtual GURL GetURL() = 0; | 154 virtual GURL GetURL() = 0; |
| 160 | 155 |
| 156 // Returns the favicon url for this target. | |
| 157 virtual GURL GetFaviconURL() = 0; | |
| 158 | |
| 161 // Activates agent host. Returns false if the operation failed. | 159 // Activates agent host. Returns false if the operation failed. |
| 162 virtual bool Activate() = 0; | 160 virtual bool Activate() = 0; |
| 163 | 161 |
| 162 // Opens devtools for this agent host. | |
| 163 virtual void Inspect() = 0; | |
| 164 | |
| 165 // Reloads the target. | |
| 166 virtual void Reload() = 0; | |
| 167 | |
| 164 // Closes agent host. Returns false if the operation failed. | 168 // Closes agent host. Returns false if the operation failed. |
| 165 virtual bool Close() = 0; | 169 virtual bool Close() = 0; |
| 166 | 170 |
| 171 // Returns the time when the target was last active. | |
| 172 virtual base::TimeTicks GetLastActivityTime() = 0; | |
| 173 | |
| 167 // Terminates all debugging sessions and detaches all clients. | 174 // Terminates all debugging sessions and detaches all clients. |
| 168 static void DetachAllClients(); | 175 static void DetachAllClients(); |
| 169 | 176 |
| 170 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> | 177 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> |
| 171 AgentStateCallback; | 178 AgentStateCallback; |
| 172 | 179 |
| 173 static void AddAgentStateCallback(const AgentStateCallback& callback); | 180 static void AddAgentStateCallback(const AgentStateCallback& callback); |
| 174 static void RemoveAgentStateCallback(const AgentStateCallback& callback); | 181 static void RemoveAgentStateCallback(const AgentStateCallback& callback); |
| 175 | 182 |
| 176 protected: | 183 protected: |
| 177 friend class base::RefCounted<DevToolsAgentHost>; | 184 friend class base::RefCounted<DevToolsAgentHost>; |
| 178 virtual ~DevToolsAgentHost() {} | 185 virtual ~DevToolsAgentHost() {} |
| 179 }; | 186 }; |
| 180 | 187 |
| 181 } // namespace content | 188 } // namespace content |
| 182 | 189 |
| 183 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 190 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
| OLD | NEW |