diff options
author | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 10:47:30 +0000 |
---|---|---|
committer | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 10:47:30 +0000 |
commit | 197e294b2219a52d2e01ab80b05bf610e0b13f1c (patch) | |
tree | 7120fd7bb7da4e5b0a5a3b89dee2807d3ba93700 /content/renderer | |
parent | 76dfe8860ddbfc23e727a0ebc14f714c35044808 (diff) | |
download | chromium_src-197e294b2219a52d2e01ab80b05bf610e0b13f1c.zip chromium_src-197e294b2219a52d2e01ab80b05bf610e0b13f1c.tar.gz chromium_src-197e294b2219a52d2e01ab80b05bf610e0b13f1c.tar.bz2 |
[Android] Java Bridge with Gin: implement Java Bridge dispatcher
This patch adds implementation for GinJavaBridgeDispatcherHost class, which
is responsible for serving JB requests from renderers, and fulfilling
them with help of GinJavaBoundObject instances.
This patch also enables passing a error message for method invocation
errors back to renderers, so they can use it when raising JavaScript
exceptions.
BUG=355644
Review URL: https://codereview.chromium.org/345753003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/java/gin_java_bridge_dispatcher.cc | 6 | ||||
-rw-r--r-- | content/renderer/java/gin_java_bridge_dispatcher.h | 4 | ||||
-rw-r--r-- | content/renderer/java/gin_java_bridge_object.cc | 8 |
3 files changed, 12 insertions, 6 deletions
diff --git a/content/renderer/java/gin_java_bridge_dispatcher.cc b/content/renderer/java/gin_java_bridge_dispatcher.cc index 88d502e..9b999f2 100644 --- a/content/renderer/java/gin_java_bridge_dispatcher.cc +++ b/content/renderer/java/gin_java_bridge_dispatcher.cc @@ -114,14 +114,16 @@ bool GinJavaBridgeDispatcher::HasJavaMethod(ObjectID object_id, scoped_ptr<base::Value> GinJavaBridgeDispatcher::InvokeJavaMethod( ObjectID object_id, const std::string& method_name, - const base::ListValue& arguments) { + const base::ListValue& arguments, + GinJavaBridgeError* error) { base::ListValue result_wrapper; render_frame()->Send( new GinJavaBridgeHostMsg_InvokeMethod(routing_id(), object_id, method_name, arguments, - &result_wrapper)); + &result_wrapper, + error)); base::Value* result; if (result_wrapper.Get(0, &result)) { return scoped_ptr<base::Value>(result->DeepCopy()); diff --git a/content/renderer/java/gin_java_bridge_dispatcher.h b/content/renderer/java/gin_java_bridge_dispatcher.h index 13c6777..efbd19f 100644 --- a/content/renderer/java/gin_java_bridge_dispatcher.h +++ b/content/renderer/java/gin_java_bridge_dispatcher.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/values.h" +#include "content/common/android/gin_java_bridge_errors.h" #include "content/public/renderer/render_frame_observer.h" namespace blink { @@ -50,7 +51,8 @@ class GinJavaBridgeDispatcher bool HasJavaMethod(ObjectID object_id, const std::string& method_name); scoped_ptr<base::Value> InvokeJavaMethod(ObjectID object_id, const std::string& method_name, - const base::ListValue& arguments); + const base::ListValue& arguments, + GinJavaBridgeError* error); GinJavaBridgeObject* GetObject(ObjectID object_id); void OnGinJavaBridgeObjectDeleted(ObjectID object_id); diff --git a/content/renderer/java/gin_java_bridge_object.cc b/content/renderer/java/gin_java_bridge_object.cc index a153f2a..d2a2b60 100644 --- a/content/renderer/java/gin_java_bridge_object.cc +++ b/content/renderer/java/gin_java_bridge_object.cc @@ -5,6 +5,7 @@ #include "content/renderer/java/gin_java_bridge_object.h" #include "base/strings/utf_string_conversions.h" +#include "content/common/android/gin_java_bridge_errors.h" #include "content/common/android/gin_java_bridge_value.h" #include "content/public/renderer/v8_value_converter.h" #include "content/renderer/java/gin_java_bridge_value_converter.h" @@ -125,11 +126,12 @@ v8::Handle<v8::Value> GinJavaBridgeObject::InvokeMethod( } } - scoped_ptr<base::Value> result = - dispatcher_->InvokeJavaMethod(object_id_, name, arguments); + GinJavaBridgeError error; + scoped_ptr<base::Value> result = dispatcher_->InvokeJavaMethod( + object_id_, name, arguments, &error); if (!result.get()) { args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( - args->isolate(), kMethodInvocationErrorMessage))); + args->isolate(), GinJavaBridgeErrorToString(error)))); return v8::Undefined(args->isolate()); } if (!result->IsType(base::Value::TYPE_BINARY)) { |