initial import
[vuplus_webkit] / Source / WebKit / mac / Plugins / Hosted / NetscapePluginHostProxy.mm
1 /*
2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #if USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API)
27
28 #import "NetscapePluginHostProxy.h"
29
30 #import <mach/mach.h>
31 #import <wtf/StdLibExtras.h>
32
33 #import "HostedNetscapePluginStream.h"
34 #import "NetscapePluginHostManager.h"
35 #import "NetscapePluginInstanceProxy.h"
36 #import "WebFrameInternal.h"
37 #import "WebHostedNetscapePluginView.h"
38 #import "WebKitSystemInterface.h"
39 #import <WebCore/Frame.h>
40 #import <WebCore/IdentifierRep.h>
41 #import <WebCore/ScriptController.h>
42
43 extern "C" {
44 #import "WebKitPluginHost.h"
45 #import "WebKitPluginClientServer.h"
46 }
47
48 using namespace std;
49 using namespace JSC;
50 using namespace WebCore;
51
52 @interface WebPlaceholderModalWindow : NSWindow 
53 @end
54
55 @implementation WebPlaceholderModalWindow
56 // Prevent NSApp from calling requestUserAttention: when the window is shown 
57 // modally, even if the app is inactive. See 6823049.
58 - (BOOL)_wantsUserAttention
59 {
60     return NO;   
61 }
62 @end
63
64 namespace WebKit {
65
66 class PluginDestroyDeferrer {
67 public:
68     PluginDestroyDeferrer(NetscapePluginInstanceProxy* proxy)
69         : m_proxy(proxy)
70     {
71         m_proxy->willCallPluginFunction();
72     }
73     
74     ~PluginDestroyDeferrer()
75     {
76         bool stopped;
77         m_proxy->didCallPluginFunction(stopped);
78     }
79
80 private:
81     RefPtr<NetscapePluginInstanceProxy> m_proxy;
82 };
83
84 typedef HashMap<mach_port_t, NetscapePluginHostProxy*> PluginProxyMap;
85 static PluginProxyMap& pluginProxyMap()
86 {
87     DEFINE_STATIC_LOCAL(PluginProxyMap, pluginProxyMap, ());
88     
89     return pluginProxyMap;
90 }
91
92 unsigned NetscapePluginHostProxy::s_processingRequests;
93
94 NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods)
95     : m_clientPort(clientPort)
96     , m_portSet(MACH_PORT_NULL)
97     , m_pluginHostPort(pluginHostPort)
98     , m_isModal(false)
99     , m_menuBarIsVisible(true)
100     , m_fullscreenWindowIsShowing(false)
101     , m_pluginHostPSN(pluginHostPSN)
102     , m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods)
103 {
104     pluginProxyMap().add(m_clientPort, this);
105     
106     // FIXME: We should use libdispatch for this.
107     CFMachPortContext context = { 0, this, 0, 0, 0 };
108     m_deadNameNotificationPort.adoptCF(CFMachPortCreate(0, deadNameNotificationCallback, &context, 0));
109
110     mach_port_t previous;
111     mach_port_request_notification(mach_task_self(), pluginHostPort, MACH_NOTIFY_DEAD_NAME, 0, 
112                                    CFMachPortGetPort(m_deadNameNotificationPort.get()), MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous);
113     ASSERT(previous == MACH_PORT_NULL);
114     
115     RetainPtr<CFRunLoopSourceRef> deathPortSource(AdoptCF, CFMachPortCreateRunLoopSource(0, m_deadNameNotificationPort.get(), 0));
116     
117     CFRunLoopAddSource(CFRunLoopGetCurrent(), deathPortSource.get(), kCFRunLoopDefaultMode);
118     
119     m_clientPortSource.adoptCF(WKCreateMIGServerSource((mig_subsystem_t)&WKWebKitPluginClient_subsystem, m_clientPort));
120     CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), kCFRunLoopDefaultMode);
121     CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSEventTrackingRunLoopMode);
122 }
123
124 NetscapePluginHostProxy::~NetscapePluginHostProxy()
125 {
126     pluginProxyMap().remove(m_clientPort);
127
128     // Free the port set
129     if (m_portSet) {
130         mach_port_extract_member(mach_task_self(), m_clientPort, m_portSet);
131         mach_port_extract_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
132         mach_port_destroy(mach_task_self(), m_portSet);
133     }
134     
135     ASSERT(m_clientPortSource);
136     CFRunLoopSourceInvalidate(m_clientPortSource.get());
137     m_clientPortSource = 0;
138 }
139
140 void NetscapePluginHostProxy::pluginHostDied()
141 {
142     PluginInstanceMap instances;    
143     m_instances.swap(instances);
144   
145     PluginInstanceMap::const_iterator end = instances.end();
146     for (PluginInstanceMap::const_iterator it = instances.begin(); it != end; ++it)
147         it->second->pluginHostDied();
148     
149     NetscapePluginHostManager::shared().pluginHostDied(this);
150     
151     // The plug-in crashed while its menu bar was hidden. Make sure to show it.
152     if (!m_menuBarIsVisible)
153         setMenuBarVisible(true);
154
155     // The plug-in crashed while it had a modal dialog up.
156     if (m_isModal)
157         endModal();
158     
159     delete this;
160 }
161     
162 void NetscapePluginHostProxy::addPluginInstance(NetscapePluginInstanceProxy* instance)
163 {
164     ASSERT(!m_instances.contains(instance->pluginID()));
165     
166     m_instances.set(instance->pluginID(), instance);
167 }
168     
169 void NetscapePluginHostProxy::removePluginInstance(NetscapePluginInstanceProxy* instance)
170 {
171     ASSERT(m_instances.get(instance->pluginID()) == instance);
172
173     m_instances.remove(instance->pluginID());
174 }
175
176 NetscapePluginInstanceProxy* NetscapePluginHostProxy::pluginInstance(uint32_t pluginID)
177 {
178     NetscapePluginInstanceProxy* result = m_instances.get(pluginID).get();
179     ASSERT(!result || result->hostProxy() == this);
180     return result;
181 }
182
183 void NetscapePluginHostProxy::deadNameNotificationCallback(CFMachPortRef port, void *msg, CFIndex size, void *info)
184 {
185     ASSERT(msg);
186     ASSERT(static_cast<mach_msg_header_t*>(msg)->msgh_id == MACH_NOTIFY_DEAD_NAME);
187     
188     static_cast<NetscapePluginHostProxy*>(info)->pluginHostDied();
189 }
190
191 void NetscapePluginHostProxy::setMenuBarVisible(bool visible)
192 {
193     m_menuBarIsVisible = visible;
194
195     [NSMenu setMenuBarVisible:visible];
196 }
197
198 void NetscapePluginHostProxy::didEnterFullscreen() const
199 {
200     SetFrontProcess(&m_pluginHostPSN);
201 }
202
203 void NetscapePluginHostProxy::didExitFullscreen() const
204 {
205     // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode.
206
207     ProcessSerialNumber frontProcess;
208     GetFrontProcess(&frontProcess);
209     Boolean isSameProcess = 0;
210     SameProcess(&frontProcess, &m_pluginHostPSN, &isSameProcess);
211     if (!isSameProcess)
212         return;
213
214     ProcessSerialNumber currentProcess;
215     GetCurrentProcess(&currentProcess);
216     SetFrontProcess(&currentProcess);
217 }
218
219 void NetscapePluginHostProxy::setFullscreenWindowIsShowing(bool isShowing)
220 {
221     if (m_fullscreenWindowIsShowing == isShowing)
222         return;
223
224     m_fullscreenWindowIsShowing = isShowing;
225     if (m_fullscreenWindowIsShowing)
226         didEnterFullscreen();
227     else
228         didExitFullscreen();
229
230 }
231
232 void NetscapePluginHostProxy::applicationDidBecomeActive()
233 {
234     SetFrontProcess(&m_pluginHostPSN);
235 }
236
237 void NetscapePluginHostProxy::beginModal()
238 {
239     ASSERT(!m_placeholderWindow);
240     ASSERT(!m_activationObserver);
241     
242     m_placeholderWindow.adoptNS([[WebPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
243     
244     m_activationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification object:NSApp queue:nil
245                                                                          usingBlock:^(NSNotification *){ applicationDidBecomeActive(); }];
246     
247     // We need to be able to get the setModal(false) call from the plug-in host.
248     CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
249     
250     [NSApp runModalForWindow:m_placeholderWindow.get()];
251     
252     [m_placeholderWindow.get() orderOut:nil];
253     m_placeholderWindow = 0;
254 }
255     
256 void NetscapePluginHostProxy::endModal()
257 {
258     ASSERT(m_placeholderWindow);
259     ASSERT(m_activationObserver);
260     
261     [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
262     m_activationObserver = nil;
263     
264     CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
265     
266     [NSApp stopModal];
267     
268     // Make ourselves the front process.
269     ProcessSerialNumber psn;
270     GetCurrentProcess(&psn);
271     SetFrontProcess(&psn);            
272 }
273     
274
275 void NetscapePluginHostProxy::setModal(bool modal)
276 {
277     if (modal == m_isModal) 
278         return;
279     
280     m_isModal = modal;
281     
282     if (m_isModal)
283         beginModal();
284     else
285         endModal();
286 }
287     
288 bool NetscapePluginHostProxy::processRequests()
289 {
290     s_processingRequests++;
291
292    if (!m_portSet) {
293         mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
294         mach_port_insert_member(mach_task_self(), m_clientPort, m_portSet);
295         mach_port_insert_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
296     }
297     
298     char buffer[4096];
299     
300     mach_msg_header_t* msg = reinterpret_cast<mach_msg_header_t*>(buffer);
301     
302     kern_return_t kr = mach_msg(msg, MACH_RCV_MSG, 0, sizeof(buffer), m_portSet, 0, MACH_PORT_NULL);
303     
304     if (kr != KERN_SUCCESS) {
305         LOG_ERROR("Could not receive mach message, error %x", kr);
306         s_processingRequests--;
307         return false;
308     }
309     
310     if (msg->msgh_local_port == m_clientPort) {
311         __ReplyUnion__WKWebKitPluginClient_subsystem reply;
312         mach_msg_header_t* replyHeader = reinterpret_cast<mach_msg_header_t*>(&reply);
313         
314         if (WebKitPluginClient_server(msg, replyHeader) && replyHeader->msgh_remote_port != MACH_PORT_NULL) {
315             kr = mach_msg(replyHeader, MACH_SEND_MSG, replyHeader->msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
316             
317             if (kr != KERN_SUCCESS) {
318                 LOG_ERROR("Could not send mach message, error %x", kr);
319                 s_processingRequests--;
320                 return false;
321             }
322         }
323         
324         s_processingRequests--;
325         return true;
326     }
327     
328     if (msg->msgh_local_port == CFMachPortGetPort(m_deadNameNotificationPort.get())) {
329         ASSERT(msg->msgh_id == MACH_NOTIFY_DEAD_NAME);
330         pluginHostDied();
331         s_processingRequests--;
332         return false;
333     }
334     
335     ASSERT_NOT_REACHED();
336     s_processingRequests--;
337     return false;
338 }
339
340 } // namespace WebKit
341
342 using namespace WebKit;
343
344 // Helper class for deallocating data
345 class DataDeallocator {
346 public:
347     DataDeallocator(data_t data, mach_msg_type_number_t dataLength)
348         : m_data(reinterpret_cast<vm_address_t>(data))
349         , m_dataLength(dataLength)
350     {
351     }
352     
353     ~DataDeallocator()
354     {
355         if (!m_data)
356             return;
357         
358         vm_deallocate(mach_task_self(), m_data, m_dataLength);
359     }
360     
361 private:
362     vm_address_t m_data;
363     vm_size_t m_dataLength;
364 };
365
366 // MiG callbacks
367 kern_return_t WKPCStatusText(mach_port_t clientPort, uint32_t pluginID, data_t text, mach_msg_type_number_t textCnt)
368 {
369     DataDeallocator deallocator(text, textCnt);
370     
371     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
372     if (!hostProxy)
373         return KERN_FAILURE;
374     
375     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
376     if (!instanceProxy)
377         return KERN_FAILURE;
378     
379     instanceProxy->status(text);
380     return KERN_SUCCESS;
381 }
382
383 kern_return_t WKPCLoadURL(mach_port_t clientPort, uint32_t pluginID, data_t url, mach_msg_type_number_t urlLength, data_t target, mach_msg_type_number_t targetLength, 
384                           data_t postData, mach_msg_type_number_t postDataLength, uint32_t flags,
385                           uint16_t* outResult, uint32_t* outStreamID)
386 {
387     DataDeallocator urlDeallocator(url, urlLength);
388     DataDeallocator targetDeallocator(target, targetLength);
389     DataDeallocator postDataDeallocator(postData, postDataLength);
390
391     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
392     if (!hostProxy)
393         return KERN_FAILURE;
394     
395     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
396     if (!instanceProxy)
397         return KERN_FAILURE;
398
399     uint32_t streamID = 0;
400     NPError result = instanceProxy->loadURL(url, target, postData, postDataLength, static_cast<LoadURLFlags>(flags), streamID);
401     
402     *outResult = result;
403     *outStreamID = streamID;
404     return KERN_SUCCESS;
405 }
406
407 kern_return_t WKPCCancelLoadURL(mach_port_t clientPort, uint32_t pluginID, uint32_t streamID, int16_t reason)
408 {
409     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
410     if (!hostProxy)
411         return KERN_FAILURE;
412     
413     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
414     if (!instanceProxy)
415         return KERN_FAILURE;
416     
417     if (!instanceProxy->cancelStreamLoad(streamID, reason))
418         return KERN_FAILURE;
419     
420     return KERN_SUCCESS;
421 }
422
423 kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, double x, double y, double width, double height)
424 {
425     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
426     if (!hostProxy)
427         return KERN_SUCCESS;
428
429     if (!hostProxy->isProcessingRequests()) {
430         if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID))
431             instanceProxy->invalidateRect(x, y, width, height);
432         return KERN_SUCCESS;
433     }
434
435     // Defer the work
436     CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{
437         if (NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort)) {
438             if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID))
439                 instanceProxy->invalidateRect(x, y, width, height);
440         }
441     });
442
443     return KERN_SUCCESS;
444 }
445
446 kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
447 {
448     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
449     if (!hostProxy)
450         return KERN_FAILURE;
451     
452     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
453     if (!instanceProxy)
454         return KERN_FAILURE;
455
456     instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::GetScriptableNPObjectReply(objectID));
457     return KERN_SUCCESS;
458 }
459
460 kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t result)
461 {
462     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
463     if (!hostProxy)
464         return KERN_FAILURE;
465     
466     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
467     if (!instanceProxy)
468         return KERN_FAILURE;
469     
470     instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanReply(result));
471     return KERN_SUCCESS;
472 }
473
474 kern_return_t WKPCBooleanAndDataReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t returnValue, data_t resultData, mach_msg_type_number_t resultLength)
475 {
476     DataDeallocator deallocator(resultData, resultLength);
477
478     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
479     if (!hostProxy)
480         return KERN_FAILURE;
481     
482     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
483     if (!instanceProxy)
484         return KERN_FAILURE;
485
486     RetainPtr<CFDataRef> result(AdoptCF, CFDataCreate(0, reinterpret_cast<UInt8*>(resultData), resultLength));
487     instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanAndDataReply(returnValue, result));
488     
489     return KERN_SUCCESS;
490 }
491
492 kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, kern_return_t result, uint32_t renderContextID, uint32_t rendererType)
493 {
494     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
495     if (!hostProxy)
496         return KERN_FAILURE;
497     
498     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
499     if (!instanceProxy)
500         return KERN_FAILURE;
501
502     instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::InstantiatePluginReply(result, renderContextID, static_cast<RendererType>(rendererType)));
503     return KERN_SUCCESS;
504 }
505
506 kern_return_t WKPCGetWindowNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
507 {
508     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
509     if (!hostProxy)
510         return KERN_FAILURE;
511     
512     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
513     if (!instanceProxy)
514         return KERN_FAILURE;
515
516     uint32_t objectID;
517     if (!instanceProxy->getWindowNPObject(objectID))
518         return KERN_FAILURE;
519     
520     *outObjectID = objectID;    
521     return KERN_SUCCESS;
522 }
523
524 kern_return_t WKPCGetPluginElementNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
525 {
526     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
527     if (!hostProxy)
528         return KERN_FAILURE;
529     
530     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
531     if (!instanceProxy)
532         return KERN_FAILURE;
533     
534     uint32_t objectID;
535     if (!instanceProxy->getPluginElementNPObject(objectID))
536         return KERN_FAILURE;
537     
538     *outObjectID = objectID;    
539     return KERN_SUCCESS;
540 }
541
542 kern_return_t WKPCForgetBrowserObject(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID)
543 {
544     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
545     if (!hostProxy)
546         return KERN_FAILURE;
547     
548     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
549     if (!instanceProxy)
550         return KERN_FAILURE;
551
552     return instanceProxy->forgetBrowserObjectID(objectID) ? KERN_SUCCESS : KERN_FAILURE;
553 }
554
555 kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, data_t scriptData, mach_msg_type_number_t scriptLength, boolean_t allowPopups)
556 {
557     DataDeallocator deallocator(scriptData, scriptLength);
558
559     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
560     if (!hostProxy)
561         return KERN_FAILURE;
562     
563     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
564     if (!instanceProxy)
565         return KERN_FAILURE;
566
567     PluginDestroyDeferrer deferrer(instanceProxy);
568     
569     String script = String::fromUTF8WithLatin1Fallback(scriptData, scriptLength);
570     
571     data_t resultData = 0;
572     mach_msg_type_number_t resultLength = 0;
573     boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength, allowPopups);
574
575     hostProxy = instanceProxy->hostProxy();
576     if (!hostProxy)
577         return KERN_FAILURE;
578
579     _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
580     if (resultData)
581         mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
582         
583     return KERN_SUCCESS;
584 }
585
586 kern_return_t WKPCGetStringIdentifier(mach_port_t clientPort, data_t name, mach_msg_type_number_t nameCnt, uint64_t* identifier)
587 {
588     DataDeallocator deallocator(name, nameCnt);
589
590     COMPILE_ASSERT(sizeof(*identifier) == sizeof(IdentifierRep*), identifier_sizes);
591     
592     *identifier = reinterpret_cast<uint64_t>(IdentifierRep::get(name));
593     return KERN_SUCCESS;
594 }
595
596 kern_return_t WKPCGetIntIdentifier(mach_port_t clientPort, int32_t value, uint64_t* identifier)
597 {
598     COMPILE_ASSERT(sizeof(*identifier) == sizeof(NPIdentifier), identifier_sizes);
599     
600     *identifier = reinterpret_cast<uint64_t>(IdentifierRep::get(value));
601     return KERN_SUCCESS;
602 }
603
604 static Identifier identifierFromIdentifierRep(IdentifierRep* identifier)
605 {
606     ASSERT(IdentifierRep::isValid(identifier));
607     ASSERT(identifier->isString());
608   
609     const char* str = identifier->string();    
610     return Identifier(JSDOMWindow::commonJSGlobalData(), stringToUString(String::fromUTF8WithLatin1Fallback(str, strlen(str))));
611 }
612
613 kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
614                          data_t argumentsData, mach_msg_type_number_t argumentsLength) 
615 {
616     DataDeallocator deallocator(argumentsData, argumentsLength);
617
618     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
619     if (!hostProxy)
620         return KERN_FAILURE;
621     
622     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
623     if (!instanceProxy)
624         return KERN_FAILURE;
625
626     PluginDestroyDeferrer deferrer(instanceProxy);
627     
628     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
629     if (!IdentifierRep::isValid(identifier))
630         return KERN_FAILURE;
631
632     Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);
633
634     data_t resultData = 0;
635     mach_msg_type_number_t resultLength = 0;
636     boolean_t returnValue = instanceProxy->invoke(objectID, methodNameIdentifier, argumentsData, argumentsLength, resultData, resultLength);
637
638     hostProxy = instanceProxy->hostProxy();
639     if (!hostProxy)
640         return KERN_FAILURE;
641
642     _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
643     if (resultData)
644         mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
645     
646     return KERN_SUCCESS;
647 }
648
649 kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID,
650                                 data_t argumentsData, mach_msg_type_number_t argumentsLength)
651 {
652     DataDeallocator deallocator(argumentsData, argumentsLength);
653
654     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
655     if (!hostProxy)
656         return KERN_FAILURE;
657     
658     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
659     if (!instanceProxy)
660         return KERN_FAILURE;
661
662     PluginDestroyDeferrer deferrer(instanceProxy);
663
664     data_t resultData = 0;
665     mach_msg_type_number_t resultLength = 0;
666     boolean_t returnValue = instanceProxy->invokeDefault(objectID, argumentsData, argumentsLength, resultData, resultLength);
667
668     hostProxy = instanceProxy->hostProxy();
669     if (!hostProxy)
670         return KERN_FAILURE;
671
672     _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
673     if (resultData)
674         mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
675     
676     return KERN_SUCCESS;
677 }
678
679 kern_return_t WKPCConstruct(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID,
680                             data_t argumentsData, mach_msg_type_number_t argumentsLength, 
681                             boolean_t* returnValue, data_t* resultData, mach_msg_type_number_t* resultLength)
682 {
683     DataDeallocator deallocator(argumentsData, argumentsLength);
684
685     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
686     if (!hostProxy)
687         return KERN_FAILURE;
688     
689     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
690     if (!instanceProxy)
691         return KERN_FAILURE;
692
693     PluginDestroyDeferrer deferrer(instanceProxy);
694
695     *returnValue = instanceProxy->construct(objectID, argumentsData, argumentsLength, *resultData, *resultLength);
696     
697     return KERN_SUCCESS;
698 }
699
700 kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
701 {
702     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
703     if (!hostProxy)
704         return KERN_FAILURE;
705     
706     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
707     if (!instanceProxy)
708         return KERN_FAILURE;
709
710     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
711     if (!IdentifierRep::isValid(identifier))
712         return KERN_FAILURE;
713     
714     PluginDestroyDeferrer deferrer(instanceProxy);
715
716     data_t resultData = 0;
717     mach_msg_type_number_t resultLength = 0;
718     boolean_t returnValue;
719     
720     if (identifier->isString()) {
721         Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);        
722         returnValue = instanceProxy->getProperty(objectID, propertyNameIdentifier, resultData, resultLength);
723     } else 
724         returnValue = instanceProxy->setProperty(objectID, identifier->number(), resultData, resultLength);
725
726     hostProxy = instanceProxy->hostProxy();
727     if (!hostProxy)
728         return KERN_FAILURE;
729
730     _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
731     if (resultData)
732         mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
733     
734     return KERN_SUCCESS;
735 }
736
737 kern_return_t WKPCSetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier, data_t valueData, mach_msg_type_number_t valueLength)
738 {
739     DataDeallocator deallocator(valueData, valueLength);
740
741     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
742     if (!hostProxy)
743         return KERN_FAILURE;
744     
745     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
746     if (!instanceProxy)
747         return KERN_FAILURE;
748
749     PluginDestroyDeferrer deferrer(instanceProxy);
750
751     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
752     if (!IdentifierRep::isValid(identifier))
753         return KERN_FAILURE;
754
755     bool result;
756     if (identifier->isString()) {
757         Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);        
758         result = instanceProxy->setProperty(objectID, propertyNameIdentifier, valueData, valueLength);
759     } else 
760         result = instanceProxy->setProperty(objectID, identifier->number(), valueData, valueLength);
761
762     hostProxy = instanceProxy->hostProxy();
763     if (!hostProxy)
764         return KERN_FAILURE;
765
766     _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result);
767
768     return KERN_SUCCESS;
769 }
770
771 kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
772 {
773     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
774     if (!hostProxy)
775         return KERN_FAILURE;
776     
777     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
778     if (!instanceProxy)
779         return KERN_FAILURE;
780     
781     PluginDestroyDeferrer deferrer(instanceProxy);
782
783     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
784     if (!IdentifierRep::isValid(identifier))
785         return KERN_FAILURE;
786
787     bool result;
788     if (identifier->isString()) {
789         Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);        
790         result = instanceProxy->removeProperty(objectID, propertyNameIdentifier);
791     } else 
792         result = instanceProxy->removeProperty(objectID, identifier->number());
793
794     hostProxy = instanceProxy->hostProxy();
795     if (!hostProxy)
796         return KERN_FAILURE;
797
798     _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result);
799
800     return KERN_SUCCESS;
801 }
802
803 kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
804 {
805     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
806     if (!hostProxy)
807         return KERN_FAILURE;
808     
809     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
810     if (!instanceProxy)
811         return KERN_FAILURE;
812     
813     PluginDestroyDeferrer deferrer(instanceProxy);
814
815     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
816     if (!IdentifierRep::isValid(identifier))
817         return KERN_FAILURE;
818     
819     boolean_t returnValue;
820     if (identifier->isString()) {
821         Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);        
822         returnValue = instanceProxy->hasProperty(objectID, propertyNameIdentifier);
823     } else 
824         returnValue = instanceProxy->hasProperty(objectID, identifier->number());
825
826     hostProxy = instanceProxy->hostProxy();
827     if (!hostProxy)
828         return KERN_FAILURE;
829
830     _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
831     
832     return KERN_SUCCESS;
833 }
834
835 kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
836 {
837     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
838     if (!hostProxy)
839         return KERN_FAILURE;
840     
841     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
842     if (!instanceProxy)
843         return KERN_FAILURE;
844     
845     PluginDestroyDeferrer deferrer(instanceProxy);
846
847     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
848     if (!IdentifierRep::isValid(identifier))
849         return KERN_FAILURE;
850     
851     Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);        
852     boolean_t returnValue = instanceProxy->hasMethod(objectID, methodNameIdentifier);
853
854     hostProxy = instanceProxy->hostProxy();
855     if (!hostProxy)
856         return KERN_FAILURE;
857
858     _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
859
860     return KERN_SUCCESS;
861 }
862
863 kern_return_t WKPCIdentifierInfo(mach_port_t clientPort, uint64_t serverIdentifier, data_t* infoData, mach_msg_type_number_t* infoLength)
864 {
865     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
866     if (!IdentifierRep::isValid(identifier))
867         return KERN_FAILURE;
868     
869     id info;
870     if (identifier->isString()) {
871         const char* str = identifier->string();
872         info = [NSData dataWithBytesNoCopy:(void*)str length:strlen(str) freeWhenDone:NO];
873     } else 
874         info = [NSNumber numberWithInt:identifier->number()];
875
876     RetainPtr<NSData*> data = [NSPropertyListSerialization dataFromPropertyList:info format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
877     ASSERT(data);
878     
879     *infoLength = [data.get() length];
880     mig_allocate(reinterpret_cast<vm_address_t*>(infoData), *infoLength);
881     
882     memcpy(*infoData, [data.get() bytes], *infoLength);
883     
884     return KERN_SUCCESS;
885 }
886
887 kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
888 {
889     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
890     if (!hostProxy)
891         return KERN_FAILURE;
892     
893     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
894     if (!instanceProxy)
895         return KERN_FAILURE;
896     
897     data_t resultData = 0;
898     mach_msg_type_number_t resultLength = 0;
899     boolean_t returnValue = instanceProxy->enumerate(objectID, resultData, resultLength);
900
901     hostProxy = instanceProxy->hostProxy();
902     if (!hostProxy)
903         return KERN_FAILURE;
904
905     _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
906     
907     if (resultData)
908         mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
909     
910     return KERN_SUCCESS;
911 }
912
913 kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVisible)
914 {
915     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
916     if (!hostProxy)
917         return KERN_FAILURE;
918
919     hostProxy->setMenuBarVisible(menuBarVisible);
920
921     return KERN_SUCCESS;
922 }
923
924 kern_return_t WKPCSetFullscreenWindowIsShowing(mach_port_t clientPort, boolean_t fullscreenWindowIsShowing)
925 {
926     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
927     if (!hostProxy)
928         return KERN_FAILURE;
929
930     hostProxy->setFullscreenWindowIsShowing(fullscreenWindowIsShowing);
931
932     return KERN_SUCCESS;
933 }
934
935 kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal)
936 {
937     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
938     if (!hostProxy)
939         return KERN_FAILURE;
940
941     if (!hostProxy->isProcessingRequests()) {
942         hostProxy->setModal(modal);
943         return KERN_SUCCESS;
944     }
945
946     // Defer the work
947     CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{
948         if (NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort))
949             hostProxy->setModal(modal);
950     });
951
952     return KERN_SUCCESS;
953 }
954
955 kern_return_t WKPCGetCookies(mach_port_t clientPort, uint32_t pluginID,
956                              data_t urlData, mach_msg_type_number_t urlLength,
957                              boolean_t* returnValue, data_t* cookiesData, mach_msg_type_number_t* cookiesLength)
958 {
959     *cookiesData = 0;
960     *cookiesLength = 0;
961     
962     DataDeallocator deallocator(urlData, urlLength);
963     
964     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
965     if (!hostProxy)
966         return KERN_FAILURE;
967     
968     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
969     if (!instanceProxy)
970         return KERN_FAILURE;
971     
972     *returnValue = instanceProxy->getCookies(urlData, urlLength, *cookiesData, *cookiesLength);
973     
974     return KERN_SUCCESS;
975 }
976
977 kern_return_t WKPCGetProxy(mach_port_t clientPort, uint32_t pluginID,
978                            data_t urlData, mach_msg_type_number_t urlLength,
979                            boolean_t* returnValue, data_t* proxyData, mach_msg_type_number_t* proxyLength)
980 {
981     *proxyData = 0;
982     *proxyLength = 0;
983     
984     DataDeallocator deallocator(urlData, urlLength);
985     
986     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
987     if (!hostProxy)
988         return KERN_FAILURE;
989     
990     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
991     if (!instanceProxy)
992         return KERN_FAILURE;
993     
994     *returnValue = instanceProxy->getProxy(urlData, urlLength, *proxyData, *proxyLength);
995     
996     return KERN_SUCCESS;
997 }
998
999 kern_return_t WKPCSetCookies(mach_port_t clientPort, uint32_t pluginID,
1000                              data_t urlData, mach_msg_type_number_t urlLength,
1001                              data_t cookiesData, mach_msg_type_number_t cookiesLength,
1002                              boolean_t* returnValue)
1003 {
1004     DataDeallocator urlDeallocator(urlData, urlLength);
1005     DataDeallocator cookiesDeallocator(cookiesData, cookiesLength);
1006  
1007     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1008     if (!hostProxy)
1009         return KERN_FAILURE;
1010     
1011     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1012     if (!instanceProxy)
1013         return KERN_FAILURE;
1014
1015     *returnValue = instanceProxy->setCookies(urlData, urlLength, cookiesData, cookiesLength);
1016     return KERN_SUCCESS;
1017 }
1018
1019 kern_return_t WKPCGetAuthenticationInfo(mach_port_t clientPort, uint32_t pluginID,
1020                                         data_t protocolData, mach_msg_type_number_t protocolLength,
1021                                         data_t hostData, mach_msg_type_number_t hostLength,
1022                                         uint32_t port,
1023                                         data_t schemeData, mach_msg_type_number_t schemeLength,
1024                                         data_t realmData, mach_msg_type_number_t realmLength,
1025                                         boolean_t* returnValue,
1026                                         data_t* usernameData, mach_msg_type_number_t *usernameLength,
1027                                         data_t* passwordData, mach_msg_type_number_t *passwordLength)
1028 {
1029     DataDeallocator protocolDeallocator(protocolData, protocolLength);
1030     DataDeallocator hostDeallocator(hostData, hostLength);
1031     DataDeallocator schemeDeallocator(schemeData, schemeLength);
1032     DataDeallocator realmDeallocator(realmData, realmLength);
1033
1034     *usernameData = 0;
1035     *usernameLength = 0;
1036     *passwordData = 0;
1037     *passwordLength = 0;
1038     
1039     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1040     if (!hostProxy)
1041         return KERN_FAILURE;
1042     
1043     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1044     if (!instanceProxy)
1045         return KERN_FAILURE;
1046     
1047     *returnValue = instanceProxy->getAuthenticationInfo(protocolData, hostData, port, schemeData, realmData, *usernameData, *usernameLength, *passwordData, *passwordLength);
1048     
1049     return KERN_SUCCESS;
1050 }
1051
1052 kern_return_t WKPCConvertPoint(mach_port_t clientPort, uint32_t pluginID, 
1053                                double sourceX, double sourceY, uint32_t sourceSpace, 
1054                                uint32_t destSpace, boolean_t *returnValue, double *destX, double *destY)
1055 {
1056     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1057     if (!hostProxy)
1058         return KERN_FAILURE;
1059     
1060     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1061     if (!instanceProxy)
1062         return KERN_FAILURE;
1063
1064     *returnValue = instanceProxy->convertPoint(sourceX, sourceY, static_cast<NPCoordinateSpace>(sourceSpace), 
1065                                                *destX, *destY, static_cast<NPCoordinateSpace>(destSpace));
1066     return KERN_SUCCESS;
1067 }
1068
1069 kern_return_t WKPCCheckIfAllowedToLoadURL(mach_port_t clientPort, uint32_t pluginID, data_t urlData, mach_msg_type_number_t urlLength,
1070                                           data_t targetData, mach_msg_type_number_t targetLength, uint32_t *checkID)
1071 {
1072     DataDeallocator urlDeallocator(urlData, urlLength);
1073     DataDeallocator targetDeallocator(targetData, targetLength);
1074
1075     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1076     if (!hostProxy)
1077         return KERN_FAILURE;
1078     
1079     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1080     if (!instanceProxy)
1081         return KERN_FAILURE;
1082     
1083     *checkID = instanceProxy->checkIfAllowedToLoadURL(urlData, targetData);
1084     return KERN_SUCCESS;
1085 }
1086
1087 kern_return_t WKPCCancelCheckIfAllowedToLoadURL(mach_port_t clientPort, uint32_t pluginID, uint32_t checkID)
1088 {
1089     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1090     if (!hostProxy)
1091         return KERN_FAILURE;
1092     
1093     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1094     if (!instanceProxy)
1095         return KERN_FAILURE;
1096
1097     instanceProxy->cancelCheckIfAllowedToLoadURL(checkID);
1098     return KERN_SUCCESS;
1099 }
1100
1101 kern_return_t WKPCResolveURL(mach_port_t clientPort, uint32_t pluginID, data_t urlData, mach_msg_type_number_t urlLength,
1102                              data_t targetData, mach_msg_type_number_t targetLength,
1103                              data_t *resolvedURLData, mach_msg_type_number_t *resolvedURLLength)
1104 {
1105     DataDeallocator urlDeallocator(urlData, urlLength);
1106     DataDeallocator targetDeallocator(targetData, targetLength);
1107     
1108     *resolvedURLData = 0;
1109     *resolvedURLLength = 0;
1110     
1111     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
1112     if (!hostProxy)
1113         return KERN_FAILURE;
1114     
1115     NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
1116     if (!instanceProxy)
1117         return KERN_FAILURE;
1118     
1119     instanceProxy->resolveURL(urlData, targetData, *resolvedURLData, *resolvedURLLength);
1120     return KERN_SUCCESS;
1121 }
1122
1123 kern_return_t WKPCSetException(mach_port_t clientPort, data_t message, mach_msg_type_number_t messageCnt)
1124 {
1125     DataDeallocator deallocator(message, messageCnt);
1126
1127     NetscapePluginInstanceProxy::setGlobalException(String::fromUTF8WithLatin1Fallback(message, messageCnt));
1128
1129     return KERN_SUCCESS;
1130 }
1131
1132 #endif // USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API)