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 // TODO(port) Just compile an empty file on posix so we can generate the | 7 #include "base/string_util.h" |
8 // libplugin target needed by other targets. This whole file does compile (see | |
9 // r9934), but it doesn't link because of undefined refs to files which aren't | |
10 // compiling yet (e.g. npobject_proxy stuff). | |
11 #if defined(OS_WIN) | |
12 | |
13 #include "chrome/common/plugin_messages.h" | 8 #include "chrome/common/plugin_messages.h" |
14 #include "chrome/common/win_util.h" | |
15 | |
16 #include "chrome/plugin/npobject_proxy.h" | 9 #include "chrome/plugin/npobject_proxy.h" |
17 #include "chrome/plugin/plugin_channel_base.h" | 10 #include "chrome/plugin/plugin_channel_base.h" |
18 #include "webkit/glue/plugins/nphostapi.h" | 11 #include "webkit/glue/plugins/nphostapi.h" |
19 #include "webkit/glue/plugins/plugin_host.h" | 12 #include "webkit/glue/plugins/plugin_host.h" |
20 #include "webkit/glue/webkit_glue.h" | 13 #include "webkit/glue/webkit_glue.h" |
21 | 14 |
22 // true if the current process is a plugin process, false if it's a renderer | 15 // true if the current process is a plugin process, false if it's a renderer |
23 // process. | 16 // process. |
24 static bool g_plugin_process; | 17 static bool g_plugin_process; |
25 | 18 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 void PatchNPNFunctions() { | 119 void PatchNPNFunctions() { |
127 g_plugin_process = true; | 120 g_plugin_process = true; |
128 NPNetscapeFuncs* funcs = GetHostFunctions(); | 121 NPNetscapeFuncs* funcs = GetHostFunctions(); |
129 NPAPI::PluginHost::Singleton()->PatchNPNetscapeFuncs(funcs); | 122 NPAPI::PluginHost::Singleton()->PatchNPNetscapeFuncs(funcs); |
130 } | 123 } |
131 | 124 |
132 bool IsPluginProcess() { | 125 bool IsPluginProcess() { |
133 return g_plugin_process; | 126 return g_plugin_process; |
134 } | 127 } |
135 | 128 |
136 #if defined(OS_WIN) | |
137 void CreateNPIdentifierParam(NPIdentifier id, NPIdentifier_Param* param) { | 129 void CreateNPIdentifierParam(NPIdentifier id, NPIdentifier_Param* param) { |
138 param->identifier = id; | 130 param->identifier = id; |
139 } | 131 } |
140 | 132 |
141 NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param) { | 133 NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param) { |
142 return param.identifier; | 134 return param.identifier; |
143 } | 135 } |
144 | 136 |
145 void CreateNPVariantParam(const NPVariant& variant, | 137 void CreateNPVariantParam(const NPVariant& variant, |
146 PluginChannelBase* channel, | 138 PluginChannelBase* channel, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 release = false; | 175 release = false; |
184 } else { | 176 } else { |
185 // The channel could be NULL if there was a channel error. The caller's | 177 // The channel could be NULL if there was a channel error. The caller's |
186 // Send call will fail anyways. | 178 // Send call will fail anyways. |
187 if (channel) { | 179 if (channel) { |
188 // NPObjectStub adds its own reference to the NPObject it owns, so if | 180 // NPObjectStub adds its own reference to the NPObject it owns, so if |
189 // we were supposed to release the corresponding variant | 181 // we were supposed to release the corresponding variant |
190 // (release==true), we should still do that. | 182 // (release==true), we should still do that. |
191 param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; | 183 param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; |
192 int route_id = channel->GenerateRouteID(); | 184 int route_id = channel->GenerateRouteID(); |
193 NPObjectStub* object_stub = new NPObjectStub( | 185 new NPObjectStub( |
194 variant.value.objectValue, channel, route_id, modal_dialog_event); | 186 variant.value.objectValue, channel, route_id, modal_dialog_event); |
195 param->npobject_routing_id = route_id; | 187 param->npobject_routing_id = route_id; |
196 param->npobject_pointer = | 188 param->npobject_pointer = |
197 reinterpret_cast<intptr_t>(variant.value.objectValue); | 189 reinterpret_cast<intptr_t>(variant.value.objectValue); |
198 } else { | 190 } else { |
199 param->type = NPVARIANT_PARAM_VOID; | 191 param->type = NPVARIANT_PARAM_VOID; |
200 } | 192 } |
201 } | 193 } |
202 break; | 194 break; |
203 } | 195 } |
(...skipping 24 matching lines...) Expand all Loading... |
228 result->type = NPVariantType_Int32; | 220 result->type = NPVariantType_Int32; |
229 result->value.intValue = param.int_value; | 221 result->value.intValue = param.int_value; |
230 break; | 222 break; |
231 case NPVARIANT_PARAM_DOUBLE: | 223 case NPVARIANT_PARAM_DOUBLE: |
232 result->type = NPVariantType_Double; | 224 result->type = NPVariantType_Double; |
233 result->value.doubleValue = param.double_value; | 225 result->value.doubleValue = param.double_value; |
234 break; | 226 break; |
235 case NPVARIANT_PARAM_STRING: | 227 case NPVARIANT_PARAM_STRING: |
236 result->type = NPVariantType_String; | 228 result->type = NPVariantType_String; |
237 result->value.stringValue.UTF8Characters = | 229 result->value.stringValue.UTF8Characters = |
238 static_cast<NPUTF8 *>(_strdup(param.string_value.c_str())); | 230 static_cast<NPUTF8 *>(base::strdup(param.string_value.c_str())); |
239 result->value.stringValue.UTF8Length = | 231 result->value.stringValue.UTF8Length = |
240 static_cast<int>(param.string_value.size()); | 232 static_cast<int>(param.string_value.size()); |
241 break; | 233 break; |
242 case NPVARIANT_PARAM_OBJECT_ROUTING_ID: | 234 case NPVARIANT_PARAM_OBJECT_ROUTING_ID: |
243 result->type = NPVariantType_Object; | 235 result->type = NPVariantType_Object; |
244 result->value.objectValue = | 236 result->value.objectValue = |
245 NPObjectProxy::Create(channel, | 237 NPObjectProxy::Create(channel, |
246 param.npobject_routing_id, | 238 param.npobject_routing_id, |
247 param.npobject_pointer, | 239 param.npobject_pointer, |
248 modal_dialog_event); | 240 modal_dialog_event); |
249 break; | 241 break; |
250 case NPVARIANT_PARAM_OBJECT_POINTER: | 242 case NPVARIANT_PARAM_OBJECT_POINTER: |
251 result->type = NPVariantType_Object; | 243 result->type = NPVariantType_Object; |
252 result->value.objectValue = | 244 result->value.objectValue = |
253 reinterpret_cast<NPObject*>(param.npobject_pointer); | 245 reinterpret_cast<NPObject*>(param.npobject_pointer); |
254 NPN_RetainObject(result->value.objectValue); | 246 NPN_RetainObject(result->value.objectValue); |
255 break; | 247 break; |
256 default: | 248 default: |
257 NOTREACHED(); | 249 NOTREACHED(); |
258 } | 250 } |
259 } | 251 } |
260 | |
261 #endif // defined(OS_WIN) | |
262 | |
263 #endif // defined(OS_WIN) | |
OLD | NEW |