OLD | NEW |
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 #include "android_webview/native/aw_dev_tools_server.h" | 5 #include "android_webview/native/aw_dev_tools_server.h" |
6 | 6 |
7 #include "android_webview/native/aw_contents.h" | 7 #include "android_webview/native/aw_contents.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 scoped_refptr<DevToolsAgentHost> agent_host_; | 62 scoped_refptr<DevToolsAgentHost> agent_host_; |
63 std::string id_; | 63 std::string id_; |
64 std::string title_; | 64 std::string title_; |
65 std::string description_; | 65 std::string description_; |
66 GURL url_; | 66 GURL url_; |
67 base::TimeTicks last_activity_time_; | 67 base::TimeTicks last_activity_time_; |
68 }; | 68 }; |
69 | 69 |
70 Target::Target(WebContents* web_contents) { | 70 Target::Target(WebContents* web_contents) { |
71 agent_host_ = | 71 agent_host_ = |
72 DevToolsAgentHost::GetOrCreateFor(web_contents->GetRenderViewHost()); | 72 DevToolsAgentHost::GetOrCreateFor(web_contents); |
73 id_ = agent_host_->GetId(); | 73 id_ = agent_host_->GetId(); |
74 description_ = GetViewDescription(web_contents); | 74 description_ = GetViewDescription(web_contents); |
75 title_ = base::UTF16ToUTF8(web_contents->GetTitle()); | 75 title_ = base::UTF16ToUTF8(web_contents->GetTitle()); |
76 url_ = web_contents->GetURL(); | 76 url_ = web_contents->GetURL(); |
77 last_activity_time_ = web_contents->GetLastActiveTime(); | 77 last_activity_time_ = web_contents->GetLastActiveTime(); |
78 } | 78 } |
79 | 79 |
80 // Delegate implementation for the devtools http handler for WebView. A new | 80 // Delegate implementation for the devtools http handler for WebView. A new |
81 // instance of this gets created each time web debugging is enabled. | 81 // instance of this gets created each time web debugging is enabled. |
82 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { | 82 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
(...skipping 16 matching lines...) Expand all Loading... |
99 return ""; | 99 return ""; |
100 } | 100 } |
101 | 101 |
102 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget( | 102 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget( |
103 const GURL&) OVERRIDE { | 103 const GURL&) OVERRIDE { |
104 return scoped_ptr<content::DevToolsTarget>(); | 104 return scoped_ptr<content::DevToolsTarget>(); |
105 } | 105 } |
106 | 106 |
107 virtual void EnumerateTargets(TargetCallback callback) OVERRIDE { | 107 virtual void EnumerateTargets(TargetCallback callback) OVERRIDE { |
108 TargetList targets; | 108 TargetList targets; |
109 std::vector<RenderViewHost*> rvh_list = | 109 std::vector<WebContents*> wc_list = |
110 DevToolsAgentHost::GetValidRenderViewHosts(); | 110 DevToolsAgentHost::GetInspectableWebContents(); |
111 for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin(); | 111 for (std::vector<WebContents*>::iterator it = wc_list.begin(); |
112 it != rvh_list.end(); ++it) { | 112 it != wc_list.end(); ++it) { |
113 WebContents* web_contents = WebContents::FromRenderViewHost(*it); | 113 targets.push_back(new Target(*it)); |
114 if (web_contents) | |
115 targets.push_back(new Target(web_contents)); | |
116 } | 114 } |
117 callback.Run(targets); | 115 callback.Run(targets); |
118 } | 116 } |
119 | 117 |
120 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( | 118 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( |
121 net::StreamListenSocket::Delegate* delegate, | 119 net::StreamListenSocket::Delegate* delegate, |
122 std::string* name) OVERRIDE { | 120 std::string* name) OVERRIDE { |
123 return scoped_ptr<net::StreamListenSocket>(); | 121 return scoped_ptr<net::StreamListenSocket>(); |
124 } | 122 } |
125 | 123 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 AwDevToolsServer* devtools_server = | 217 AwDevToolsServer* devtools_server = |
220 reinterpret_cast<AwDevToolsServer*>(server); | 218 reinterpret_cast<AwDevToolsServer*>(server); |
221 if (enabled) { | 219 if (enabled) { |
222 devtools_server->Start(); | 220 devtools_server->Start(); |
223 } else { | 221 } else { |
224 devtools_server->Stop(); | 222 devtools_server->Stop(); |
225 } | 223 } |
226 } | 224 } |
227 | 225 |
228 } // namespace android_webview | 226 } // namespace android_webview |
OLD | NEW |