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