OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/devtools/device/devtools_android_bridge.h" | 5 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 : public content::DevToolsExternalAgentProxyDelegate, | 293 : public content::DevToolsExternalAgentProxyDelegate, |
294 public AndroidDeviceManager::AndroidWebSocket::Delegate { | 294 public AndroidDeviceManager::AndroidWebSocket::Delegate { |
295 public: | 295 public: |
296 static scoped_refptr<content::DevToolsAgentHost> GetOrCreateAgentHost( | 296 static scoped_refptr<content::DevToolsAgentHost> GetOrCreateAgentHost( |
297 DevToolsAndroidBridge* bridge, | 297 DevToolsAndroidBridge* bridge, |
298 const BrowserId& browser_id, | 298 const BrowserId& browser_id, |
299 const std::string& local_id, | 299 const std::string& local_id, |
300 const std::string& target_path, | 300 const std::string& target_path, |
301 const std::string& type, | 301 const std::string& type, |
302 base::DictionaryValue* value); | 302 base::DictionaryValue* value); |
| 303 ~AgentHostDelegate() override; |
303 | 304 |
304 private: | 305 private: |
305 AgentHostDelegate( | 306 AgentHostDelegate( |
306 DevToolsAndroidBridge* bridge, | 307 DevToolsAndroidBridge* bridge, |
307 const BrowserId& browser_id, | 308 const BrowserId& browser_id, |
308 const std::string& local_id, | 309 const std::string& local_id, |
309 const std::string& target_path, | 310 const std::string& target_path, |
310 const std::string& type, | 311 const std::string& type, |
311 base::DictionaryValue* value); | 312 base::DictionaryValue* value); |
312 ~AgentHostDelegate() override; | |
313 // DevToolsExternalAgentProxyDelegate overrides. | 313 // DevToolsExternalAgentProxyDelegate overrides. |
314 void Attach(content::DevToolsExternalAgentProxy* proxy) override; | 314 void Attach(content::DevToolsExternalAgentProxy* proxy) override; |
315 void Detach() override; | 315 void Detach() override; |
316 std::string GetId() override; | |
317 std::string GetType() override; | 316 std::string GetType() override; |
318 std::string GetTitle() override; | 317 std::string GetTitle() override; |
319 std::string GetDescription() override; | 318 std::string GetDescription() override; |
320 GURL GetURL() override; | 319 GURL GetURL() override; |
321 GURL GetFaviconURL() override; | 320 GURL GetFaviconURL() override; |
322 bool Activate() override; | 321 bool Activate() override; |
323 bool Inspect() override; | 322 bool Inspect() override; |
324 void Reload() override; | 323 void Reload() override; |
325 bool Close() override; | 324 bool Close() override; |
326 void SendMessageToBackend(const std::string& message) override; | 325 void SendMessageToBackend(const std::string& message) override; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 const BrowserId& browser_id, | 393 const BrowserId& browser_id, |
395 const std::string& local_id, | 394 const std::string& local_id, |
396 const std::string& target_path, | 395 const std::string& target_path, |
397 const std::string& type, | 396 const std::string& type, |
398 base::DictionaryValue* value) { | 397 base::DictionaryValue* value) { |
399 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 398 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
400 AgentHostDelegates::iterator it = bridge->host_delegates_.find(local_id); | 399 AgentHostDelegates::iterator it = bridge->host_delegates_.find(local_id); |
401 if (it != bridge->host_delegates_.end()) | 400 if (it != bridge->host_delegates_.end()) |
402 return it->second->agent_host_; | 401 return it->second->agent_host_; |
403 | 402 |
404 AgentHostDelegate* delegate = new AgentHostDelegate( | 403 std::unique_ptr<AgentHostDelegate> delegate(new AgentHostDelegate( |
405 bridge, browser_id, local_id, target_path, type, value); | 404 bridge, browser_id, local_id, target_path, type, value)); |
406 scoped_refptr<content::DevToolsAgentHost> result = | 405 scoped_refptr<content::DevToolsAgentHost> result = |
407 content::DevToolsAgentHost::Create(delegate); | 406 content::DevToolsAgentHost::Forward(local_id, std::move(delegate)); |
408 delegate->agent_host_ = result.get(); | 407 delegate->agent_host_ = result.get(); |
409 return result; | 408 return result; |
410 } | 409 } |
411 | 410 |
412 DevToolsAndroidBridge::AgentHostDelegate::AgentHostDelegate( | 411 DevToolsAndroidBridge::AgentHostDelegate::AgentHostDelegate( |
413 DevToolsAndroidBridge* bridge, | 412 DevToolsAndroidBridge* bridge, |
414 const BrowserId& browser_id, | 413 const BrowserId& browser_id, |
415 const std::string& local_id, | 414 const std::string& local_id, |
416 const std::string& target_path, | 415 const std::string& target_path, |
417 const std::string& type, | 416 const std::string& type, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 web_socket_.reset( | 456 web_socket_.reset( |
458 device_->CreateWebSocket(browser_id_.second, target_path_, this)); | 457 device_->CreateWebSocket(browser_id_.second, target_path_, this)); |
459 } | 458 } |
460 | 459 |
461 void DevToolsAndroidBridge::AgentHostDelegate::Detach() { | 460 void DevToolsAndroidBridge::AgentHostDelegate::Detach() { |
462 web_socket_.reset(); | 461 web_socket_.reset(); |
463 device_ = nullptr; | 462 device_ = nullptr; |
464 proxy_ = nullptr; | 463 proxy_ = nullptr; |
465 } | 464 } |
466 | 465 |
467 std::string DevToolsAndroidBridge::AgentHostDelegate::GetId() { | |
468 return local_id_; | |
469 } | |
470 | |
471 std::string DevToolsAndroidBridge::AgentHostDelegate::GetType() { | 466 std::string DevToolsAndroidBridge::AgentHostDelegate::GetType() { |
472 return remote_type_; | 467 return remote_type_; |
473 } | 468 } |
474 | 469 |
475 std::string DevToolsAndroidBridge::AgentHostDelegate::GetTitle() { | 470 std::string DevToolsAndroidBridge::AgentHostDelegate::GetTitle() { |
476 return title_; | 471 return title_; |
477 } | 472 } |
478 | 473 |
479 std::string DevToolsAndroidBridge::AgentHostDelegate::GetDescription() { | 474 std::string DevToolsAndroidBridge::AgentHostDelegate::GetDescription() { |
480 return description_; | 475 return description_; |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 StopDeviceListPolling(); | 990 StopDeviceListPolling(); |
996 StartDeviceListPolling(); | 991 StartDeviceListPolling(); |
997 } | 992 } |
998 } | 993 } |
999 | 994 |
1000 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( | 995 void DevToolsAndroidBridge::set_tcp_provider_callback_for_test( |
1001 TCPProviderCallback callback) { | 996 TCPProviderCallback callback) { |
1002 tcp_provider_callback_ = callback; | 997 tcp_provider_callback_ = callback; |
1003 CreateDeviceProviders(); | 998 CreateDeviceProviders(); |
1004 } | 999 } |
OLD | NEW |