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/shell/shell_devtools_delegate.h" | 5 #include "content/shell/shell_devtools_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "content/public/browser/devtools_http_handler.h" | 12 #include "content/public/browser/devtools_http_handler.h" |
| 13 #include "content/public/browser/devtools_remote_frontend_util.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
15 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
16 #include "content/shell/shell.h" | 17 #include "content/shell/shell.h" |
17 #include "grit/shell_resources.h" | 18 #include "grit/shell_resources.h" |
18 #include "net/socket/tcp_listen_socket.h" | 19 #include "net/socket/tcp_listen_socket.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
20 | 21 |
21 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
22 #include "content/public/browser/android/devtools_auth.h" | 23 #include "content/public/browser/android/devtools_auth.h" |
23 #include "net/socket/unix_domain_socket_posix.h" | 24 #include "net/socket/unix_domain_socket_posix.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 net::StreamListenSocketFactory* CreateSocketFactory() { | 29 content::DevToolsHttpHandler* CreateDevToolsHttpHandler( |
| 30 content::DevToolsHttpHandlerDelegate* delegate) { |
29 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 31 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 32 |
30 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
31 std::string socket_name = "content_shell_devtools_remote"; | 34 std::string socket_name = |
| 35 content::GetDevToolsServerSocketName("content_shell"); |
32 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { | 36 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { |
33 socket_name = command_line.GetSwitchValueASCII( | 37 socket_name = command_line.GetSwitchValueASCII( |
34 switches::kRemoteDebuggingSocketName); | 38 switches::kRemoteDebuggingSocketName); |
35 } | 39 } |
36 return new net::UnixDomainSocketWithAbstractNamespaceFactory( | 40 |
37 socket_name, "", base::Bind(&content::CanUserConnectToDevTools)); | 41 return content::DevToolsHttpHandler::Start( |
| 42 new net::UnixDomainSocketWithAbstractNamespaceFactory( |
| 43 socket_name, "", base::Bind(&content::CanUserConnectToDevTools)), |
| 44 content::GetDevToolsFrontendMainResourceURL(), |
| 45 delegate); |
38 #else | 46 #else |
39 // See if the user specified a port on the command line (useful for | 47 // See if the user specified a port on the command line (useful for |
40 // automation). If not, use an ephemeral port by specifying 0. | 48 // automation). If not, use an ephemeral port by specifying 0. |
41 int port = 0; | 49 int port = 0; |
42 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | 50 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { |
43 int temp_port; | 51 int temp_port; |
44 std::string port_str = | 52 std::string port_str = |
45 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | 53 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); |
46 if (base::StringToInt(port_str, &temp_port) && | 54 if (base::StringToInt(port_str, &temp_port) && |
47 temp_port > 0 && temp_port < 65535) { | 55 temp_port > 0 && temp_port < 65535) { |
48 port = temp_port; | 56 port = temp_port; |
49 } else { | 57 } else { |
50 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; | 58 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; |
51 } | 59 } |
52 } | 60 } |
53 return new net::TCPListenSocketFactory("127.0.0.1", port); | 61 |
| 62 return content::DevToolsHttpHandler::Start( |
| 63 new net::TCPListenSocketFactory("127.0.0.1", port), |
| 64 std::string(), |
| 65 delegate); |
54 #endif | 66 #endif |
55 } | 67 } |
56 } // namespace | 68 } // namespace |
57 | 69 |
58 namespace content { | 70 namespace content { |
59 | 71 |
60 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) | 72 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) |
61 : browser_context_(browser_context) { | 73 : browser_context_(browser_context) { |
62 devtools_http_handler_ = | 74 devtools_http_handler_ = CreateDevToolsHttpHandler(this); |
63 DevToolsHttpHandler::Start(CreateSocketFactory(), std::string(), this); | |
64 } | 75 } |
65 | 76 |
66 ShellDevToolsDelegate::~ShellDevToolsDelegate() { | 77 ShellDevToolsDelegate::~ShellDevToolsDelegate() { |
67 } | 78 } |
68 | 79 |
69 void ShellDevToolsDelegate::Stop() { | 80 void ShellDevToolsDelegate::Stop() { |
70 // The call below destroys this. | 81 // The call below destroys this. |
71 devtools_http_handler_->Stop(); | 82 devtools_http_handler_->Stop(); |
72 } | 83 } |
73 | 84 |
74 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { | 85 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { |
75 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 86 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
76 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); | 87 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); |
77 } | 88 } |
78 | 89 |
79 bool ShellDevToolsDelegate::BundlesFrontendResources() { | 90 bool ShellDevToolsDelegate::BundlesFrontendResources() { |
| 91 #if defined(OS_ANDROID) |
| 92 return false; |
| 93 #else |
80 return true; | 94 return true; |
| 95 #endif |
81 } | 96 } |
82 | 97 |
83 base::FilePath ShellDevToolsDelegate::GetDebugFrontendDir() { | 98 base::FilePath ShellDevToolsDelegate::GetDebugFrontendDir() { |
84 return base::FilePath(); | 99 return base::FilePath(); |
85 } | 100 } |
86 | 101 |
87 std::string ShellDevToolsDelegate::GetPageThumbnailData(const GURL& url) { | 102 std::string ShellDevToolsDelegate::GetPageThumbnailData(const GURL& url) { |
88 return std::string(); | 103 return std::string(); |
89 } | 104 } |
90 | 105 |
(...skipping 17 matching lines...) Expand all Loading... |
108 } | 123 } |
109 | 124 |
110 scoped_refptr<net::StreamListenSocket> | 125 scoped_refptr<net::StreamListenSocket> |
111 ShellDevToolsDelegate::CreateSocketForTethering( | 126 ShellDevToolsDelegate::CreateSocketForTethering( |
112 net::StreamListenSocket::Delegate* delegate, | 127 net::StreamListenSocket::Delegate* delegate, |
113 std::string* name) { | 128 std::string* name) { |
114 return NULL; | 129 return NULL; |
115 } | 130 } |
116 | 131 |
117 } // namespace content | 132 } // namespace content |
OLD | NEW |