OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/devtools/devtools_agent_host_impl.h" | 5 #include "content/browser/devtools/devtools_agent_host_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 namespace { | 25 namespace { |
26 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; | 26 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; |
27 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; | 27 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; |
28 | 28 |
29 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*> | 29 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*> |
30 AgentStateCallbacks; | 30 AgentStateCallbacks; |
31 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks = | 31 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks = |
32 LAZY_INSTANCE_INITIALIZER; | 32 LAZY_INSTANCE_INITIALIZER; |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 char DevToolsAgentHost::kTypePage[] = "page"; | |
36 char DevToolsAgentHost::kTypeFrame[] = "frame"; | |
37 char DevToolsAgentHost::kTypeSharedWorker[] = "shared_worker"; | |
38 char DevToolsAgentHost::kTypeServiceWorker[] = "service_worker"; | |
39 char DevToolsAgentHost::kTypeExternal[] = "external"; | |
40 char DevToolsAgentHost::kTypeBrowser[] = "browser"; | |
41 char DevToolsAgentHost::kTypeOther[] = "other"; | |
42 | |
35 // static | 43 // static |
36 std::string DevToolsAgentHost::GetProtocolVersion() { | 44 std::string DevToolsAgentHost::GetProtocolVersion() { |
37 return std::string(devtools::kProtocolVersion); | 45 return std::string(devtools::kProtocolVersion); |
38 } | 46 } |
39 | 47 |
40 // static | 48 // static |
41 bool DevToolsAgentHost::IsSupportedProtocolVersion(const std::string& version) { | 49 bool DevToolsAgentHost::IsSupportedProtocolVersion(const std::string& version) { |
42 return devtools::IsSupportedProtocolVersion(version); | 50 return devtools::IsSupportedProtocolVersion(version); |
43 } | 51 } |
44 | 52 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 int y) { | 167 int y) { |
160 if (!client_ || client_ != client) | 168 if (!client_ || client_ != client) |
161 return; | 169 return; |
162 InspectElement(x, y); | 170 InspectElement(x, y); |
163 } | 171 } |
164 | 172 |
165 std::string DevToolsAgentHostImpl::GetId() { | 173 std::string DevToolsAgentHostImpl::GetId() { |
166 return id_; | 174 return id_; |
167 } | 175 } |
168 | 176 |
177 std::string DevToolsAgentHostImpl::GetParentId() { | |
178 return ""; | |
179 } | |
180 | |
181 std::string DevToolsAgentHostImpl::GetDescription() { | |
182 return ""; | |
183 } | |
184 | |
185 GURL DevToolsAgentHostImpl::GetFaviconURL() { | |
186 return GURL(); | |
187 } | |
188 | |
189 base::TimeTicks DevToolsAgentHostImpl::GetLastActivityTime() { | |
190 return base::TimeTicks(); | |
191 } | |
192 | |
169 BrowserContext* DevToolsAgentHostImpl::GetBrowserContext() { | 193 BrowserContext* DevToolsAgentHostImpl::GetBrowserContext() { |
170 return nullptr; | 194 return nullptr; |
171 } | 195 } |
172 | 196 |
173 WebContents* DevToolsAgentHostImpl::GetWebContents() { | 197 WebContents* DevToolsAgentHostImpl::GetWebContents() { |
174 return NULL; | 198 return NULL; |
175 } | 199 } |
176 | 200 |
177 void DevToolsAgentHostImpl::DisconnectWebContents() { | 201 void DevToolsAgentHostImpl::DisconnectWebContents() { |
178 } | 202 } |
179 | 203 |
180 void DevToolsAgentHostImpl::ConnectWebContents(WebContents* wc) { | 204 void DevToolsAgentHostImpl::ConnectWebContents(WebContents* wc) { |
181 } | 205 } |
182 | 206 |
207 void DevToolsAgentHostImpl::Inspect() { | |
208 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
209 manager->delegate()->Inspect(this); | |
210 } | |
211 | |
183 void DevToolsAgentHostImpl::SendProtocolResponse(int session_id, | 212 void DevToolsAgentHostImpl::SendProtocolResponse(int session_id, |
184 const std::string& message) { | 213 const std::string& message) { |
185 SendMessageToClient(session_id, message); | 214 SendMessageToClient(session_id, message); |
186 } | 215 } |
187 | 216 |
188 void DevToolsAgentHostImpl::SendProtocolNotification( | 217 void DevToolsAgentHostImpl::SendProtocolNotification( |
189 const std::string& message) { | 218 const std::string& message) { |
190 SendMessageToClient(session_id_, message); | 219 SendMessageToClient(session_id_, message); |
191 } | 220 } |
192 | 221 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 DevToolsAgentHostImpl* agent_host, bool attached) { | 288 DevToolsAgentHostImpl* agent_host, bool attached) { |
260 AgentStateCallbacks copy(g_callbacks.Get()); | 289 AgentStateCallbacks copy(g_callbacks.Get()); |
261 DevToolsManager* manager = DevToolsManager::GetInstance(); | 290 DevToolsManager* manager = DevToolsManager::GetInstance(); |
262 manager->AgentHostStateChanged(agent_host, attached); | 291 manager->AgentHostStateChanged(agent_host, attached); |
263 if (manager->delegate()) | 292 if (manager->delegate()) |
264 manager->delegate()->DevToolsAgentStateChanged(agent_host, attached); | 293 manager->delegate()->DevToolsAgentStateChanged(agent_host, attached); |
265 for (AgentStateCallbacks::iterator it = copy.begin(); it != copy.end(); ++it) | 294 for (AgentStateCallbacks::iterator it = copy.begin(); it != copy.end(); ++it) |
266 (*it)->Run(agent_host, attached); | 295 (*it)->Run(agent_host, attached); |
267 } | 296 } |
268 | 297 |
269 bool DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) { | 298 bool DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) { |
dgozman
2016/08/22 23:09:07
Remove this method.
| |
270 DevToolsManager* manager = DevToolsManager::GetInstance(); | 299 DevToolsManager* manager = DevToolsManager::GetInstance(); |
271 if (manager->delegate()) { | 300 if (manager->delegate()) { |
272 manager->delegate()->Inspect(browser_context, this); | 301 manager->delegate()->Inspect(this); |
273 return true; | 302 return true; |
274 } | 303 } |
275 return false; | 304 return false; |
276 } | 305 } |
277 | 306 |
278 // DevToolsMessageChunkProcessor ----------------------------------------------- | 307 // DevToolsMessageChunkProcessor ----------------------------------------------- |
279 | 308 |
280 DevToolsMessageChunkProcessor::DevToolsMessageChunkProcessor( | 309 DevToolsMessageChunkProcessor::DevToolsMessageChunkProcessor( |
281 const SendMessageCallback& callback) | 310 const SendMessageCallback& callback) |
282 : callback_(callback), | 311 : callback_(callback), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 if (message_buffer_.size() != message_buffer_size_) | 344 if (message_buffer_.size() != message_buffer_size_) |
316 return false; | 345 return false; |
317 callback_.Run(chunk.session_id, message_buffer_); | 346 callback_.Run(chunk.session_id, message_buffer_); |
318 message_buffer_ = std::string(); | 347 message_buffer_ = std::string(); |
319 message_buffer_size_ = 0; | 348 message_buffer_size_ = 0; |
320 } | 349 } |
321 return true; | 350 return true; |
322 } | 351 } |
323 | 352 |
324 } // namespace content | 353 } // namespace content |
OLD | NEW |