OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child/npobject_util.h" | 5 #include "content/child/npobject_util.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/child/np_channel_base.h" | 8 #include "content/child/np_channel_base.h" |
9 #include "content/child/npobject_proxy.h" | 9 #include "content/child/npobject_proxy.h" |
10 #include "content/child/plugin_messages.h" | 10 #include "content/child/plugin_messages.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 variant.value.objectValue); | 197 variant.value.objectValue); |
198 if (route_id != MSG_ROUTING_NONE) { | 198 if (route_id != MSG_ROUTING_NONE) { |
199 param->npobject_routing_id = route_id; | 199 param->npobject_routing_id = route_id; |
200 } else { | 200 } else { |
201 route_id = channel->GenerateRouteID(); | 201 route_id = channel->GenerateRouteID(); |
202 new NPObjectStub( | 202 new NPObjectStub( |
203 variant.value.objectValue, channel, route_id, render_view_id, | 203 variant.value.objectValue, channel, route_id, render_view_id, |
204 page_url); | 204 page_url); |
205 param->npobject_routing_id = route_id; | 205 param->npobject_routing_id = route_id; |
206 } | 206 } |
| 207 |
| 208 // Include the object's owner. |
| 209 NPP owner = WebBindings::getObjectOwner(variant.value.objectValue); |
| 210 param->npobject_owner_id = |
| 211 channel->GetExistingRouteForNPObjectOwner(owner); |
207 } else { | 212 } else { |
208 param->type = NPVARIANT_PARAM_VOID; | 213 param->type = NPVARIANT_PARAM_VOID; |
209 } | 214 } |
210 } | 215 } |
211 break; | 216 break; |
212 } | 217 } |
213 default: | 218 default: |
214 NOTREACHED(); | 219 NOTREACHED(); |
215 } | 220 } |
216 | 221 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 break; | 257 break; |
253 } | 258 } |
254 case NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID: { | 259 case NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID: { |
255 result->type = NPVariantType_Object; | 260 result->type = NPVariantType_Object; |
256 NPObject* object = | 261 NPObject* object = |
257 channel->GetExistingNPObjectProxy(param.npobject_routing_id); | 262 channel->GetExistingNPObjectProxy(param.npobject_routing_id); |
258 if (object) { | 263 if (object) { |
259 WebBindings::retainObject(object); | 264 WebBindings::retainObject(object); |
260 result->value.objectValue = object; | 265 result->value.objectValue = object; |
261 } else { | 266 } else { |
| 267 NPP owner = |
| 268 channel->GetExistingNPObjectOwner(param.npobject_owner_id); |
| 269 // TODO(wez): Once NPObject tracking lands in Blink, check |owner| and |
| 270 // return NPVariantType_Void if it is NULL. |
262 result->value.objectValue = | 271 result->value.objectValue = |
263 NPObjectProxy::Create(channel, | 272 NPObjectProxy::Create(channel, |
264 param.npobject_routing_id, | 273 param.npobject_routing_id, |
265 render_view_id, | 274 render_view_id, |
266 page_url); | 275 page_url, |
| 276 owner); |
267 } | 277 } |
268 break; | 278 break; |
269 } | 279 } |
270 case NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID: { | 280 case NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID: { |
271 NPObjectBase* npobject_base = | 281 NPObjectBase* npobject_base = |
272 channel->GetNPObjectListenerForRoute(param.npobject_routing_id); | 282 channel->GetNPObjectListenerForRoute(param.npobject_routing_id); |
273 if (!npobject_base) { | 283 if (!npobject_base) { |
274 DLOG(WARNING) << "Invalid routing id passed in" | 284 DLOG(WARNING) << "Invalid routing id passed in" |
275 << param.npobject_routing_id; | 285 << param.npobject_routing_id; |
276 return false; | 286 return false; |
277 } | 287 } |
278 | 288 |
279 DCHECK(npobject_base->GetUnderlyingNPObject() != NULL); | 289 DCHECK(npobject_base->GetUnderlyingNPObject() != NULL); |
280 | 290 |
281 result->type = NPVariantType_Object; | 291 result->type = NPVariantType_Object; |
282 result->value.objectValue = npobject_base->GetUnderlyingNPObject(); | 292 result->value.objectValue = npobject_base->GetUnderlyingNPObject(); |
283 WebBindings::retainObject(result->value.objectValue); | 293 WebBindings::retainObject(result->value.objectValue); |
284 break; | 294 break; |
285 } | 295 } |
286 default: | 296 default: |
287 NOTREACHED(); | 297 NOTREACHED(); |
288 } | 298 } |
289 return true; | 299 return true; |
290 } | 300 } |
291 | 301 |
292 } // namespace content | 302 } // namespace content |
OLD | NEW |