Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/devtools/devtools_target_impl.h

Issue 442303002: DevTools: migrate DevTools APIs to use WebContents instead of RenderViewHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "content/public/browser/devtools_target.h" 11 #include "content/public/browser/devtools_target.h"
12 #include "content/public/browser/worker_service.h" 12 #include "content/public/browser/worker_service.h"
13 13
14 class Profile; 14 class Profile;
15 15
16 namespace content { 16 namespace content {
17 class DevToolsAgentHost; 17 class DevToolsAgentHost;
18 class RenderViewHost; 18 class RenderViewHost;
19 class WebContents;
19 } 20 }
20 21
21 class DevToolsTargetImpl : public content::DevToolsTarget { 22 class DevToolsTargetImpl : public content::DevToolsTarget {
22 public: 23 public:
23 explicit DevToolsTargetImpl( 24 explicit DevToolsTargetImpl(
24 scoped_refptr<content::DevToolsAgentHost> agent_host); 25 scoped_refptr<content::DevToolsAgentHost> agent_host);
25 virtual ~DevToolsTargetImpl(); 26 virtual ~DevToolsTargetImpl();
26 27
27 // content::DevToolsTarget overrides: 28 // content::DevToolsTarget overrides:
28 virtual std::string GetId() const OVERRIDE; 29 virtual std::string GetId() const OVERRIDE;
29 virtual std::string GetParentId() const OVERRIDE; 30 virtual std::string GetParentId() const OVERRIDE;
30 virtual std::string GetType() const OVERRIDE; 31 virtual std::string GetType() const OVERRIDE;
31 virtual std::string GetTitle() const OVERRIDE; 32 virtual std::string GetTitle() const OVERRIDE;
32 virtual std::string GetDescription() const OVERRIDE; 33 virtual std::string GetDescription() const OVERRIDE;
33 virtual GURL GetURL() const OVERRIDE; 34 virtual GURL GetURL() const OVERRIDE;
34 virtual GURL GetFaviconURL() const OVERRIDE; 35 virtual GURL GetFaviconURL() const OVERRIDE;
35 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE; 36 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE;
36 virtual scoped_refptr<content::DevToolsAgentHost> 37 virtual scoped_refptr<content::DevToolsAgentHost>
37 GetAgentHost() const OVERRIDE; 38 GetAgentHost() const OVERRIDE;
38 virtual bool IsAttached() const OVERRIDE; 39 virtual bool IsAttached() const OVERRIDE;
39 virtual bool Activate() const OVERRIDE; 40 virtual bool Activate() const OVERRIDE;
40 virtual bool Close() const OVERRIDE; 41 virtual bool Close() const OVERRIDE;
41 42
42 // Returns the RenderViewHost associated with the target on NULL if there is 43 // Returns the WebContents associated with the target on NULL if there is
43 // not any. 44 // not any.
44 virtual content::RenderViewHost* GetRenderViewHost() const; 45 virtual content::WebContents* GetWebContents() const;
45 46
46 // Returns the tab id if the target is associated with a tab, -1 otherwise. 47 // Returns the tab id if the target is associated with a tab, -1 otherwise.
47 virtual int GetTabId() const; 48 virtual int GetTabId() const;
48 49
49 // Returns the extension id if the target is associated with an extension 50 // Returns the extension id if the target is associated with an extension
50 // background page. 51 // background page.
51 virtual std::string GetExtensionId() const; 52 virtual std::string GetExtensionId() const;
52 53
53 // Open a new DevTools window or activate the existing one. 54 // Open a new DevTools window or activate the existing one.
54 virtual void Inspect(Profile* profile) const; 55 virtual void Inspect(Profile* profile) const;
55 56
56 // Reload the target page. 57 // Reload the target page.
57 virtual void Reload() const; 58 virtual void Reload() const;
58 59
59 // Creates a new target associated with RenderViewHost. 60 // Creates a new target associated with WebContents.
60 static scoped_ptr<DevToolsTargetImpl> CreateForRenderViewHost( 61 static scoped_ptr<DevToolsTargetImpl> CreateForWebContents(
61 content::RenderViewHost*, bool is_tab); 62 content::WebContents* web_contents,
63 bool is_tab);
62 64
63 void set_parent_id(const std::string& parent_id) { parent_id_ = parent_id; } 65 void set_parent_id(const std::string& parent_id) { parent_id_ = parent_id; }
64 void set_type(const std::string& type) { type_ = type; } 66 void set_type(const std::string& type) { type_ = type; }
65 void set_title(const std::string& title) { title_ = title; } 67 void set_title(const std::string& title) { title_ = title; }
66 void set_description(const std::string& desc) { description_ = desc; } 68 void set_description(const std::string& desc) { description_ = desc; }
67 void set_url(const GURL& url) { url_ = url; } 69 void set_url(const GURL& url) { url_ = url; }
68 void set_favicon_url(const GURL& url) { favicon_url_ = url; } 70 void set_favicon_url(const GURL& url) { favicon_url_ = url; }
69 void set_last_activity_time(const base::TimeTicks& time) { 71 void set_last_activity_time(const base::TimeTicks& time) {
70 last_activity_time_ = time; 72 last_activity_time_ = time;
71 } 73 }
72 74
73 typedef std::vector<DevToolsTargetImpl*> List; 75 typedef std::vector<DevToolsTargetImpl*> List;
74 typedef base::Callback<void(const List&)> Callback; 76 typedef base::Callback<void(const List&)> Callback;
75 77
76 static List EnumerateRenderViewHostTargets(); 78 static List EnumerateWebContentsTargets();
77 static void EnumerateWorkerTargets(Callback callback); 79 static void EnumerateWorkerTargets(Callback callback);
78 static void EnumerateAllTargets(Callback callback); 80 static void EnumerateAllTargets(Callback callback);
79 81
80 private: 82 private:
81 scoped_refptr<content::DevToolsAgentHost> agent_host_; 83 scoped_refptr<content::DevToolsAgentHost> agent_host_;
82 std::string parent_id_; 84 std::string parent_id_;
83 std::string type_; 85 std::string type_;
84 std::string title_; 86 std::string title_;
85 std::string description_; 87 std::string description_;
86 GURL url_; 88 GURL url_;
87 GURL favicon_url_; 89 GURL favicon_url_;
88 base::TimeTicks last_activity_time_; 90 base::TimeTicks last_activity_time_;
89 }; 91 };
90 92
91 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_ 93 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGET_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_sanity_browsertest.cc ('k') | chrome/browser/devtools/devtools_target_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698