OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 break; | 146 break; |
147 case JavaType::TypeDouble: | 147 case JavaType::TypeDouble: |
148 DOUBLE_TO_NPVARIANT(env->CallDoubleMethodA(object, id, parameters), | 148 DOUBLE_TO_NPVARIANT(env->CallDoubleMethodA(object, id, parameters), |
149 result); | 149 result); |
150 break; | 150 break; |
151 case JavaType::TypeVoid: | 151 case JavaType::TypeVoid: |
152 env->CallVoidMethodA(object, id, parameters); | 152 env->CallVoidMethodA(object, id, parameters); |
153 VOID_TO_NPVARIANT(result); | 153 VOID_TO_NPVARIANT(result); |
154 break; | 154 break; |
155 case JavaType::TypeArray: | 155 case JavaType::TypeArray: |
156 // TODO(steveblock): Handle arrays | 156 // LIVECONNECT_COMPLIANCE: Don't call methods that return arrays, to |
157 // maintain existing behavior. We should call the method and convert the | |
bulach
2011/11/29 11:11:14
is the second sentence a TODO? also, I got comment
Steve Block
2011/11/29 11:18:00
It't not really a TODO. This file has many comment
bulach
2011/11/29 11:46:19
got it, thanks for the clarification!
| |
158 // result to a JavaScript array. | |
157 VOID_TO_NPVARIANT(result); | 159 VOID_TO_NPVARIANT(result); |
158 break; | 160 break; |
159 case JavaType::TypeString: { | 161 case JavaType::TypeString: { |
160 ScopedJavaLocalRef<jstring> java_string(env, static_cast<jstring>( | 162 ScopedJavaLocalRef<jstring> java_string(env, static_cast<jstring>( |
161 env->CallObjectMethodA(object, id, parameters))); | 163 env->CallObjectMethodA(object, id, parameters))); |
162 if (!java_string.obj()) { | 164 if (!java_string.obj()) { |
163 // LIVECONNECT_COMPLIANCE: Return undefined to maintain existing | 165 // LIVECONNECT_COMPLIANCE: Return undefined to maintain existing |
164 // behavior. We should return a null string. | 166 // behavior. We should return a null string. |
165 VOID_TO_NPVARIANT(result); | 167 VOID_TO_NPVARIANT(result); |
166 break; | 168 break; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 size_t num_methods = env->GetArrayLength(methods.obj()); | 607 size_t num_methods = env->GetArrayLength(methods.obj()); |
606 DCHECK(num_methods) << "Java objects always have public methods"; | 608 DCHECK(num_methods) << "Java objects always have public methods"; |
607 for (size_t i = 0; i < num_methods; ++i) { | 609 for (size_t i = 0; i < num_methods; ++i) { |
608 ScopedJavaLocalRef<jobject> java_method( | 610 ScopedJavaLocalRef<jobject> java_method( |
609 env, | 611 env, |
610 env->GetObjectArrayElement(methods.obj(), i)); | 612 env->GetObjectArrayElement(methods.obj(), i)); |
611 JavaMethod* method = new JavaMethod(java_method); | 613 JavaMethod* method = new JavaMethod(java_method); |
612 methods_.insert(std::make_pair(method->name(), method)); | 614 methods_.insert(std::make_pair(method->name(), method)); |
613 } | 615 } |
614 } | 616 } |
OLD | NEW |