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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/common/gin_java_bridge_messages.h" | 10 #include "content/common/gin_java_bridge_messages.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 bool GinJavaBridgeDispatcher::HasJavaMethod(ObjectID object_id, | 87 bool GinJavaBridgeDispatcher::HasJavaMethod(ObjectID object_id, |
88 const std::string& method_name) { | 88 const std::string& method_name) { |
89 bool result; | 89 bool result; |
90 render_frame()->Send(new GinJavaBridgeHostMsg_HasMethod( | 90 render_frame()->Send(new GinJavaBridgeHostMsg_HasMethod( |
91 routing_id(), object_id, method_name, &result)); | 91 routing_id(), object_id, method_name, &result)); |
92 return result; | 92 return result; |
93 } | 93 } |
94 | 94 |
95 scoped_ptr<base::Value> GinJavaBridgeDispatcher::InvokeJavaMethod( | 95 std::unique_ptr<base::Value> GinJavaBridgeDispatcher::InvokeJavaMethod( |
96 ObjectID object_id, | 96 ObjectID object_id, |
97 const std::string& method_name, | 97 const std::string& method_name, |
98 const base::ListValue& arguments, | 98 const base::ListValue& arguments, |
99 GinJavaBridgeError* error) { | 99 GinJavaBridgeError* error) { |
100 base::ListValue result_wrapper; | 100 base::ListValue result_wrapper; |
101 render_frame()->Send( | 101 render_frame()->Send( |
102 new GinJavaBridgeHostMsg_InvokeMethod(routing_id(), | 102 new GinJavaBridgeHostMsg_InvokeMethod(routing_id(), |
103 object_id, | 103 object_id, |
104 method_name, | 104 method_name, |
105 arguments, | 105 arguments, |
106 &result_wrapper, | 106 &result_wrapper, |
107 error)); | 107 error)); |
108 base::Value* result; | 108 base::Value* result; |
109 if (result_wrapper.Get(0, &result)) { | 109 if (result_wrapper.Get(0, &result)) { |
110 return scoped_ptr<base::Value>(result->DeepCopy()); | 110 return std::unique_ptr<base::Value>(result->DeepCopy()); |
111 } else { | 111 } else { |
112 return scoped_ptr<base::Value>(); | 112 return std::unique_ptr<base::Value>(); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { | 116 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { |
117 GinJavaBridgeObject* result = objects_.Lookup(object_id); | 117 GinJavaBridgeObject* result = objects_.Lookup(object_id); |
118 if (!result) { | 118 if (!result) { |
119 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); | 119 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); |
120 if (result) | 120 if (result) |
121 objects_.AddWithID(result, object_id); | 121 objects_.AddWithID(result, object_id); |
122 } | 122 } |
123 return result; | 123 return result; |
124 } | 124 } |
125 | 125 |
126 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted( | 126 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted( |
127 GinJavaBridgeObject* object) { | 127 GinJavaBridgeObject* object) { |
128 int object_id = object->object_id(); | 128 int object_id = object->object_id(); |
129 // Ignore cleaning up of old object wrappers. | 129 // Ignore cleaning up of old object wrappers. |
130 if (objects_.Lookup(object_id) != object) return; | 130 if (objects_.Lookup(object_id) != object) return; |
131 objects_.Remove(object_id); | 131 objects_.Remove(object_id); |
132 render_frame()->Send( | 132 render_frame()->Send( |
133 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); | 133 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); |
134 } | 134 } |
135 | 135 |
136 } // namespace content | 136 } // namespace content |
OLD | NEW |