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