- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / devtools / devtools_target_impl.h
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.
4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "content/public/browser/devtools_target.h"
12 #include "content/public/browser/worker_service.h"
13
14 class Profile;
15
16 namespace content {
17 class DevToolsAgentHost;
18 class RenderViewHost;
19 }
20
21 class DevToolsTargetImpl : public content::DevToolsTarget {
22  public:
23
24   DevToolsTargetImpl();
25   virtual ~DevToolsTargetImpl();
26
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
37     OVERRIDE;
38   virtual bool Activate() const OVERRIDE;
39   virtual bool Close() const OVERRIDE;
40
41   // Returns the RenderViewHost associated with the target on NULL if there is
42   // not any.
43   virtual content::RenderViewHost* GetRenderViewHost() const;
44
45   // Returns the tab id if the target is associated with a tab, -1 otherwise.
46   virtual int GetTabId() const;
47
48   // Returns the extension id if the target is associated with an extension
49   // background page.
50   virtual std::string GetExtensionId() const;
51
52   // Open a new DevTools window or activate the existing one.
53   virtual void Inspect(Profile* profile) const;
54
55   // Reload the target page.
56   virtual void Reload() const;
57
58   // Creates a new target associated with RenderViewHost.
59   static scoped_ptr<DevToolsTargetImpl> CreateForRenderViewHost(
60       content::RenderViewHost*, bool is_tab);
61
62   // Creates a new target associated with a shared worker.
63   static scoped_ptr<DevToolsTargetImpl> CreateForWorker(
64       const content::WorkerService::WorkerInfo&);
65
66   typedef std::vector<DevToolsTargetImpl*> List;
67   typedef base::Callback<void(const List&)> Callback;
68
69   static List EnumerateRenderViewHostTargets();
70   static void EnumerateWorkerTargets(Callback callback);
71   static void EnumerateAllTargets(Callback callback);
72
73  protected:
74   scoped_refptr<content::DevToolsAgentHost> agent_host_;
75   std::string id_;
76   std::string type_;
77   std::string title_;
78   std::string description_;
79   GURL url_;
80   GURL favicon_url_;
81   base::TimeTicks last_activity_time_;
82 };
83
84 #endif  // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_