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