| 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 "content/browser/renderer_host/java/java_bound_object.h" | 5 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // LIVECONNECT_COMPLIANCE: Existing behavior is to return undefined. | 187 // LIVECONNECT_COMPLIANCE: Existing behavior is to return undefined. |
| 188 // Spec requires returning a null string. | 188 // Spec requires returning a null string. |
| 189 VOID_TO_NPVARIANT(*result); | 189 VOID_TO_NPVARIANT(*result); |
| 190 break; | 190 break; |
| 191 } | 191 } |
| 192 std::string str = | 192 std::string str = |
| 193 base::android::ConvertJavaStringToUTF8(scoped_java_string); | 193 base::android::ConvertJavaStringToUTF8(scoped_java_string); |
| 194 // Take a copy and pass ownership to the variant. We must allocate using | 194 // Take a copy and pass ownership to the variant. We must allocate using |
| 195 // NPN_MemAlloc, to match NPN_ReleaseVariant, which uses NPN_MemFree. | 195 // NPN_MemAlloc, to match NPN_ReleaseVariant, which uses NPN_MemFree. |
| 196 size_t length = str.length(); | 196 size_t length = str.length(); |
| 197 // TODO(thakis): This causes linker errors in a components build. Figure |
| 198 // out what to do. |
| 197 char* buffer = static_cast<char*>(NPN_MemAlloc(length)); | 199 char* buffer = static_cast<char*>(NPN_MemAlloc(length)); |
| 198 str.copy(buffer, length, 0); | 200 str.copy(buffer, length, 0); |
| 199 STRINGN_TO_NPVARIANT(buffer, length, *result); | 201 STRINGN_TO_NPVARIANT(buffer, length, *result); |
| 200 break; | 202 break; |
| 201 } | 203 } |
| 202 case JavaType::TypeObject: { | 204 case JavaType::TypeObject: { |
| 203 // If an exception was raised, we must clear it before calling most JNI | 205 // If an exception was raised, we must clear it before calling most JNI |
| 204 // methods. ScopedJavaLocalRef is liable to make such calls, so we test | 206 // methods. ScopedJavaLocalRef is liable to make such calls, so we test |
| 205 // first. | 207 // first. |
| 206 jobject java_object = env->CallObjectMethodA(object, id, parameters); | 208 jobject java_object = env->CallObjectMethodA(object, id, parameters); |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 if (!safe) | 863 if (!safe) |
| 862 continue; | 864 continue; |
| 863 } | 865 } |
| 864 | 866 |
| 865 JavaMethod* method = new JavaMethod(java_method); | 867 JavaMethod* method = new JavaMethod(java_method); |
| 866 methods_.insert(std::make_pair(method->name(), method)); | 868 methods_.insert(std::make_pair(method->name(), method)); |
| 867 } | 869 } |
| 868 } | 870 } |
| 869 | 871 |
| 870 } // namespace content | 872 } // namespace content |
| OLD | NEW |