| 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/common/devtools_messages.h" |
| 12 #include "content/public/browser/devtools_agent_host.h" | 13 #include "content/public/browser/devtools_agent_host.h" |
| 13 | 14 |
| 14 namespace IPC { | 15 namespace IPC { |
| 15 class Message; | 16 class Message; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 class BrowserContext; | 21 class BrowserContext; |
| 21 class DevToolsProtocolHandler; | 22 class DevToolsProtocolHandler; |
| 22 | 23 |
| 23 // Describes interface for managing devtools agents from the browser process. | 24 // Describes interface for managing devtools agents from the browser process. |
| 24 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { | 25 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { |
| 25 public: | 26 public: |
| 26 // Informs the hosted agent that a client host has attached. | 27 // Informs the hosted agent that a client host has attached. |
| 27 virtual void Attach() = 0; | 28 virtual void Attach() = 0; |
| 28 | 29 |
| 29 // Informs the hosted agent that a client host has detached. | 30 // Informs the hosted agent that a client host has detached. |
| 30 virtual void Detach() = 0; | 31 virtual void Detach() = 0; |
| 31 | 32 |
| 32 // Sends a message to the agent. | |
| 33 bool DispatchProtocolMessage(const std::string& message) override; | |
| 34 | |
| 35 // Opens the inspector for this host. | 33 // Opens the inspector for this host. |
| 36 void Inspect(BrowserContext* browser_context); | 34 void Inspect(BrowserContext* browser_context); |
| 37 | 35 |
| 38 // DevToolsAgentHost implementation. | 36 // DevToolsAgentHost implementation. |
| 39 void AttachClient(DevToolsAgentHostClient* client) override; | 37 void AttachClient(DevToolsAgentHostClient* client) override; |
| 40 void DetachClient() override; | 38 void DetachClient() override; |
| 41 bool IsAttached() override; | 39 bool IsAttached() override; |
| 42 void InspectElement(int x, int y) override; | 40 void InspectElement(int x, int y) override; |
| 43 std::string GetId() override; | 41 std::string GetId() override; |
| 44 BrowserContext* GetBrowserContext() override; | 42 BrowserContext* GetBrowserContext() override; |
| 45 WebContents* GetWebContents() override; | 43 WebContents* GetWebContents() override; |
| 46 void DisconnectWebContents() override; | 44 void DisconnectWebContents() override; |
| 47 void ConnectWebContents(WebContents* wc) override; | 45 void ConnectWebContents(WebContents* wc) override; |
| 46 bool DispatchProtocolMessage(const std::string& message) override; |
| 48 | 47 |
| 49 protected: | 48 protected: |
| 50 DevToolsAgentHostImpl(); | 49 DevToolsAgentHostImpl(); |
| 51 ~DevToolsAgentHostImpl() override; | 50 ~DevToolsAgentHostImpl() override; |
| 52 | 51 |
| 53 scoped_ptr<DevToolsProtocolHandler> protocol_handler_; | 52 scoped_ptr<DevToolsProtocolHandler> protocol_handler_; |
| 53 std::string state_cookie_; |
| 54 | 54 |
| 55 void set_handle_all_protocol_commands() { handle_all_commands_ = true; } | 55 void set_handle_all_protocol_commands() { handle_all_commands_ = true; } |
| 56 void HostClosed(); | 56 void HostClosed(); |
| 57 void SendMessageToClient(const std::string& message); | 57 void SendMessageToClient(const std::string& message); |
| 58 void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); |
| 58 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); | 59 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 friend class DevToolsAgentHost; // for static methods | 62 friend class DevToolsAgentHost; // for static methods |
| 62 | 63 |
| 63 const std::string id_; | 64 const std::string id_; |
| 64 DevToolsAgentHostClient* client_; | 65 DevToolsAgentHostClient* client_; |
| 65 bool handle_all_commands_; | 66 bool handle_all_commands_; |
| 67 std::string message_buffer_; |
| 68 uint32 message_buffer_size_; |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 } // namespace content | 71 } // namespace content |
| 69 | 72 |
| 70 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 73 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
| OLD | NEW |