| 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 "base/android/command_line_android.h" | 5 #include "base/android/command_line_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 static void Reset(JNIEnv* env, jclass clazz) { | 34 static void Reset(JNIEnv* env, jclass clazz) { |
| 35 CommandLine::Reset(); | 35 CommandLine::Reset(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static jboolean HasSwitch(JNIEnv* env, jclass clazz, jstring jswitch) { | 38 static jboolean HasSwitch(JNIEnv* env, jclass clazz, jstring jswitch) { |
| 39 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); | 39 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); |
| 40 return CommandLine::ForCurrentProcess()->HasSwitch(switch_string); | 40 return CommandLine::ForCurrentProcess()->HasSwitch(switch_string); |
| 41 } | 41 } |
| 42 | 42 |
| 43 static ScopedJavaLocalRef<jstring> GetSwitchValue(JNIEnv* env, | 43 static jstring GetSwitchValue(JNIEnv* env, jclass clazz, jstring jswitch) { |
| 44 jclass clazz, | |
| 45 jstring jswitch) { | |
| 46 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); | 44 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); |
| 47 std::string value(CommandLine::ForCurrentProcess()->GetSwitchValueNative( | 45 std::string value(CommandLine::ForCurrentProcess()->GetSwitchValueNative( |
| 48 switch_string)); | 46 switch_string)); |
| 49 if (value.empty()) | 47 if (value.empty()) |
| 50 return ScopedJavaLocalRef<jstring>(); | 48 return 0; |
| 51 return ConvertUTF8ToJavaString(env, value); | 49 // OK to release, JNI binding. |
| 50 return ConvertUTF8ToJavaString(env, value).Release(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 static void AppendSwitch(JNIEnv* env, jclass clazz, jstring jswitch) { | 53 static void AppendSwitch(JNIEnv* env, jclass clazz, jstring jswitch) { |
| 55 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); | 54 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); |
| 56 CommandLine::ForCurrentProcess()->AppendSwitch(switch_string); | 55 CommandLine::ForCurrentProcess()->AppendSwitch(switch_string); |
| 57 } | 56 } |
| 58 | 57 |
| 59 static void AppendSwitchWithValue(JNIEnv* env, jclass clazz, | 58 static void AppendSwitchWithValue(JNIEnv* env, jclass clazz, |
| 60 jstring jswitch, jstring jvalue) { | 59 jstring jswitch, jstring jvalue) { |
| 61 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); | 60 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 CommandLine::Init(0, NULL); | 77 CommandLine::Init(0, NULL); |
| 79 AppendJavaStringArrayToCommandLine(env, array, true); | 78 AppendJavaStringArrayToCommandLine(env, array, true); |
| 80 } | 79 } |
| 81 | 80 |
| 82 bool RegisterCommandLine(JNIEnv* env) { | 81 bool RegisterCommandLine(JNIEnv* env) { |
| 83 return RegisterNativesImpl(env); | 82 return RegisterNativesImpl(env); |
| 84 } | 83 } |
| 85 | 84 |
| 86 } // namespace android | 85 } // namespace android |
| 87 } // namespace base | 86 } // namespace base |
| OLD | NEW |