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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h"
20 // Describes interface for managing devtools agents from browser process.
21 class CONTENT_EXPORT DevToolsAgentHost
22 : public base::RefCounted
<DevToolsAgentHost
> {
24 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist.
25 static scoped_refptr
<DevToolsAgentHost
> GetForId(const std::string
& id
);
27 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|.
28 // New DevToolsAgentHost will be created if it does not exist.
29 static scoped_refptr
<DevToolsAgentHost
> GetOrCreateFor(
30 WebContents
* web_contents
);
32 // Returns DevToolsAgentHost that can be used for inspecting |rvh|.
33 // New DevToolsAgentHost will be created if it does not exist.
34 static scoped_refptr
<DevToolsAgentHost
> GetOrCreateFor(RenderViewHost
* rvh
);
36 // Returns true iff an instance of DevToolsAgentHost for the |rvh|
38 static bool HasFor(RenderViewHost
* rvh
);
40 // Returns DevToolsAgentHost that can be used for inspecting shared worker
41 // with given worker process host id and routing id.
42 static scoped_refptr
<DevToolsAgentHost
> GetForWorker(int worker_process_id
,
45 static bool IsDebuggerAttached(WebContents
* web_contents
);
47 // Returns a list of all existing RenderViewHost's that can be debugged.
48 static std::vector
<RenderViewHost
*> GetValidRenderViewHosts();
50 // Returns true if there is a client attached.
51 virtual bool IsAttached() = 0;
53 // Starts inspecting element at position (|x|, |y|) in the specified page.
54 virtual void InspectElement(int x
, int y
) = 0;
56 // Returns the unique id of the agent.
57 virtual std::string
GetId() = 0;
59 // Returns render view host instance for this host if any.
60 virtual RenderViewHost
* GetRenderViewHost() = 0;
62 // Temporarily detaches render view host from this host. Must be followed by
63 // a call to ConnectRenderViewHost (may leak the host instance otherwise).
64 virtual void DisconnectRenderViewHost() = 0;
66 // Attaches render view host to this host.
67 virtual void ConnectRenderViewHost(RenderViewHost
* rvh
) = 0;
70 friend class base::RefCounted
<DevToolsAgentHost
>;
71 virtual ~DevToolsAgentHost() {}
74 } // namespace content
76 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_