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_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/browser/devtools_agent_host.h" | 12 #include "content/public/browser/devtools_agent_host.h" |
13 | 13 |
14 namespace IPC { | 14 namespace IPC { |
15 class Message; | 15 class Message; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class BrowserContext; | |
21 | |
22 // Describes interface for managing devtools agents from the browser process. | 20 // Describes interface for managing devtools agents from the browser process. |
23 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { | 21 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { |
24 public: | 22 public: |
| 23 class CONTENT_EXPORT CloseListener { |
| 24 public: |
| 25 virtual void AgentHostClosing(DevToolsAgentHostImpl*) = 0; |
| 26 protected: |
| 27 virtual ~CloseListener() {} |
| 28 }; |
| 29 |
25 // Informs the hosted agent that a client host has attached. | 30 // Informs the hosted agent that a client host has attached. |
26 virtual void Attach() = 0; | 31 virtual void Attach() = 0; |
27 | 32 |
28 // Informs the hosted agent that a client host has detached. | 33 // Informs the hosted agent that a client host has detached. |
29 virtual void Detach() = 0; | 34 virtual void Detach() = 0; |
30 | 35 |
31 // Sends a message to the agent. | 36 // Sends a message to the agent hosted by this object. |
32 virtual void DispatchProtocolMessage(const std::string& message) = 0; | 37 virtual void DispatchOnInspectorBackend(const std::string& message) = 0; |
33 | 38 |
34 // Opens the inspector for this host. | 39 void set_close_listener(CloseListener* listener) { |
35 void Inspect(BrowserContext* browser_context); | 40 close_listener_ = listener; |
| 41 } |
36 | 42 |
37 // DevToolsAgentHost implementation. | 43 // DevToolsAgentHost implementation. |
38 virtual void AttachClient(DevToolsAgentHostClient* client) OVERRIDE; | |
39 virtual void DetachClient() OVERRIDE; | |
40 virtual bool IsAttached() OVERRIDE; | 44 virtual bool IsAttached() OVERRIDE; |
| 45 |
41 virtual void InspectElement(int x, int y) OVERRIDE; | 46 virtual void InspectElement(int x, int y) OVERRIDE; |
| 47 |
42 virtual std::string GetId() OVERRIDE; | 48 virtual std::string GetId() OVERRIDE; |
| 49 |
43 virtual WebContents* GetWebContents() OVERRIDE; | 50 virtual WebContents* GetWebContents() OVERRIDE; |
| 51 |
44 virtual void DisconnectWebContents() OVERRIDE; | 52 virtual void DisconnectWebContents() OVERRIDE; |
45 virtual void ConnectWebContents(WebContents* wc) OVERRIDE; | 53 |
| 54 virtual void ConnectWebContents(WebContents* rvh) OVERRIDE; |
| 55 |
46 virtual bool IsWorker() const OVERRIDE; | 56 virtual bool IsWorker() const OVERRIDE; |
47 | 57 |
48 protected: | 58 protected: |
49 DevToolsAgentHostImpl(); | 59 DevToolsAgentHostImpl(); |
50 virtual ~DevToolsAgentHostImpl(); | 60 virtual ~DevToolsAgentHostImpl(); |
51 | 61 |
52 void HostClosed(); | 62 void NotifyCloseListener(); |
53 void SendMessageToClient(const std::string& message); | |
54 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); | |
55 | 63 |
56 private: | 64 private: |
57 friend class DevToolsAgentHost; // for static methods | 65 CloseListener* close_listener_; |
58 | |
59 const std::string id_; | 66 const std::string id_; |
60 DevToolsAgentHostClient* client_; | |
61 }; | 67 }; |
62 | 68 |
63 } // namespace content | 69 } // namespace content |
64 | 70 |
65 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 71 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
OLD | NEW |