Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_target_impl.h
blobd02be13dea49d89e1bff10e1b9c5b8a71e7aefa0
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_
8 #include <vector>
10 #include "base/callback.h"
11 #include "content/public/browser/devtools_target.h"
12 #include "content/public/browser/worker_service.h"
14 class Profile;
16 namespace content {
17 class DevToolsAgentHost;
18 class RenderViewHost;
21 class DevToolsTargetImpl : public content::DevToolsTarget {
22 public:
24 DevToolsTargetImpl();
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
37 OVERRIDE;
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
42 // not any.
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
49 // background page.
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);
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_;
84 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_