1 // Copyright 2013 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
10 #include "base/callback.h"
11 #include "content/public/browser/devtools_target.h"
12 #include "content/public/browser/worker_service.h"
17 class DevToolsAgentHost;
21 class DevToolsTargetImpl : public content::DevToolsTarget {
25 virtual ~DevToolsTargetImpl();
27 // content::DevToolsTarget overrides:
28 virtual std::string GetId() const OVERRIDE;
29 virtual std::string GetType() const OVERRIDE;
30 virtual std::string GetTitle() const OVERRIDE;
31 virtual std::string GetDescription() const OVERRIDE;
32 virtual GURL GetUrl() const OVERRIDE;
33 virtual GURL GetFaviconUrl() const OVERRIDE;
34 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE;
35 virtual bool IsAttached() const OVERRIDE;
36 virtual scoped_refptr<content::DevToolsAgentHost> GetAgentHost() const
38 virtual bool Activate() const OVERRIDE;
39 virtual bool Close() const OVERRIDE;
41 // Returns the RenderViewHost associated with the target on NULL if there is
43 virtual content::RenderViewHost* GetRenderViewHost() const;
45 // Returns the tab id if the target is associated with a tab, -1 otherwise.
46 virtual int GetTabId() const;
48 // Returns the extension id if the target is associated with an extension
50 virtual std::string GetExtensionId() const;
52 // Open a new DevTools window or activate the existing one.
53 virtual void Inspect(Profile* profile) const;
55 // Reload the target page.
56 virtual void Reload() const;
58 // Creates a new target associated with RenderViewHost.
59 static scoped_ptr<DevToolsTargetImpl> CreateForRenderViewHost(
60 content::RenderViewHost*, bool is_tab);
62 // Creates a new target associated with a shared worker.
63 static scoped_ptr<DevToolsTargetImpl> CreateForWorker(
64 const content::WorkerService::WorkerInfo&);
66 typedef std::vector<DevToolsTargetImpl*> List;
67 typedef base::Callback<void(const List&)> Callback;
69 static List EnumerateRenderViewHostTargets();
70 static void EnumerateWorkerTargets(Callback callback);
71 static void EnumerateAllTargets(Callback callback);
74 scoped_refptr<content::DevToolsAgentHost> agent_host_;
78 std::string description_;
81 base::TimeTicks last_activity_time_;
84 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_