Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / devtools_agent_host.h
index be02843..cc5d69c 100644 (file)
@@ -9,8 +9,11 @@
 #include <vector>
 
 #include "base/basictypes.h"
+#include "base/callback.h"
 #include "base/memory/ref_counted.h"
 #include "content/common/content_export.h"
+#include "content/public/browser/devtools_agent_host_client.h"
+#include "url/gurl.h"
 
 namespace content {
 
@@ -21,6 +24,20 @@ class WebContents;
 class CONTENT_EXPORT DevToolsAgentHost
     : public base::RefCounted<DevToolsAgentHost> {
  public:
+  enum Type {
+    // Agent host associated with WebContents.
+    TYPE_WEB_CONTENTS,
+
+    // Agent host associated with shared worker.
+    TYPE_SHARED_WORKER,
+
+    // Agent host associated with service worker.
+    TYPE_SERVICE_WORKER,
+
+    // Agent host associated with DevToolsExternalAgentProxyDelegate.
+    TYPE_EXTERNAL,
+  };
+
   // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist.
   static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
 
@@ -46,12 +63,23 @@ class CONTENT_EXPORT DevToolsAgentHost
 
   static bool IsDebuggerAttached(WebContents* web_contents);
 
-  // Returns a list of all existing WebContents that can be debugged.
-  static std::vector<WebContents*> GetInspectableWebContents();
+  typedef std::vector<scoped_refptr<DevToolsAgentHost> > List;
+
+  // Returns all possible DevToolsAgentHosts.
+  static List GetOrCreateAll();
+
+  // Client attaches to this agent host to start debugging it.
+  virtual void AttachClient(DevToolsAgentHostClient* client) = 0;
+
+  // Already attached client detaches from this agent host to stop debugging it.
+  virtual void DetachClient() = 0;
 
   // Returns true if there is a client attached.
   virtual bool IsAttached() = 0;
 
+  // Sends a message to the agent.
+  virtual void DispatchProtocolMessage(const std::string& message) = 0;
+
   // Starts inspecting element at position (|x|, |y|) in the specified page.
   virtual void InspectElement(int x, int y) = 0;
 
@@ -71,6 +99,30 @@ class CONTENT_EXPORT DevToolsAgentHost
   // Returns true if DevToolsAgentHost is for worker.
   virtual bool IsWorker() const = 0;
 
+  // Returns agent host type.
+  virtual Type GetType() = 0;
+
+  // Returns agent host title.
+  virtual std::string GetTitle() = 0;
+
+  // Returns url associated with agent host.
+  virtual GURL GetURL() = 0;
+
+  // Activates agent host. Returns false if the operation failed.
+  virtual bool Activate() = 0;
+
+  // Closes agent host. Returns false if the operation failed.
+  virtual bool Close() = 0;
+
+  // Terminates all debugging sessions and detaches all clients.
+  static void DetachAllClients();
+
+  typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
+      AgentStateCallback;
+
+  static void AddAgentStateCallback(const AgentStateCallback& callback);
+  static void RemoveAgentStateCallback(const AgentStateCallback& callback);
+
  protected:
   friend class base::RefCounted<DevToolsAgentHost>;
   virtual ~DevToolsAgentHost() {}