| 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/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class DevToolsExternalAgentProxyDelegate; | 17 class DevToolsExternalAgentProxyDelegate; |
| 18 class RenderViewHost; | |
| 19 class WebContents; | 18 class WebContents; |
| 20 | 19 |
| 21 // Describes interface for managing devtools agents from browser process. | 20 // Describes interface for managing devtools agents from browser process. |
| 22 class CONTENT_EXPORT DevToolsAgentHost | 21 class CONTENT_EXPORT DevToolsAgentHost |
| 23 : public base::RefCounted<DevToolsAgentHost> { | 22 : public base::RefCounted<DevToolsAgentHost> { |
| 24 public: | 23 public: |
| 25 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. | 24 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. |
| 26 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); | 25 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); |
| 27 | 26 |
| 28 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. | 27 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. |
| 29 // New DevToolsAgentHost will be created if it does not exist. | 28 // New DevToolsAgentHost will be created if it does not exist. |
| 30 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( | 29 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( |
| 31 WebContents* web_contents); | 30 WebContents* web_contents); |
| 32 | 31 |
| 33 // Returns DevToolsAgentHost that can be used for inspecting |rvh|. | 32 // Returns true iff an instance of DevToolsAgentHost for the |web_contents| |
| 34 // New DevToolsAgentHost will be created if it does not exist. | |
| 35 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(RenderViewHost* rvh); | |
| 36 | |
| 37 // Returns true iff an instance of DevToolsAgentHost for the |rvh| | |
| 38 // does exist. | 33 // does exist. |
| 39 static bool HasFor(RenderViewHost* rvh); | 34 static bool HasFor(WebContents* web_contents); |
| 40 | 35 |
| 41 // Returns DevToolsAgentHost that can be used for inspecting shared worker | 36 // Returns DevToolsAgentHost that can be used for inspecting shared worker |
| 42 // with given worker process host id and routing id. | 37 // with given worker process host id and routing id. |
| 43 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, | 38 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, |
| 44 int worker_route_id); | 39 int worker_route_id); |
| 45 | 40 |
| 46 // Creates DevToolsAgentHost that communicates to the target by means of | 41 // Creates DevToolsAgentHost that communicates to the target by means of |
| 47 // provided |delegate|. |delegate| ownership is passed to the created agent | 42 // provided |delegate|. |delegate| ownership is passed to the created agent |
| 48 // host. | 43 // host. |
| 49 static scoped_refptr<DevToolsAgentHost> Create( | 44 static scoped_refptr<DevToolsAgentHost> Create( |
| 50 DevToolsExternalAgentProxyDelegate* delegate); | 45 DevToolsExternalAgentProxyDelegate* delegate); |
| 51 | 46 |
| 52 static bool IsDebuggerAttached(WebContents* web_contents); | 47 static bool IsDebuggerAttached(WebContents* web_contents); |
| 53 | 48 |
| 54 // Returns a list of all existing RenderViewHost's that can be debugged. | 49 // Returns a list of all existing WebContents that can be debugged. |
| 55 static std::vector<RenderViewHost*> GetValidRenderViewHosts(); | 50 static std::vector<WebContents*> GetInspectableWebContents(); |
| 56 | 51 |
| 57 // Returns true if there is a client attached. | 52 // Returns true if there is a client attached. |
| 58 virtual bool IsAttached() = 0; | 53 virtual bool IsAttached() = 0; |
| 59 | 54 |
| 60 // Starts inspecting element at position (|x|, |y|) in the specified page. | 55 // Starts inspecting element at position (|x|, |y|) in the specified page. |
| 61 virtual void InspectElement(int x, int y) = 0; | 56 virtual void InspectElement(int x, int y) = 0; |
| 62 | 57 |
| 63 // Returns the unique id of the agent. | 58 // Returns the unique id of the agent. |
| 64 virtual std::string GetId() = 0; | 59 virtual std::string GetId() = 0; |
| 65 | 60 |
| 66 // Returns render view host instance for this host if any. | 61 // Returns web contents instance for this host if any. |
| 67 virtual RenderViewHost* GetRenderViewHost() = 0; | 62 virtual WebContents* GetWebContents() = 0; |
| 68 | 63 |
| 69 // Temporarily detaches render view host from this host. Must be followed by | 64 // Temporarily detaches render view host from this host. Must be followed by |
| 70 // a call to ConnectRenderViewHost (may leak the host instance otherwise). | 65 // a call to ConnectWebContents (may leak the host instance otherwise). |
| 71 virtual void DisconnectRenderViewHost() = 0; | 66 virtual void DisconnectWebContents() = 0; |
| 72 | 67 |
| 73 // Attaches render view host to this host. | 68 // Attaches render view host to this host. |
| 74 virtual void ConnectRenderViewHost(RenderViewHost* rvh) = 0; | 69 virtual void ConnectWebContents(WebContents* web_contents) = 0; |
| 75 | 70 |
| 76 // Returns true if DevToolsAgentHost is for worker. | 71 // Returns true if DevToolsAgentHost is for worker. |
| 77 virtual bool IsWorker() const = 0; | 72 virtual bool IsWorker() const = 0; |
| 78 | 73 |
| 79 protected: | 74 protected: |
| 80 friend class base::RefCounted<DevToolsAgentHost>; | 75 friend class base::RefCounted<DevToolsAgentHost>; |
| 81 virtual ~DevToolsAgentHost() {} | 76 virtual ~DevToolsAgentHost() {} |
| 82 }; | 77 }; |
| 83 | 78 |
| 84 } // namespace content | 79 } // namespace content |
| 85 | 80 |
| 86 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 81 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
| OLD | NEW |