| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.content.Context; |
| 7 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
| 8 | 9 |
| 9 import org.chromium.base.ApiCompatibilityUtils; | 10 import org.chromium.base.ApiCompatibilityUtils; |
| 10 import org.chromium.base.ContextUtils; | |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Controller for Remote Web Debugging (Developer Tools). | 14 * Controller for Remote Web Debugging (Developer Tools). |
| 15 */ | 15 */ |
| 16 public class DevToolsServer { | 16 public class DevToolsServer { |
| 17 private static final String DEBUG_PERMISSION_SIFFIX = ".permission.DEBUG"; | 17 private static final String DEBUG_PERMISSION_SIFFIX = ".permission.DEBUG"; |
| 18 | 18 |
| 19 private long mNativeDevToolsServer; | 19 private long mNativeDevToolsServer; |
| 20 | 20 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 setRemoteDebuggingEnabled(enabled, Security.DEFAULT); | 50 setRemoteDebuggingEnabled(enabled, Security.DEFAULT); |
| 51 } | 51 } |
| 52 | 52 |
| 53 private native long nativeInitRemoteDebugging(String socketNamePrefix); | 53 private native long nativeInitRemoteDebugging(String socketNamePrefix); |
| 54 private native void nativeDestroyRemoteDebugging(long devToolsServer); | 54 private native void nativeDestroyRemoteDebugging(long devToolsServer); |
| 55 private native boolean nativeIsRemoteDebuggingEnabled(long devToolsServer); | 55 private native boolean nativeIsRemoteDebuggingEnabled(long devToolsServer); |
| 56 private native void nativeSetRemoteDebuggingEnabled( | 56 private native void nativeSetRemoteDebuggingEnabled( |
| 57 long devToolsServer, boolean enabled, boolean allowDebugPermission); | 57 long devToolsServer, boolean enabled, boolean allowDebugPermission); |
| 58 | 58 |
| 59 @CalledByNative | 59 @CalledByNative |
| 60 private static boolean checkDebugPermission(int pid, int uid) { | 60 private static boolean checkDebugPermission(Context context, int pid, int ui
d) { |
| 61 String debugPermissionName = | 61 String debugPermissionName = context.getPackageName() + DEBUG_PERMISSION
_SIFFIX; |
| 62 ContextUtils.getApplicationContext().getPackageName() + DEBUG_PE
RMISSION_SIFFIX; | 62 return ApiCompatibilityUtils.checkPermission(context, debugPermissionNam
e, pid, uid) |
| 63 return ApiCompatibilityUtils.checkPermission( | |
| 64 ContextUtils.getApplicationContext(), debugPermissionName
, pid, uid) | |
| 65 == PackageManager.PERMISSION_GRANTED; | 63 == PackageManager.PERMISSION_GRANTED; |
| 66 } | 64 } |
| 67 } | 65 } |
| OLD | NEW |