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_value.h" | 9 #include "content/common/android/gin_java_bridge_value.h" |
9 #include "content/public/renderer/v8_value_converter.h" | 10 #include "content/public/renderer/v8_value_converter.h" |
10 #include "content/renderer/java/gin_java_bridge_value_converter.h" | 11 #include "content/renderer/java/gin_java_bridge_value_converter.h" |
11 #include "gin/function_template.h" | 12 #include "gin/function_template.h" |
12 #include "third_party/WebKit/public/web/WebFrame.h" | 13 #include "third_party/WebKit/public/web/WebFrame.h" |
13 #include "third_party/WebKit/public/web/WebKit.h" | 14 #include "third_party/WebKit/public/web/WebKit.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 while (args->GetNext(&val)) { | 119 while (args->GetNext(&val)) { |
119 scoped_ptr<base::Value> arg(converter_->FromV8Value(val, context)); | 120 scoped_ptr<base::Value> arg(converter_->FromV8Value(val, context)); |
120 if (arg.get()) { | 121 if (arg.get()) { |
121 arguments.Append(arg.release()); | 122 arguments.Append(arg.release()); |
122 } else { | 123 } else { |
123 arguments.Append(base::Value::CreateNullValue()); | 124 arguments.Append(base::Value::CreateNullValue()); |
124 } | 125 } |
125 } | 126 } |
126 } | 127 } |
127 | 128 |
128 scoped_ptr<base::Value> result = | 129 GinJavaBridgeError error; |
129 dispatcher_->InvokeJavaMethod(object_id_, name, arguments); | 130 scoped_ptr<base::Value> result = dispatcher_->InvokeJavaMethod( |
| 131 object_id_, name, arguments, &error); |
130 if (!result.get()) { | 132 if (!result.get()) { |
131 args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( | 133 args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( |
132 args->isolate(), kMethodInvocationErrorMessage))); | 134 args->isolate(), GinJavaBridgeErrorToString(error)))); |
133 return v8::Undefined(args->isolate()); | 135 return v8::Undefined(args->isolate()); |
134 } | 136 } |
135 if (!result->IsType(base::Value::TYPE_BINARY)) { | 137 if (!result->IsType(base::Value::TYPE_BINARY)) { |
136 return converter_->ToV8Value(result.get(), | 138 return converter_->ToV8Value(result.get(), |
137 args->isolate()->GetCurrentContext()); | 139 args->isolate()->GetCurrentContext()); |
138 } | 140 } |
139 | 141 |
140 scoped_ptr<const GinJavaBridgeValue> gin_value = | 142 scoped_ptr<const GinJavaBridgeValue> gin_value = |
141 GinJavaBridgeValue::FromValue(result.get()); | 143 GinJavaBridgeValue::FromValue(result.get()); |
142 if (gin_value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)) { | 144 if (gin_value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)) { |
(...skipping 13 matching lines...) Expand all Loading... |
156 float float_value; | 158 float float_value; |
157 gin_value->GetAsNonFinite(&float_value); | 159 gin_value->GetAsNonFinite(&float_value); |
158 return v8::Number::New(args->isolate(), float_value); | 160 return v8::Number::New(args->isolate(), float_value); |
159 } | 161 } |
160 return v8::Undefined(args->isolate()); | 162 return v8::Undefined(args->isolate()); |
161 } | 163 } |
162 | 164 |
163 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; | 165 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; |
164 | 166 |
165 } // namespace content | 167 } // namespace content |
OLD | NEW |