devtools_agent_host.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string> 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector> 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/ref_counted.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/common/content_export.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content { 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class RenderViewHost; 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebContents; 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Describes interface for managing devtools agents from browser process. 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class CONTENT_EXPORT DevToolsAgentHost 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) : public base::RefCounted<DevToolsAgentHost> { 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns DevToolsAgentHost that can be used for inspecting |rvh|. 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // New DevToolsAgentHost will be created if it does not exist. 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(RenderViewHost* rvh); 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns true iff an instance of DevToolsAgentHost for the |rvh| 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // does exist. 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static bool HasFor(RenderViewHost* rvh); 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns DevToolsAgentHost that can be used for inspecting shared worker 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // with given worker process host id and routing id. 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int worker_route_id); 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static bool IsDebuggerAttached(WebContents* web_contents); 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Detaches given |rvh| from the agent host temporarily and returns the agent 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // host id that allows to reattach another rvh to that agent host later. 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns empty string if there is no agent host associated with the |rvh|. 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static std::string DisconnectRenderViewHost(RenderViewHost* rvh); 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reattaches agent host detached with DisconnectRenderViewHost method above 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // to |rvh|. 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static void ConnectRenderViewHost(const std::string& agent_host_cookie, 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RenderViewHost* rvh); 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns a list of all existing RenderViewHost's that can be debugged. 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static std::vector<RenderViewHost*> GetValidRenderViewHosts(); 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Starts inspecting element at position (|x|, |y|) in the specified page. 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InspectElement(int x, int y) = 0; 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns the unique id of the agent. 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual std::string GetId() = 0; 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns render view host instance for this host if any. 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual RenderViewHost* GetRenderViewHost() = 0; 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected: 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) friend class base::RefCounted<DevToolsAgentHost>; 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~DevToolsAgentHost() {} 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace content 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 72