| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/plugin/npobject_util.h" | 5 #include "chrome/plugin/npobject_util.h" |
| 6 | 6 |
| 7 #include "chrome/common/plugin_messages.h" | 7 #include "chrome/common/plugin_messages.h" |
| 8 #include "chrome/common/win_util.h" | 8 #include "chrome/common/win_util.h" |
| 9 #include "chrome/plugin/npobject_proxy.h" | 9 #include "chrome/plugin/npobject_proxy.h" |
| 10 #include "chrome/plugin/plugin_channel_base.h" | 10 #include "chrome/plugin/plugin_channel_base.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 break; | 164 break; |
| 165 case NPVariantType_Object: | 165 case NPVariantType_Object: |
| 166 { | 166 { |
| 167 if (variant.value.objectValue->_class == NPObjectProxy::npclass()) { | 167 if (variant.value.objectValue->_class == NPObjectProxy::npclass()) { |
| 168 param->type = NPVARIANT_PARAM_OBJECT_POINTER; | 168 param->type = NPVARIANT_PARAM_OBJECT_POINTER; |
| 169 param->npobject_pointer = | 169 param->npobject_pointer = |
| 170 NPObjectProxy::GetProxy(variant.value.objectValue)->npobject_ptr(); | 170 NPObjectProxy::GetProxy(variant.value.objectValue)->npobject_ptr(); |
| 171 // Don't release, because our original variant is the same as our proxy. | 171 // Don't release, because our original variant is the same as our proxy. |
| 172 release = false; | 172 release = false; |
| 173 } else { | 173 } else { |
| 174 // NPObjectStub adds its own reference to the NPObject it owns, so if we | 174 // The channel could be NULL if there was a channel error. The caller's |
| 175 // were supposed to release the corresponding variant (release==true), | 175 // Send call will fail anyways. |
| 176 // we should still do that. | 176 if (channel) { |
| 177 param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; | 177 // NPObjectStub adds its own reference to the NPObject it owns, so if |
| 178 int route_id = channel->GenerateRouteID(); | 178 // we were supposed to release the corresponding variant |
| 179 NPObjectStub* object_stub = new NPObjectStub( | 179 // (release==true), we should still do that. |
| 180 variant.value.objectValue, channel, route_id); | 180 param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; |
| 181 param->npobject_routing_id = route_id; | 181 int route_id = channel->GenerateRouteID(); |
| 182 param->npobject_pointer = variant.value.objectValue; | 182 NPObjectStub* object_stub = new NPObjectStub( |
| 183 variant.value.objectValue, channel, route_id); |
| 184 param->npobject_routing_id = route_id; |
| 185 param->npobject_pointer = variant.value.objectValue; |
| 186 } else { |
| 187 param->type = NPVARIANT_PARAM_VOID; |
| 188 } |
| 183 } | 189 } |
| 184 break; | 190 break; |
| 185 } | 191 } |
| 186 default: | 192 default: |
| 187 NOTREACHED(); | 193 NOTREACHED(); |
| 188 } | 194 } |
| 189 | 195 |
| 190 if (release) | 196 if (release) |
| 191 NPN_ReleaseVariantValue(const_cast<NPVariant*>(&variant)); | 197 NPN_ReleaseVariantValue(const_cast<NPVariant*>(&variant)); |
| 192 } | 198 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 case NPVARIANT_PARAM_OBJECT_POINTER: | 237 case NPVARIANT_PARAM_OBJECT_POINTER: |
| 232 result->type = NPVariantType_Object; | 238 result->type = NPVariantType_Object; |
| 233 result->value.objectValue = static_cast<NPObject*>(param.npobject_pointer)
; | 239 result->value.objectValue = static_cast<NPObject*>(param.npobject_pointer)
; |
| 234 NPN_RetainObject(result->value.objectValue); | 240 NPN_RetainObject(result->value.objectValue); |
| 235 break; | 241 break; |
| 236 default: | 242 default: |
| 237 NOTREACHED(); | 243 NOTREACHED(); |
| 238 } | 244 } |
| 239 } | 245 } |
| 240 | 246 |
| OLD | NEW |