summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm')
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm118
1 files changed, 85 insertions, 33 deletions
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
index 836277c..b437012 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
@@ -89,15 +89,16 @@ static PluginProxyMap& pluginProxyMap()
return pluginProxyMap;
}
+unsigned NetscapePluginHostProxy::s_processingRequests;
+
NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods)
: m_clientPort(clientPort)
, m_portSet(MACH_PORT_NULL)
, m_pluginHostPort(pluginHostPort)
, m_isModal(false)
, m_menuBarIsVisible(true)
- , m_fullScreenWindowIsShowing(false)
+ , m_fullscreenWindowIsShowing(false)
, m_pluginHostPSN(pluginHostPSN)
- , m_processingRequests(0)
, m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods)
{
pluginProxyMap().add(m_clientPort, this);
@@ -184,7 +185,9 @@ void NetscapePluginHostProxy::removePluginInstance(NetscapePluginInstanceProxy*
NetscapePluginInstanceProxy* NetscapePluginHostProxy::pluginInstance(uint32_t pluginID)
{
- return m_instances.get(pluginID).get();
+ NetscapePluginInstanceProxy* result = m_instances.get(pluginID).get();
+ ASSERT(!result || result->hostProxy() == this);
+ return result;
}
void NetscapePluginHostProxy::deadNameNotificationCallback(CFMachPortRef port, void *msg, CFIndex size, void *info)
@@ -202,12 +205,12 @@ void NetscapePluginHostProxy::setMenuBarVisible(bool visible)
[NSMenu setMenuBarVisible:visible];
}
-void NetscapePluginHostProxy::didEnterFullScreen() const
+void NetscapePluginHostProxy::didEnterFullscreen() const
{
SetFrontProcess(&m_pluginHostPSN);
}
-void NetscapePluginHostProxy::didExitFullScreen() const
+void NetscapePluginHostProxy::didExitFullscreen() const
{
// If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode.
@@ -223,16 +226,16 @@ void NetscapePluginHostProxy::didExitFullScreen() const
SetFrontProcess(&currentProcess);
}
-void NetscapePluginHostProxy::setFullScreenWindowIsShowing(bool isShowing)
+void NetscapePluginHostProxy::setFullscreenWindowIsShowing(bool isShowing)
{
- if (m_fullScreenWindowIsShowing == isShowing)
+ if (m_fullscreenWindowIsShowing == isShowing)
return;
- m_fullScreenWindowIsShowing = isShowing;
- if (m_fullScreenWindowIsShowing)
- didEnterFullScreen();
+ m_fullscreenWindowIsShowing = isShowing;
+ if (m_fullscreenWindowIsShowing)
+ didEnterFullscreen();
else
- didExitFullScreen();
+ didExitFullscreen();
}
@@ -294,7 +297,7 @@ void NetscapePluginHostProxy::setModal(bool modal)
bool NetscapePluginHostProxy::processRequests()
{
- m_processingRequests++;
+ s_processingRequests++;
if (!m_portSet) {
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
@@ -310,7 +313,7 @@ bool NetscapePluginHostProxy::processRequests()
if (kr != KERN_SUCCESS) {
LOG_ERROR("Could not receive mach message, error %x", kr);
- m_processingRequests--;
+ s_processingRequests--;
return false;
}
@@ -323,24 +326,24 @@ bool NetscapePluginHostProxy::processRequests()
if (kr != KERN_SUCCESS) {
LOG_ERROR("Could not send mach message, error %x", kr);
- m_processingRequests--;
+ s_processingRequests--;
return false;
}
}
- m_processingRequests--;
+ s_processingRequests--;
return true;
}
if (msg->msgh_local_port == CFMachPortGetPort(m_deadNameNotificationPort.get())) {
ASSERT(msg->msgh_id == MACH_NOTIFY_DEAD_NAME);
pluginHostDied();
- m_processingRequests--;
+ s_processingRequests--;
return false;
}
ASSERT_NOT_REACHED();
- m_processingRequests--;
+ s_processingRequests--;
return false;
}
@@ -437,7 +440,7 @@ kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, doub
if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID))
instanceProxy->invalidateRect(x, y, width, height);
return KERN_SUCCESS;
- }
+ }
// Defer the work
CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{
@@ -578,7 +581,11 @@ kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t r
data_t resultData = 0;
mach_msg_type_number_t resultLength = 0;
boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength, allowPopups);
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
@@ -610,7 +617,7 @@ static Identifier identifierFromIdentifierRep(IdentifierRep* identifier)
ASSERT(identifier->isString());
const char* str = identifier->string();
- return Identifier(JSDOMWindow::commonJSGlobalData(), String::fromUTF8WithLatin1Fallback(str, strlen(str)));
+ return Identifier(JSDOMWindow::commonJSGlobalData(), stringToUString(String::fromUTF8WithLatin1Fallback(str, strlen(str))));
}
kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
@@ -637,7 +644,11 @@ kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t req
data_t resultData = 0;
mach_msg_type_number_t resultLength = 0;
boolean_t returnValue = instanceProxy->invoke(objectID, methodNameIdentifier, argumentsData, argumentsLength, resultData, resultLength);
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
@@ -663,7 +674,11 @@ kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint3
data_t resultData = 0;
mach_msg_type_number_t resultLength = 0;
boolean_t returnValue = instanceProxy->invokeDefault(objectID, argumentsData, argumentsLength, resultData, resultLength);
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
@@ -701,7 +716,7 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
if (!instanceProxy)
return KERN_FAILURE;
-
+
IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
if (!IdentifierRep::isValid(identifier))
return KERN_FAILURE;
@@ -717,7 +732,11 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
returnValue = instanceProxy->getProperty(objectID, propertyNameIdentifier, resultData, resultLength);
} else
returnValue = instanceProxy->setProperty(objectID, identifier->number(), resultData, resultLength);
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
@@ -750,6 +769,10 @@ kern_return_t WKPCSetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
} else
result = instanceProxy->setProperty(objectID, identifier->number(), valueData, valueLength);
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result);
return KERN_SUCCESS;
@@ -778,6 +801,10 @@ kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint
} else
result = instanceProxy->removeProperty(objectID, identifier->number());
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result);
return KERN_SUCCESS;
@@ -805,7 +832,11 @@ kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
returnValue = instanceProxy->hasProperty(objectID, propertyNameIdentifier);
} else
returnValue = instanceProxy->hasProperty(objectID, identifier->number());
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
return KERN_SUCCESS;
@@ -830,6 +861,10 @@ kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t
Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);
boolean_t returnValue = instanceProxy->hasMethod(objectID, methodNameIdentifier);
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
return KERN_SUCCESS;
@@ -872,7 +907,11 @@ kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t
data_t resultData = 0;
mach_msg_type_number_t resultLength = 0;
boolean_t returnValue = instanceProxy->enumerate(objectID, resultData, resultLength);
-
+
+ hostProxy = instanceProxy->hostProxy();
+ if (!hostProxy)
+ return KERN_FAILURE;
+
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
@@ -892,13 +931,13 @@ kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVis
return KERN_SUCCESS;
}
-kern_return_t WKPCSetFullScreenWindowIsShowing(mach_port_t clientPort, boolean_t fullScreenWindowIsShowing)
+kern_return_t WKPCSetFullscreenWindowIsShowing(mach_port_t clientPort, boolean_t fullscreenWindowIsShowing)
{
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
- hostProxy->setFullScreenWindowIsShowing(fullScreenWindowIsShowing);
+ hostProxy->setFullscreenWindowIsShowing(fullscreenWindowIsShowing);
return KERN_SUCCESS;
}
@@ -908,9 +947,18 @@ kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal)
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
-
- hostProxy->setModal(modal);
-
+
+ if (!hostProxy->isProcessingRequests()) {
+ hostProxy->setModal(modal);
+ return KERN_SUCCESS;
+ }
+
+ // Defer the work
+ CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{
+ if (NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort))
+ hostProxy->setModal(modal);
+ });
+
return KERN_SUCCESS;
}
@@ -1090,7 +1138,7 @@ kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mac
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
-
+
NSOpenPanel *sheet = [NSOpenPanel openPanel];
NSDictionary *panelState = [NSPropertyListSerialization propertyListFromData:[NSData dataWithBytes:panelData length:panelDataLength]
mutabilityOption:NSPropertyListImmutable
@@ -1114,7 +1162,11 @@ kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mac
[sheet setRequiredFileType:[panelState objectForKey:@"requiredFileType"]];
[sheet setTitle:[panelState objectForKey:@"title"]];
[sheet runModal];
-
+
+ NetscapePluginHostProxy* newHostProxy = pluginProxyMap().get(clientPort);
+ if (newHostProxy != hostProxy)
+ return KERN_FAILURE;
+
NSDictionary *ret = [NSDictionary dictionaryWithObjectsAndKeys:
[sheet filenames], @"filenames",
WKNoteOpenPanelFiles([sheet filenames]), @"extensions",