| 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 |
| 20 // Describes interface for managing devtools agents from the browser process. | 22 // Describes interface for managing devtools agents from the browser process. |
| 21 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { | 23 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { |
| 22 public: | 24 public: |
| 23 class CONTENT_EXPORT CloseListener { | |
| 24 public: | |
| 25 virtual void AgentHostClosing(DevToolsAgentHostImpl*) = 0; | |
| 26 protected: | |
| 27 virtual ~CloseListener() {} | |
| 28 }; | |
| 29 | |
| 30 // Informs the hosted agent that a client host has attached. | 25 // Informs the hosted agent that a client host has attached. |
| 31 virtual void Attach() = 0; | 26 virtual void Attach() = 0; |
| 32 | 27 |
| 33 // Informs the hosted agent that a client host has detached. | 28 // Informs the hosted agent that a client host has detached. |
| 34 virtual void Detach() = 0; | 29 virtual void Detach() = 0; |
| 35 | 30 |
| 36 // Sends a message to the agent hosted by this object. | 31 // Opens the inspector for this host. |
| 37 virtual void DispatchOnInspectorBackend(const std::string& message) = 0; | 32 void Inspect(BrowserContext* browser_context); |
| 38 | |
| 39 void set_close_listener(CloseListener* listener) { | |
| 40 close_listener_ = listener; | |
| 41 } | |
| 42 | 33 |
| 43 // DevToolsAgentHost implementation. | 34 // DevToolsAgentHost implementation. |
| 35 virtual void AttachClient(Client* client) OVERRIDE; |
| 36 virtual void DetachClient() OVERRIDE; |
| 44 virtual bool IsAttached() OVERRIDE; | 37 virtual bool IsAttached() OVERRIDE; |
| 45 | |
| 46 virtual void InspectElement(int x, int y) OVERRIDE; | 38 virtual void InspectElement(int x, int y) OVERRIDE; |
| 47 | |
| 48 virtual std::string GetId() OVERRIDE; | 39 virtual std::string GetId() OVERRIDE; |
| 49 | |
| 50 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; | 40 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; |
| 51 | |
| 52 virtual void DisconnectRenderViewHost() OVERRIDE; | 41 virtual void DisconnectRenderViewHost() OVERRIDE; |
| 53 | |
| 54 virtual void ConnectRenderViewHost(RenderViewHost* rvh) OVERRIDE; | 42 virtual void ConnectRenderViewHost(RenderViewHost* rvh) OVERRIDE; |
| 55 | |
| 56 virtual bool IsWorker() const OVERRIDE; | 43 virtual bool IsWorker() const OVERRIDE; |
| 57 | 44 |
| 58 protected: | 45 protected: |
| 59 DevToolsAgentHostImpl(); | 46 DevToolsAgentHostImpl(); |
| 60 virtual ~DevToolsAgentHostImpl(); | 47 virtual ~DevToolsAgentHostImpl(); |
| 61 | 48 |
| 62 void NotifyCloseListener(); | 49 void HostClosed(); |
| 50 void SendMessageToClient(const std::string& message); |
| 63 | 51 |
| 64 private: | 52 private: |
| 65 CloseListener* close_listener_; | 53 friend class DevToolsAgentHost; // for static methods |
| 54 void DetachInternal(DetachReason reason, bool need_detach); |
| 55 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); |
| 56 |
| 66 const std::string id_; | 57 const std::string id_; |
| 58 Client* client_; |
| 67 }; | 59 }; |
| 68 | 60 |
| 69 } // namespace content | 61 } // namespace content |
| 70 | 62 |
| 71 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 63 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
| OLD | NEW |