ServiceWorkerVersion: remove unused parameter in DispatchInstallEvent
[chromium-blink-merge.git] / content / public / browser / devtools_agent_host.h
blob5715fd88ca20a6787763f353e67b7cea455cbc56
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.
5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/devtools_agent_host_client.h"
16 #include "url/gurl.h"
18 namespace content {
20 class BrowserContext;
21 class DevToolsExternalAgentProxyDelegate;
22 class WebContents;
24 // Describes interface for managing devtools agents from browser process.
25 class CONTENT_EXPORT DevToolsAgentHost
26 : public base::RefCounted<DevToolsAgentHost> {
27 public:
28 enum Type {
29 // Agent host associated with WebContents.
30 TYPE_WEB_CONTENTS,
32 // Agent host associated with shared worker.
33 TYPE_SHARED_WORKER,
35 // Agent host associated with service worker.
36 TYPE_SERVICE_WORKER,
38 // Agent host associated with DevToolsExternalAgentProxyDelegate.
39 TYPE_EXTERNAL,
42 // Returns DevToolsAgentHost with a given |id| or nullptr of it doesn't exist.
43 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
45 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|.
46 // New DevToolsAgentHost will be created if it does not exist.
47 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(
48 WebContents* web_contents);
50 // Returns true iff an instance of DevToolsAgentHost for the |web_contents|
51 // does exist.
52 static bool HasFor(WebContents* web_contents);
54 // Returns DevToolsAgentHost that can be used for inspecting shared worker
55 // with given worker process host id and routing id.
56 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id,
57 int worker_route_id);
59 // Creates DevToolsAgentHost that communicates to the target by means of
60 // provided |delegate|. |delegate| ownership is passed to the created agent
61 // host.
62 static scoped_refptr<DevToolsAgentHost> Create(
63 DevToolsExternalAgentProxyDelegate* delegate);
65 static bool IsDebuggerAttached(WebContents* web_contents);
67 typedef std::vector<scoped_refptr<DevToolsAgentHost> > List;
69 // Returns all possible DevToolsAgentHosts.
70 static List GetOrCreateAll();
72 // Client attaches to this agent host to start debugging it.
73 virtual void AttachClient(DevToolsAgentHostClient* client) = 0;
75 // Already attached client detaches from this agent host to stop debugging it.
76 virtual void DetachClient() = 0;
78 // Returns true if there is a client attached.
79 virtual bool IsAttached() = 0;
81 // Sends a message to the agent.
82 virtual void DispatchProtocolMessage(const std::string& message) = 0;
84 // Starts inspecting element at position (|x|, |y|) in the specified page.
85 virtual void InspectElement(int x, int y) = 0;
87 // Returns the unique id of the agent.
88 virtual std::string GetId() = 0;
90 // Returns web contents instance for this host if any.
91 virtual WebContents* GetWebContents() = 0;
93 // Returns related browser context instance if available.
94 virtual BrowserContext* GetBrowserContext() = 0;
96 // Temporarily detaches render view host from this host. Must be followed by
97 // a call to ConnectWebContents (may leak the host instance otherwise).
98 virtual void DisconnectWebContents() = 0;
100 // Attaches render view host to this host.
101 virtual void ConnectWebContents(WebContents* web_contents) = 0;
103 // Returns true if DevToolsAgentHost is for worker.
104 virtual bool IsWorker() const = 0;
106 // Returns agent host type.
107 virtual Type GetType() = 0;
109 // Returns agent host title.
110 virtual std::string GetTitle() = 0;
112 // Returns url associated with agent host.
113 virtual GURL GetURL() = 0;
115 // Activates agent host. Returns false if the operation failed.
116 virtual bool Activate() = 0;
118 // Closes agent host. Returns false if the operation failed.
119 virtual bool Close() = 0;
121 // Terminates all debugging sessions and detaches all clients.
122 static void DetachAllClients();
124 typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
125 AgentStateCallback;
127 static void AddAgentStateCallback(const AgentStateCallback& callback);
128 static void RemoveAgentStateCallback(const AgentStateCallback& callback);
130 protected:
131 friend class base::RefCounted<DevToolsAgentHost>;
132 virtual ~DevToolsAgentHost() {}
135 } // namespace content
137 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_