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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "content/public/browser/android/devtools_auth.h" | 13 #include "content/public/browser/android/devtools_auth.h" |
14 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
15 #include "content/public/browser/devtools_http_handler.h" | 15 #include "content/public/browser/devtools_http_handler.h" |
16 #include "content/public/browser/devtools_http_handler_delegate.h" | 16 #include "content/public/browser/devtools_http_handler_delegate.h" |
17 #include "content/public/browser/devtools_target.h" | 17 #include "content/public/browser/devtools_target.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/user_agent.h" |
19 #include "jni/AwDevToolsServer_jni.h" | 20 #include "jni/AwDevToolsServer_jni.h" |
20 #include "net/socket/unix_domain_socket_posix.h" | 21 #include "net/socket/unix_domain_socket_posix.h" |
21 #include "webkit/common/user_agent/user_agent_util.h" | |
22 | 22 |
23 using content::DevToolsAgentHost; | 23 using content::DevToolsAgentHost; |
24 using content::RenderViewHost; | 24 using content::RenderViewHost; |
25 using content::WebContents; | 25 using content::WebContents; |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const char kFrontEndURL[] = | 29 const char kFrontEndURL[] = |
30 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; | 30 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; |
31 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; | 31 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 void AwDevToolsServer::Start() { | 172 void AwDevToolsServer::Start() { |
173 if (protocol_handler_) | 173 if (protocol_handler_) |
174 return; | 174 return; |
175 | 175 |
176 protocol_handler_ = content::DevToolsHttpHandler::Start( | 176 protocol_handler_ = content::DevToolsHttpHandler::Start( |
177 new net::UnixDomainSocketWithAbstractNamespaceFactory( | 177 new net::UnixDomainSocketWithAbstractNamespaceFactory( |
178 base::StringPrintf(kSocketNameFormat, getpid()), | 178 base::StringPrintf(kSocketNameFormat, getpid()), |
179 "", | 179 "", |
180 base::Bind(&content::CanUserConnectToDevTools)), | 180 base::Bind(&content::CanUserConnectToDevTools)), |
181 base::StringPrintf(kFrontEndURL, | 181 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), |
182 webkit_glue::GetWebKitRevision().c_str()), | |
183 new AwDevToolsServerDelegate()); | 182 new AwDevToolsServerDelegate()); |
184 } | 183 } |
185 | 184 |
186 void AwDevToolsServer::Stop() { | 185 void AwDevToolsServer::Stop() { |
187 if (!protocol_handler_) | 186 if (!protocol_handler_) |
188 return; | 187 return; |
189 // Note that the call to Stop() below takes care of |protocol_handler_| | 188 // Note that the call to Stop() below takes care of |protocol_handler_| |
190 // deletion. | 189 // deletion. |
191 protocol_handler_->Stop(); | 190 protocol_handler_->Stop(); |
192 protocol_handler_ = NULL; | 191 protocol_handler_ = NULL; |
(...skipping 24 matching lines...) Expand all Loading... |
217 AwDevToolsServer* devtools_server = | 216 AwDevToolsServer* devtools_server = |
218 reinterpret_cast<AwDevToolsServer*>(server); | 217 reinterpret_cast<AwDevToolsServer*>(server); |
219 if (enabled) { | 218 if (enabled) { |
220 devtools_server->Start(); | 219 devtools_server->Start(); |
221 } else { | 220 } else { |
222 devtools_server->Stop(); | 221 devtools_server->Stop(); |
223 } | 222 } |
224 } | 223 } |
225 | 224 |
226 } // namespace android_webview | 225 } // namespace android_webview |
OLD | NEW |