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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
23 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "components/devtools_discovery/devtools_discovery_manager.h" | |
26 #include "components/devtools_http_handler/devtools_http_handler.h" | 25 #include "components/devtools_http_handler/devtools_http_handler.h" |
27 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" | 26 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" |
28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" | 28 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" |
| 29 #include "content/public/browser/devtools_manager_delegate.h" |
30 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
31 #include "content/public/common/user_agent.h" | 31 #include "content/public/common/user_agent.h" |
32 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
33 #include "net/base/io_buffer.h" | 33 #include "net/base/io_buffer.h" |
34 #include "net/base/ip_endpoint.h" | 34 #include "net/base/ip_endpoint.h" |
35 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
36 #include "net/server/http_server.h" | 36 #include "net/server/http_server.h" |
37 #include "net/server/http_server_request_info.h" | 37 #include "net/server/http_server_request_info.h" |
38 #include "net/server/http_server_response_info.h" | 38 #include "net/server/http_server_response_info.h" |
39 #include "net/socket/server_socket.h" | 39 #include "net/socket/server_socket.h" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 version.SetString("Android-Package", | 568 version.SetString("Android-Package", |
569 base::android::BuildInfo::GetInstance()->package_name()); | 569 base::android::BuildInfo::GetInstance()->package_name()); |
570 #endif | 570 #endif |
571 SendJson(connection_id, net::HTTP_OK, &version, std::string()); | 571 SendJson(connection_id, net::HTTP_OK, &version, std::string()); |
572 return; | 572 return; |
573 } | 573 } |
574 | 574 |
575 if (command == "list") { | 575 if (command == "list") { |
576 std::string host = info.headers["host"]; | 576 std::string host = info.headers["host"]; |
577 DevToolsAgentHost::List agent_hosts = | 577 DevToolsAgentHost::List agent_hosts = |
578 devtools_discovery::DevToolsDiscoveryManager::GetInstance()-> | 578 content::DevToolsAgentHost::DiscoverAllHosts(); |
579 GetDescriptors(); | |
580 std::sort(agent_hosts.begin(), agent_hosts.end(), TimeComparator); | 579 std::sort(agent_hosts.begin(), agent_hosts.end(), TimeComparator); |
581 agent_host_map_.clear(); | 580 agent_host_map_.clear(); |
582 base::ListValue list_value; | 581 base::ListValue list_value; |
583 for (auto& agent_host : agent_hosts) { | 582 for (auto& agent_host : agent_hosts) { |
584 agent_host_map_[agent_host->GetId()] = agent_host; | 583 agent_host_map_[agent_host->GetId()] = agent_host; |
585 list_value.Append(SerializeDescriptor(agent_host, host)); | 584 list_value.Append(SerializeDescriptor(agent_host, host)); |
586 } | 585 } |
587 SendJson(connection_id, net::HTTP_OK, &list_value, std::string()); | 586 SendJson(connection_id, net::HTTP_OK, &list_value, std::string()); |
588 return; | 587 return; |
589 } | 588 } |
590 | 589 |
591 if (command == "new") { | 590 if (command == "new") { |
592 GURL url(net::UnescapeURLComponent( | 591 GURL url(net::UnescapeURLComponent( |
593 query, net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | | 592 query, net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | |
594 net::UnescapeRule::PATH_SEPARATORS)); | 593 net::UnescapeRule::PATH_SEPARATORS)); |
595 if (!url.is_valid()) | 594 if (!url.is_valid()) |
596 url = GURL(url::kAboutBlankURL); | 595 url = GURL(url::kAboutBlankURL); |
597 scoped_refptr<DevToolsAgentHost> agent_host = | 596 scoped_refptr<DevToolsAgentHost> agent_host = nullptr; |
598 devtools_discovery::DevToolsDiscoveryManager::GetInstance()->CreateNew( | 597 content::DevToolsManagerDelegate* delegate = |
599 url); | 598 DevToolsAgentHost::GetDevToolsManagerDelegate(); |
| 599 if (delegate) |
| 600 agent_host = delegate->CreateNewTarget(url); |
600 if (!agent_host) { | 601 if (!agent_host) { |
601 SendJson(connection_id, | 602 SendJson(connection_id, |
602 net::HTTP_INTERNAL_SERVER_ERROR, | 603 net::HTTP_INTERNAL_SERVER_ERROR, |
603 NULL, | 604 NULL, |
604 "Could not create new page"); | 605 "Could not create new page"); |
605 return; | 606 return; |
606 } | 607 } |
607 std::string host = info.headers["host"]; | 608 std::string host = info.headers["host"]; |
608 std::unique_ptr<base::DictionaryValue> dictionary( | 609 std::unique_ptr<base::DictionaryValue> dictionary( |
609 SerializeDescriptor(agent_host, host)); | 610 SerializeDescriptor(agent_host, host)); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 id.c_str(), | 924 id.c_str(), |
924 host); | 925 host); |
925 dictionary->SetString( | 926 dictionary->SetString( |
926 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 927 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
927 } | 928 } |
928 | 929 |
929 return dictionary; | 930 return dictionary; |
930 } | 931 } |
931 | 932 |
932 } // namespace devtools_http_handler | 933 } // namespace devtools_http_handler |
OLD | NEW |