2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #if USE(PLUGIN_HOST_PROCESS)
28 #import "NetscapePluginHostProxy.h"
31 #import <wtf/StdLibExtras.h>
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>
44 #import "WebKitPluginHost.h"
45 #import "WebKitPluginClientServer.h"
50 using namespace WebCore;
54 class PluginDestroyDeferrer {
56 PluginDestroyDeferrer(NetscapePluginInstanceProxy* proxy)
59 m_proxy->willCallPluginFunction();
62 ~PluginDestroyDeferrer()
64 m_proxy->didCallPluginFunction();
68 RefPtr<NetscapePluginInstanceProxy> m_proxy;
71 typedef HashMap<mach_port_t, NetscapePluginHostProxy*> PluginProxyMap;
72 static PluginProxyMap& pluginProxyMap()
74 DEFINE_STATIC_LOCAL(PluginProxyMap, pluginProxyMap, ());
76 return pluginProxyMap;
79 NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN)
80 : m_clientPort(clientPort)
81 , m_portSet(MACH_PORT_NULL)
82 , m_pluginHostPort(pluginHostPort)
84 , m_menuBarIsVisible(true)
85 , m_pluginHostPSN(pluginHostPSN)
87 pluginProxyMap().add(m_clientPort, this);
89 // FIXME: We should use libdispatch for this.
90 CFMachPortContext context = { 0, this, 0, 0, 0 };
91 m_deadNameNotificationPort.adoptCF(CFMachPortCreate(0, deadNameNotificationCallback, &context, 0));
94 mach_port_request_notification(mach_task_self(), pluginHostPort, MACH_NOTIFY_DEAD_NAME, 0,
95 CFMachPortGetPort(m_deadNameNotificationPort.get()), MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous);
96 ASSERT(previous == MACH_PORT_NULL);
98 RetainPtr<CFRunLoopSourceRef> deathPortSource(AdoptCF, CFMachPortCreateRunLoopSource(0, m_deadNameNotificationPort.get(), 0));
100 CFRunLoopAddSource(CFRunLoopGetCurrent(), deathPortSource.get(), kCFRunLoopDefaultMode);
102 #ifdef USE_LIBDISPATCH
103 // FIXME: Unfortunately we can't use a dispatch source here until <rdar://problem/6393180> has been resolved.
104 m_clientPortSource = dispatch_source_mig_create(m_clientPort, WKWebKitPluginClient_subsystem.maxsize, 0,
105 dispatch_get_main_queue(), WebKitPluginClient_server);
107 m_clientPortSource.adoptCF(WKCreateMIGServerSource((mig_subsystem_t)&WKWebKitPluginClient_subsystem, m_clientPort));
108 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), kCFRunLoopDefaultMode);
109 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSEventTrackingRunLoopMode);
113 NetscapePluginHostProxy::~NetscapePluginHostProxy()
115 pluginProxyMap().remove(m_clientPort);
119 mach_port_extract_member(mach_task_self(), m_clientPort, m_portSet);
120 mach_port_extract_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
121 mach_port_destroy(mach_task_self(), m_portSet);
124 ASSERT(m_clientPortSource);
125 #ifdef USE_LIBDISPATCH
126 dispatch_release(m_clientPortSource);
128 CFRunLoopSourceInvalidate(m_clientPortSource.get());
129 m_clientPortSource = 0;
133 void NetscapePluginHostProxy::pluginHostDied()
135 PluginInstanceMap instances;
136 m_instances.swap(instances);
138 PluginInstanceMap::const_iterator end = instances.end();
139 for (PluginInstanceMap::const_iterator it = instances.begin(); it != end; ++it)
140 it->second->pluginHostDied();
142 NetscapePluginHostManager::shared().pluginHostDied(this);
144 // The plug-in crashed while its menu bar was hidden. Make sure to show it.
145 if (!m_menuBarIsVisible)
146 setMenuBarVisible(true);
148 // The plug-in crashed while it had a modal dialog up.
155 void NetscapePluginHostProxy::addPluginInstance(NetscapePluginInstanceProxy* instance)
157 ASSERT(!m_instances.contains(instance->pluginID()));
159 m_instances.set(instance->pluginID(), instance);
162 void NetscapePluginHostProxy::removePluginInstance(NetscapePluginInstanceProxy* instance)
164 ASSERT(m_instances.get(instance->pluginID()) == instance);
166 m_instances.remove(instance->pluginID());
169 NetscapePluginInstanceProxy* NetscapePluginHostProxy::pluginInstance(uint32_t pluginID)
171 return m_instances.get(pluginID).get();
174 void NetscapePluginHostProxy::deadNameNotificationCallback(CFMachPortRef port, void *msg, CFIndex size, void *info)
176 ASSERT(msg && static_cast<mach_msg_header_t*>(msg)->msgh_id == MACH_NOTIFY_DEAD_NAME);
178 static_cast<NetscapePluginHostProxy*>(info)->pluginHostDied();
181 void NetscapePluginHostProxy::setMenuBarVisible(bool visible)
183 m_menuBarIsVisible = visible;
185 [NSMenu setMenuBarVisible:visible];
187 // Make ourselves the front app
188 ProcessSerialNumber psn;
189 GetCurrentProcess(&psn);
190 SetFrontProcess(&psn);
194 void NetscapePluginHostProxy::applicationDidBecomeActive()
196 SetFrontProcess(&m_pluginHostPSN);
199 void NetscapePluginHostProxy::beginModal()
201 ASSERT(!m_placeholderWindow);
202 ASSERT(!m_activationObserver);
204 m_placeholderWindow.adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
206 m_activationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification object:NSApp queue:nil
207 usingBlock:^(NSNotification *){ applicationDidBecomeActive(); }];
209 // We need to be able to get the setModal(false) call from the plug-in host.
210 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
212 [NSApp runModalForWindow:m_placeholderWindow.get()];
215 void NetscapePluginHostProxy::endModal()
217 ASSERT(m_placeholderWindow);
218 ASSERT(m_activationObserver);
220 [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
221 m_activationObserver = nil;
223 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
226 [m_placeholderWindow.get() orderOut:nil];
227 m_placeholderWindow = 0;
229 // Make ourselves the front process.
230 ProcessSerialNumber psn;
231 GetCurrentProcess(&psn);
232 SetFrontProcess(&psn);
236 void NetscapePluginHostProxy::setModal(bool modal)
238 if (modal == m_isModal)
249 bool NetscapePluginHostProxy::processRequests()
252 mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
253 mach_port_insert_member(mach_task_self(), m_clientPort, m_portSet);
254 mach_port_insert_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
259 mach_msg_header_t* msg = reinterpret_cast<mach_msg_header_t*>(buffer);
261 kern_return_t kr = mach_msg(msg, MACH_RCV_MSG, 0, sizeof(buffer), m_portSet, 0, MACH_PORT_NULL);
263 if (kr != KERN_SUCCESS) {
264 LOG_ERROR("Could not receive mach message, error %x", kr);
268 if (msg->msgh_local_port == m_clientPort) {
269 __ReplyUnion__WKWebKitPluginClient_subsystem reply;
270 mach_msg_header_t* replyHeader = reinterpret_cast<mach_msg_header_t*>(&reply);
272 if (WebKitPluginClient_server(msg, replyHeader) && replyHeader->msgh_remote_port != MACH_PORT_NULL) {
273 kr = mach_msg(replyHeader, MACH_SEND_MSG, replyHeader->msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
275 if (kr != KERN_SUCCESS) {
276 LOG_ERROR("Could not send mach message, error %x", kr);
284 if (msg->msgh_local_port == CFMachPortGetPort(m_deadNameNotificationPort.get())) {
285 ASSERT(msg->msgh_id == MACH_NOTIFY_DEAD_NAME);
290 ASSERT_NOT_REACHED();
294 } // namespace WebKit
296 using namespace WebKit;
298 // Helper class for deallocating data
299 class DataDeallocator {
301 DataDeallocator(data_t data, mach_msg_type_number_t dataLength)
302 : m_data(reinterpret_cast<vm_address_t>(data))
303 , m_dataLength(dataLength)
312 vm_deallocate(mach_task_self(), m_data, m_dataLength);
317 vm_size_t m_dataLength;
321 kern_return_t WKPCStatusText(mach_port_t clientPort, uint32_t pluginID, data_t text, mach_msg_type_number_t textCnt)
323 DataDeallocator deallocator(text, textCnt);
325 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
329 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
333 instanceProxy->status(text);
337 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,
338 data_t postData, mach_msg_type_number_t postDataLength, uint32_t flags,
339 uint16_t* outResult, uint32_t* outStreamID)
341 DataDeallocator urlDeallocator(url, urlLength);
342 DataDeallocator targetDeallocator(target, targetLength);
343 DataDeallocator postDataDeallocator(postData, postDataLength);
345 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
349 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
353 uint32_t streamID = 0;
354 NPError result = instanceProxy->loadURL(url, target, postData, postDataLength, static_cast<LoadURLFlags>(flags), streamID);
357 *outStreamID = streamID;
361 kern_return_t WKPCCancelLoadURL(mach_port_t clientPort, uint32_t pluginID, uint32_t streamID, int16_t reason)
363 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
367 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
371 HostedNetscapePluginStream* pluginStream = instanceProxy->pluginStream(streamID);
375 pluginStream->cancelLoad(reason);
379 kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, double x, double y, double width, double height)
381 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
385 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
389 instanceProxy->invalidateRect(x, y, width, height);
393 kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
395 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
399 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
403 instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::GetScriptableNPObjectReply(objectID));
407 kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t result)
409 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
413 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
417 instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanReply(result));
421 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)
423 DataDeallocator deallocator(resultData, resultLength);
425 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
429 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
433 RetainPtr<CFDataRef> result(AdoptCF, CFDataCreate(0, reinterpret_cast<UInt8*>(resultData), resultLength));
434 instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanAndDataReply(returnValue, result));
439 kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, kern_return_t result, uint32_t renderContextID, boolean_t useSoftwareRenderer)
441 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
445 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
449 instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::InstantiatePluginReply(result, renderContextID, useSoftwareRenderer));
453 kern_return_t WKPCGetWindowNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
455 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
459 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
464 if (!instanceProxy->getWindowNPObject(objectID))
467 *outObjectID = objectID;
471 kern_return_t WKPCGetPluginElementNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
473 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
477 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
482 if (!instanceProxy->getPluginElementNPObject(objectID))
485 *outObjectID = objectID;
489 kern_return_t WKPCReleaseObject(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID)
491 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
495 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
499 instanceProxy->releaseObject(objectID);
503 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)
505 DataDeallocator deallocator(scriptData, scriptLength);
507 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
511 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
515 PluginDestroyDeferrer deferrer(instanceProxy);
517 String script = String::fromUTF8WithLatin1Fallback(scriptData, scriptLength);
519 data_t resultData = 0;
520 mach_msg_type_number_t resultLength = 0;
521 boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength);
523 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
525 mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
530 kern_return_t WKPCGetStringIdentifier(mach_port_t clientPort, data_t name, mach_msg_type_number_t nameCnt, uint64_t* identifier)
532 DataDeallocator deallocator(name, nameCnt);
534 COMPILE_ASSERT(sizeof(*identifier) == sizeof(IdentifierRep*), identifier_sizes);
536 *identifier = reinterpret_cast<uint64_t>(IdentifierRep::get(name));
540 kern_return_t WKPCGetIntIdentifier(mach_port_t clientPort, int32_t value, uint64_t* identifier)
542 COMPILE_ASSERT(sizeof(*identifier) == sizeof(NPIdentifier), identifier_sizes);
544 *identifier = reinterpret_cast<uint64_t>(IdentifierRep::get(value));
548 static Identifier identifierFromIdentifierRep(IdentifierRep* identifier)
550 ASSERT(IdentifierRep::isValid(identifier));
551 ASSERT(identifier->isString());
553 const char* str = identifier->string();
554 return Identifier(JSDOMWindow::commonJSGlobalData(), String::fromUTF8WithLatin1Fallback(str, strlen(str)));
557 kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
558 data_t argumentsData, mach_msg_type_number_t argumentsLength)
560 DataDeallocator deallocator(argumentsData, argumentsLength);
562 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
566 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
570 PluginDestroyDeferrer deferrer(instanceProxy);
572 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
573 if (!IdentifierRep::isValid(identifier)) {
574 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false, 0, 0);
578 Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);
580 data_t resultData = 0;
581 mach_msg_type_number_t resultLength = 0;
582 boolean_t returnValue = instanceProxy->invoke(objectID, methodNameIdentifier, argumentsData, argumentsLength, resultData, resultLength);
584 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
586 mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
591 kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID,
592 data_t argumentsData, mach_msg_type_number_t argumentsLength)
594 DataDeallocator deallocator(argumentsData, argumentsLength);
596 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
600 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
604 PluginDestroyDeferrer deferrer(instanceProxy);
606 data_t resultData = 0;
607 mach_msg_type_number_t resultLength = 0;
608 boolean_t returnValue = instanceProxy->invokeDefault(objectID, argumentsData, argumentsLength, resultData, resultLength);
610 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
612 mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
617 kern_return_t WKPCConstruct(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID,
618 data_t argumentsData, mach_msg_type_number_t argumentsLength,
619 boolean_t* returnValue, data_t* resultData, mach_msg_type_number_t* resultLength)
621 DataDeallocator deallocator(argumentsData, argumentsLength);
623 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
627 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
631 PluginDestroyDeferrer deferrer(instanceProxy);
633 *returnValue = instanceProxy->construct(objectID, argumentsData, argumentsLength, *resultData, *resultLength);
638 kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
640 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
644 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
648 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
649 if (!IdentifierRep::isValid(identifier))
652 PluginDestroyDeferrer deferrer(instanceProxy);
654 data_t resultData = 0;
655 mach_msg_type_number_t resultLength = 0;
656 boolean_t returnValue;
658 if (identifier->isString()) {
659 Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);
660 returnValue = instanceProxy->getProperty(objectID, propertyNameIdentifier, resultData, resultLength);
662 returnValue = instanceProxy->setProperty(objectID, identifier->number(), resultData, resultLength);
664 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
666 mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
671 kern_return_t WKPCSetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier, data_t valueData, mach_msg_type_number_t valueLength, boolean_t* returnValue)
673 DataDeallocator deallocator(valueData, valueLength);
675 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
679 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
683 PluginDestroyDeferrer deferrer(instanceProxy);
685 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
686 if (!IdentifierRep::isValid(identifier))
687 *returnValue = false;
689 if (identifier->isString()) {
690 Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);
691 *returnValue = instanceProxy->setProperty(objectID, propertyNameIdentifier, valueData, valueLength);
693 *returnValue = instanceProxy->setProperty(objectID, identifier->number(), valueData, valueLength);
698 kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier, boolean_t* returnValue)
700 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
704 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
708 PluginDestroyDeferrer deferrer(instanceProxy);
710 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
711 if (!IdentifierRep::isValid(identifier))
714 if (identifier->isString()) {
715 Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);
716 *returnValue = instanceProxy->removeProperty(objectID, propertyNameIdentifier);
718 *returnValue = instanceProxy->removeProperty(objectID, identifier->number());
723 kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
725 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
729 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
733 PluginDestroyDeferrer deferrer(instanceProxy);
735 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
736 if (!IdentifierRep::isValid(identifier)) {
737 _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false);
741 boolean_t returnValue;
742 if (identifier->isString()) {
743 Identifier propertyNameIdentifier = identifierFromIdentifierRep(identifier);
744 returnValue = instanceProxy->hasProperty(objectID, propertyNameIdentifier);
746 returnValue = instanceProxy->hasProperty(objectID, identifier->number());
748 _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
753 kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
755 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
759 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
763 PluginDestroyDeferrer deferrer(instanceProxy);
765 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
766 if (!IdentifierRep::isValid(identifier)) {
767 _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false);
771 Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);
772 boolean_t returnValue = instanceProxy->hasMethod(objectID, methodNameIdentifier);
774 _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
779 kern_return_t WKPCIdentifierInfo(mach_port_t clientPort, uint64_t serverIdentifier, data_t* infoData, mach_msg_type_number_t* infoLength)
781 IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
782 if (!IdentifierRep::isValid(identifier))
786 if (identifier->isString()) {
787 const char* str = identifier->string();
788 info = [NSData dataWithBytesNoCopy:(void*)str length:strlen(str) freeWhenDone:NO];
790 info = [NSNumber numberWithInt:identifier->number()];
792 RetainPtr<NSData*> data = [NSPropertyListSerialization dataFromPropertyList:info format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
795 *infoLength = [data.get() length];
796 mig_allocate(reinterpret_cast<vm_address_t*>(infoData), *infoLength);
798 memcpy(*infoData, [data.get() bytes], *infoLength);
803 kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
805 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
809 NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
813 data_t resultData = 0;
814 mach_msg_type_number_t resultLength = 0;
815 boolean_t returnValue = instanceProxy->enumerate(objectID, resultData, resultLength);
817 _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
820 mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
825 kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVisible)
827 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
831 hostProxy->setMenuBarVisible(menuBarVisible);
836 kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal)
838 NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
842 hostProxy->setModal(modal);
847 #endif // USE(PLUGIN_HOST_PROCESS)