OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/java/gin_java_bridge_object.h" | 5 #include "content/renderer/java/gin_java_bridge_object.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/common/android/gin_java_bridge_errors.h" | 8 #include "content/common/android/gin_java_bridge_errors.h" |
9 #include "content/common/android/gin_java_bridge_value.h" | 9 #include "content/common/android/gin_java_bridge_value.h" |
10 #include "content/public/renderer/v8_value_converter.h" | 10 #include "content/public/renderer/v8_value_converter.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 gin::ObjectTemplateBuilder GinJavaBridgeObject::GetObjectTemplateBuilder( | 77 gin::ObjectTemplateBuilder GinJavaBridgeObject::GetObjectTemplateBuilder( |
78 v8::Isolate* isolate) { | 78 v8::Isolate* isolate) { |
79 return gin::Wrappable<GinJavaBridgeObject>::GetObjectTemplateBuilder(isolate) | 79 return gin::Wrappable<GinJavaBridgeObject>::GetObjectTemplateBuilder(isolate) |
80 .AddNamedPropertyInterceptor(); | 80 .AddNamedPropertyInterceptor(); |
81 } | 81 } |
82 | 82 |
83 v8::Local<v8::Value> GinJavaBridgeObject::GetNamedProperty( | 83 v8::Local<v8::Value> GinJavaBridgeObject::GetNamedProperty( |
84 v8::Isolate* isolate, | 84 v8::Isolate* isolate, |
85 const std::string& property) { | 85 const std::string& property) { |
86 if (dispatcher_ && dispatcher_->HasJavaMethod(object_id_, property)) { | 86 std::map<std::string, bool>::iterator method_pos = |
| 87 known_methods_.find(property); |
| 88 if (method_pos == known_methods_.end()) { |
| 89 if (!dispatcher_) { |
| 90 return v8::Local<v8::Value>(); |
| 91 } |
| 92 known_methods_[property] = dispatcher_->HasJavaMethod(object_id_, property); |
| 93 } |
| 94 if (known_methods_[property]) { |
87 return gin::CreateFunctionTemplate( | 95 return gin::CreateFunctionTemplate( |
88 isolate, | 96 isolate, |
89 base::Bind(&GinJavaBridgeObject::InvokeMethod, | 97 base::Bind(&GinJavaBridgeObject::InvokeMethod, |
90 base::Unretained(this), | 98 base::Unretained(this), |
91 property))->GetFunction(); | 99 property))->GetFunction(); |
92 } else { | 100 } else { |
93 return v8::Local<v8::Value>(); | 101 return v8::Local<v8::Value>(); |
94 } | 102 } |
95 } | 103 } |
96 | 104 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 float float_value; | 166 float float_value; |
159 gin_value->GetAsNonFinite(&float_value); | 167 gin_value->GetAsNonFinite(&float_value); |
160 return v8::Number::New(args->isolate(), float_value); | 168 return v8::Number::New(args->isolate(), float_value); |
161 } | 169 } |
162 return v8::Undefined(args->isolate()); | 170 return v8::Undefined(args->isolate()); |
163 } | 171 } |
164 | 172 |
165 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; | 173 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; |
166 | 174 |
167 } // namespace content | 175 } // namespace content |
OLD | NEW |