| 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 "chrome/browser/android/devtools_server.h" | 5 #include "chrome/browser/android/devtools_server.h" |
| 6 | 6 |
| 7 #include <pwd.h> | 7 #include <pwd.h> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/android/context_utils.h" | |
| 12 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 13 #include "base/bind.h" | 12 #include "base/bind.h" |
| 14 #include "base/callback.h" | 13 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 17 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 18 #include "base/logging.h" | 17 #include "base/logging.h" |
| 19 #include "base/macros.h" | 18 #include "base/macros.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 64 |
| 66 const char kFrontEndURL[] = | 65 const char kFrontEndURL[] = |
| 67 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/inspector.html"; | 66 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/inspector.html"; |
| 68 const char kTetheringSocketName[] = "chrome_devtools_tethering_%d_%d"; | 67 const char kTetheringSocketName[] = "chrome_devtools_tethering_%d_%d"; |
| 69 | 68 |
| 70 const int kBackLog = 10; | 69 const int kBackLog = 10; |
| 71 | 70 |
| 72 bool AuthorizeSocketAccessWithDebugPermission( | 71 bool AuthorizeSocketAccessWithDebugPermission( |
| 73 const net::UnixDomainServerSocket::Credentials& credentials) { | 72 const net::UnixDomainServerSocket::Credentials& credentials) { |
| 74 JNIEnv* env = base::android::AttachCurrentThread(); | 73 JNIEnv* env = base::android::AttachCurrentThread(); |
| 75 return Java_DevToolsServer_checkDebugPermission( | 74 return Java_DevToolsServer_checkDebugPermission(env, credentials.process_id, |
| 76 env, base::android::GetApplicationContext(), | 75 credentials.user_id) || |
| 77 credentials.process_id, credentials.user_id) || | 76 content::CanUserConnectToDevTools(credentials); |
| 78 content::CanUserConnectToDevTools(credentials); | |
| 79 } | 77 } |
| 80 | 78 |
| 81 // Factory for UnixDomainServerSocket. It tries a fallback socket when | 79 // Factory for UnixDomainServerSocket. It tries a fallback socket when |
| 82 // original socket doesn't work. | 80 // original socket doesn't work. |
| 83 class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory { | 81 class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory { |
| 84 public: | 82 public: |
| 85 UnixDomainServerSocketFactory( | 83 UnixDomainServerSocketFactory( |
| 86 const std::string& socket_name, | 84 const std::string& socket_name, |
| 87 const net::UnixDomainServerSocket::AuthCallback& auth_callback) | 85 const net::UnixDomainServerSocket::AuthCallback& auth_callback) |
| 88 : socket_name_(socket_name), | 86 : socket_name_(socket_name), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 jlong server, | 201 jlong server, |
| 204 jboolean enabled, | 202 jboolean enabled, |
| 205 jboolean allow_debug_permission) { | 203 jboolean allow_debug_permission) { |
| 206 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 204 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
| 207 if (enabled) { | 205 if (enabled) { |
| 208 devtools_server->Start(allow_debug_permission); | 206 devtools_server->Start(allow_debug_permission); |
| 209 } else { | 207 } else { |
| 210 devtools_server->Stop(); | 208 devtools_server->Stop(); |
| 211 } | 209 } |
| 212 } | 210 } |
| OLD | NEW |