| 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_devtools_server.h" | 5 #include "android_webview/native/aw_devtools_server.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/browser/browser_view_renderer.h" | 9 #include "android_webview/browser/browser_view_renderer.h" |
| 10 #include "android_webview/common/aw_content_client.h" | 10 #include "android_webview/common/aw_content_client.h" |
| 11 #include "android_webview/native/aw_contents.h" | 11 #include "android_webview/native/aw_contents.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "content/public/browser/android/devtools_auth.h" | 19 #include "content/public/browser/android/devtools_auth.h" |
| 20 #include "content/public/browser/devtools_agent_host.h" | 20 #include "content/public/browser/devtools_agent_host.h" |
| 21 #include "content/public/browser/devtools_socket_factory.h" | 21 #include "content/public/browser/devtools_socket_factory.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/common/user_agent.h" | 23 #include "content/public/common/user_agent.h" |
| 24 #include "jni/AwDevToolsServer_jni.h" | 24 #include "jni/AwDevToolsServer_jni.h" |
| 25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 26 #include "net/socket/unix_domain_server_socket_posix.h" | 26 #include "net/socket/unix_domain_server_socket_posix.h" |
| 27 #include "v8/include/v8.h" |
| 27 | 28 |
| 28 using base::android::JavaParamRef; | 29 using base::android::JavaParamRef; |
| 29 using content::DevToolsAgentHost; | 30 using content::DevToolsAgentHost; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const char kFrontEndURL[] = | 34 const char kFrontEndURL[] = |
| 34 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/inspector.html"; | 35 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/inspector.html"; |
| 35 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; | 36 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; |
| 36 const char kTetheringSocketName[] = "webview_devtools_tethering_%d_%d"; | 37 const char kTetheringSocketName[] = "webview_devtools_tethering_%d_%d"; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return; | 95 return; |
| 95 is_started_ = true; | 96 is_started_ = true; |
| 96 | 97 |
| 97 std::unique_ptr<content::DevToolsSocketFactory> factory( | 98 std::unique_ptr<content::DevToolsSocketFactory> factory( |
| 98 new UnixDomainServerSocketFactory( | 99 new UnixDomainServerSocketFactory( |
| 99 base::StringPrintf(kSocketNameFormat, getpid()))); | 100 base::StringPrintf(kSocketNameFormat, getpid()))); |
| 100 DevToolsAgentHost::StartRemoteDebuggingServer( | 101 DevToolsAgentHost::StartRemoteDebuggingServer( |
| 101 std::move(factory), | 102 std::move(factory), |
| 102 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), | 103 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), |
| 103 base::FilePath(), base::FilePath(), | 104 base::FilePath(), base::FilePath(), |
| 104 GetProduct(), GetUserAgent()); | 105 GetProduct(), GetUserAgent(), v8::V8::GetVersion()); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void AwDevToolsServer::Stop() { | 108 void AwDevToolsServer::Stop() { |
| 108 DevToolsAgentHost::StopRemoteDebuggingServer(); | 109 DevToolsAgentHost::StopRemoteDebuggingServer(); |
| 109 is_started_ = false; | 110 is_started_ = false; |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool AwDevToolsServer::IsStarted() const { | 113 bool AwDevToolsServer::IsStarted() const { |
| 113 return is_started_; | 114 return is_started_; |
| 114 } | 115 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 136 AwDevToolsServer* devtools_server = | 137 AwDevToolsServer* devtools_server = |
| 137 reinterpret_cast<AwDevToolsServer*>(server); | 138 reinterpret_cast<AwDevToolsServer*>(server); |
| 138 if (enabled) { | 139 if (enabled) { |
| 139 devtools_server->Start(); | 140 devtools_server->Start(); |
| 140 } else { | 141 } else { |
| 141 devtools_server->Stop(); | 142 devtools_server->Stop(); |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 | 145 |
| 145 } // namespace android_webview | 146 } // namespace android_webview |
| OLD | NEW |