| 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_dispatcher.h" | 5 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/common/gin_java_bridge_messages.h" | 9 #include "content/common/gin_java_bridge_messages.h" |
| 10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const std::string& method_name) { | 107 const std::string& method_name) { |
| 108 bool result; | 108 bool result; |
| 109 render_frame()->Send(new GinJavaBridgeHostMsg_HasMethod( | 109 render_frame()->Send(new GinJavaBridgeHostMsg_HasMethod( |
| 110 routing_id(), object_id, method_name, &result)); | 110 routing_id(), object_id, method_name, &result)); |
| 111 return result; | 111 return result; |
| 112 } | 112 } |
| 113 | 113 |
| 114 scoped_ptr<base::Value> GinJavaBridgeDispatcher::InvokeJavaMethod( | 114 scoped_ptr<base::Value> GinJavaBridgeDispatcher::InvokeJavaMethod( |
| 115 ObjectID object_id, | 115 ObjectID object_id, |
| 116 const std::string& method_name, | 116 const std::string& method_name, |
| 117 const base::ListValue& arguments) { | 117 const base::ListValue& arguments, |
| 118 std::string* error_message) { |
| 118 base::ListValue result_wrapper; | 119 base::ListValue result_wrapper; |
| 119 render_frame()->Send( | 120 render_frame()->Send( |
| 120 new GinJavaBridgeHostMsg_InvokeMethod(routing_id(), | 121 new GinJavaBridgeHostMsg_InvokeMethod(routing_id(), |
| 121 object_id, | 122 object_id, |
| 122 method_name, | 123 method_name, |
| 123 arguments, | 124 arguments, |
| 124 &result_wrapper)); | 125 &result_wrapper, |
| 126 error_message)); |
| 125 base::Value* result; | 127 base::Value* result; |
| 126 if (result_wrapper.Get(0, &result)) { | 128 if (result_wrapper.Get(0, &result)) { |
| 127 return scoped_ptr<base::Value>(result->DeepCopy()); | 129 return scoped_ptr<base::Value>(result->DeepCopy()); |
| 128 } else { | 130 } else { |
| 129 return scoped_ptr<base::Value>(); | 131 return scoped_ptr<base::Value>(); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { | 135 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { |
| 134 GinJavaBridgeObject* result = objects_.Lookup(object_id); | 136 GinJavaBridgeObject* result = objects_.Lookup(object_id); |
| 135 if (!result) { | 137 if (!result) { |
| 136 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); | 138 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); |
| 137 if (result) | 139 if (result) |
| 138 objects_.AddWithID(result, object_id); | 140 objects_.AddWithID(result, object_id); |
| 139 } | 141 } |
| 140 return result; | 142 return result; |
| 141 } | 143 } |
| 142 | 144 |
| 143 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted(ObjectID object_id) { | 145 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted(ObjectID object_id) { |
| 144 if (!objects_.Lookup(object_id)) | 146 if (!objects_.Lookup(object_id)) |
| 145 return; | 147 return; |
| 146 objects_.Remove(object_id); | 148 objects_.Remove(object_id); |
| 147 render_frame()->Send( | 149 render_frame()->Send( |
| 148 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); | 150 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); |
| 149 } | 151 } |
| 150 | 152 |
| 151 } // namespace content | 153 } // namespace content |
| OLD | NEW |