summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Plugins
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-08-11 17:01:47 +0100
committerBen Murdoch <benm@google.com>2009-08-11 18:21:02 +0100
commit0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch)
tree2943df35f62d885c89d01063cc528dd73b480fea /WebKit/mac/Plugins
parent7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff)
downloadexternal_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2
Merge in WebKit r47029.
Diffstat (limited to 'WebKit/mac/Plugins')
-rw-r--r--WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h11
-rw-r--r--WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm10
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h4
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm49
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h15
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm279
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h54
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm381
-rw-r--r--WebKit/mac/Plugins/Hosted/ProxyInstance.h22
-rw-r--r--WebKit/mac/Plugins/Hosted/ProxyInstance.mm87
-rw-r--r--WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h4
-rw-r--r--WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm104
-rw-r--r--WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs58
-rw-r--r--WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs35
-rw-r--r--WebKit/mac/Plugins/Hosted/WebKitPluginHostTypes.h2
-rw-r--r--WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm4
-rw-r--r--WebKit/mac/Plugins/WebBaseNetscapePluginView.h22
-rw-r--r--WebKit/mac/Plugins/WebBaseNetscapePluginView.mm279
-rw-r--r--WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.h46
-rw-r--r--WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.mm61
-rw-r--r--WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.h64
-rw-r--r--WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.mm48
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginEventHandler.h3
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.h5
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm13
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h5
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm22
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginPackage.mm14
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginView.h17
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginView.mm269
-rw-r--r--WebKit/mac/Plugins/WebNullPluginView.mm3
-rw-r--r--WebKit/mac/Plugins/WebPluginContainerCheck.h19
-rw-r--r--WebKit/mac/Plugins/WebPluginContainerCheck.mm32
-rw-r--r--WebKit/mac/Plugins/WebPluginController.h3
-rw-r--r--WebKit/mac/Plugins/WebPluginController.mm84
-rw-r--r--WebKit/mac/Plugins/WebPluginDatabase.mm11
-rw-r--r--WebKit/mac/Plugins/npapi.mm41
37 files changed, 1886 insertions, 294 deletions
diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
index 539372c..72e845b 100644
--- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
+++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
@@ -51,13 +51,18 @@ public:
{
return adoptRef(new HostedNetscapePluginStream(instance, streamID, request));
}
-
+ static PassRefPtr<HostedNetscapePluginStream> create(NetscapePluginInstanceProxy* instance, WebCore::FrameLoader* frameLoader)
+ {
+ return adoptRef(new HostedNetscapePluginStream(instance, frameLoader));
+ }
+
uint32_t streamID() const { return m_streamID; }
void startStreamWithResponse(NSURLResponse *response);
void didReceiveData(WebCore::NetscapePlugInStreamLoader*, const char* bytes, int length);
void didFinishLoading(WebCore::NetscapePlugInStreamLoader*);
-
+ void didFail(WebCore::NetscapePlugInStreamLoader*, const WebCore::ResourceError&);
+
void start();
void stop();
@@ -68,6 +73,7 @@ private:
void cancelLoad(NSError *);
HostedNetscapePluginStream(NetscapePluginInstanceProxy*, uint32_t streamID, NSURLRequest *);
+ HostedNetscapePluginStream(NetscapePluginInstanceProxy*, WebCore::FrameLoader*);
void startStream(NSURL *, long long expectedContentLength, NSDate *lastModifiedDate, NSString *mimeType, NSData *headers);
@@ -75,7 +81,6 @@ private:
// NetscapePlugInStreamLoaderClient methods.
void didReceiveResponse(WebCore::NetscapePlugInStreamLoader*, const WebCore::ResourceResponse&);
- void didFail(WebCore::NetscapePlugInStreamLoader*, const WebCore::ResourceError&);
bool wantsAllStreams() const;
RefPtr<NetscapePluginInstanceProxy> m_instance;
diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
index c2abc92..63e18a0 100644
--- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
+++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
@@ -57,6 +57,14 @@ HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstancePro
[m_request.get() _web_setHTTPReferrer:nil];
}
+HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstanceProxy* instance, WebCore::FrameLoader* frameLoader)
+ : m_instance(instance)
+ , m_streamID(1)
+ , m_isTerminated(false)
+ , m_frameLoader(frameLoader)
+{
+}
+
void HostedNetscapePluginStream::startStreamWithResponse(NSURLResponse *response)
{
didReceiveResponse(0, response);
@@ -152,7 +160,7 @@ void HostedNetscapePluginStream::didReceiveResponse(NetscapePlugInStreamLoader*,
[theHeaders appendBytes:"\0" length:1];
}
- startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r _webcore_MIMEType], theHeaders);
+ startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r MIMEType], theHeaders);
}
static NPReason reasonForError(NSError *error)
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
index d550dac..a1d9bad 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
@@ -43,12 +43,14 @@ class NetscapePluginHostManager {
public:
static NetscapePluginHostManager& shared();
- PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(WebNetscapePluginPackage *, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL);
+ PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(WebNetscapePluginPackage *, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame);
void pluginHostDied(NetscapePluginHostProxy*);
static void createPropertyListFile(WebNetscapePluginPackage *);
+ void didCreateWindow();
+
private:
NetscapePluginHostProxy* hostForPackage(WebNetscapePluginPackage *);
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
index 08a6d6a..4aa290a 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
@@ -29,6 +29,7 @@
#import "NetscapePluginHostProxy.h"
#import "NetscapePluginInstanceProxy.h"
+#import "WebLocalizableStrings.h"
#import "WebKitSystemInterface.h"
#import "WebNetscapePluginPackage.h"
#import <mach/mach_port.h>
@@ -74,17 +75,24 @@ NetscapePluginHostProxy* NetscapePluginHostManager::hostForPackage(WebNetscapePl
return result.first->second;
mach_port_t clientPort;
- if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort) != KERN_SUCCESS)
+ if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort) != KERN_SUCCESS) {
+ m_pluginHosts.remove(result.first);
return 0;
+ }
mach_port_t pluginHostPort;
ProcessSerialNumber pluginHostPSN;
if (!spawnPluginHost(package, clientPort, pluginHostPort, pluginHostPSN)) {
mach_port_destroy(mach_task_self(), clientPort);
+ m_pluginHosts.remove(result.first);
return 0;
}
- NetscapePluginHostProxy* hostProxy = new NetscapePluginHostProxy(clientPort, pluginHostPort, pluginHostPSN);
+ // Since Flash NPObjects add methods dynamically, we don't want to cache when a property/method doesn't exist
+ // on an object because it could be added later.
+ bool shouldCacheMissingPropertiesAndMethods = ![[[package bundle] bundleIdentifier] isEqualToString:@"com.macromedia.Flash Player.plugin"];
+
+ NetscapePluginHostProxy* hostProxy = new NetscapePluginHostProxy(clientPort, pluginHostPort, pluginHostPSN, shouldCacheMissingPropertiesAndMethods);
CFRetain(package);
result.first->second = hostProxy;
@@ -106,9 +114,12 @@ bool NetscapePluginHostManager::spawnPluginHost(WebNetscapePluginPackage *packag
NSString *pluginHostAppPath = [[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] pathForAuxiliaryExecutable:pluginHostAppName];
NSString *pluginHostAppExecutablePath = [[NSBundle bundleWithPath:pluginHostAppPath] executablePath];
+ RetainPtr<CFStringRef> localization(AdoptCF, WKCopyCFLocalizationPreferredName(NULL));
+
NSDictionary *launchProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
pluginHostAppExecutablePath, @"pluginHostPath",
[NSNumber numberWithInt:[package pluginHostArchitecture]], @"cpuType",
+ localization.get(), @"localization",
nil];
NSData *data = [NSPropertyListSerialization dataFromPropertyList:launchProperties format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
@@ -134,7 +145,10 @@ bool NetscapePluginHostManager::spawnPluginHost(WebNetscapePluginPackage *packag
return false;
}
- NSString *visibleName = [NSString stringWithFormat:@"%@ Plug-in Host - %@", [[NSProcessInfo processInfo] processName], [package filename]];
+ NSString *visibleName = [NSString stringWithFormat:UI_STRING("%@ (%@ Internet plug-in)",
+ "visible name of the plug-in host process. The first argument is the plug-in name "
+ "and the second argument is the application name."),
+ [[package filename] stringByDeletingPathExtension], [[NSProcessInfo processInfo] processName]];
NSDictionary *hostProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
visibleName, @"visibleName",
@@ -197,7 +211,7 @@ void NetscapePluginHostManager::pluginHostDied(NetscapePluginHostProxy* pluginHo
}
}
-PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(WebNetscapePluginPackage *pluginPackage, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL)
+PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(WebNetscapePluginPackage *pluginPackage, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame)
{
NetscapePluginHostProxy* hostProxy = hostForPackage(pluginPackage);
if (!hostProxy)
@@ -220,13 +234,18 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
if (sourceURL)
[properties.get() setObject:[sourceURL absoluteString] forKey:@"sourceURL"];
+ [properties.get() setObject:[NSNumber numberWithBool:fullFrame] forKey:@"fullFrame"];
+
NSData *data = [NSPropertyListSerialization dataFromPropertyList:properties.get() format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
ASSERT(data);
- RefPtr<NetscapePluginInstanceProxy> instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView);
+ RefPtr<NetscapePluginInstanceProxy> instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView, fullFrame);
uint32_t requestID = instance->nextRequestID();
kern_return_t kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
if (kr == MACH_SEND_INVALID_DEST) {
+ // Invalidate the instance.
+ instance->invalidate();
+
// The plug-in host must have died, but we haven't received the death notification yet.
pluginHostDied(hostProxy);
@@ -234,14 +253,14 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
hostProxy = hostForPackage(pluginPackage);
// Create a new instance.
- instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView);
+ instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView, fullFrame);
requestID = instance->nextRequestID();
kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
}
auto_ptr<NetscapePluginInstanceProxy::InstantiatePluginReply> reply = instance->waitForReply<NetscapePluginInstanceProxy::InstantiatePluginReply>(requestID);
if (!reply.get() || reply->m_resultCode != KERN_SUCCESS) {
- instance->invalidate();
+ instance->cleanup();
return 0;
}
@@ -278,6 +297,22 @@ void NetscapePluginHostManager::createPropertyListFile(WebNetscapePluginPackage
}
}
+void NetscapePluginHostManager::didCreateWindow()
+{
+ // See if any of our hosts are in full-screen mode.
+ PluginHostMap::iterator end = m_pluginHosts.end();
+ for (PluginHostMap::iterator it = m_pluginHosts.begin(); it != end; ++it) {
+ NetscapePluginHostProxy* hostProxy = it->second;
+
+ if (!hostProxy->isMenuBarVisible()) {
+ // Make ourselves the front process.
+ ProcessSerialNumber psn;
+ GetCurrentProcess(&psn);
+ SetFrontProcess(&psn);
+ return;
+ }
+ }
+}
} // namespace WebKit
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
index 4676f47..c3b58de 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
@@ -33,13 +33,15 @@
#include <wtf/RetainPtr.h>
#include <wtf/PassRefPtr.h>
+@class WebPlaceholderModalWindow;
+
namespace WebKit {
class NetscapePluginInstanceProxy;
class NetscapePluginHostProxy {
public:
- NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN);
+ NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods);
mach_port_t port() const { return m_pluginHostPort; }
mach_port_t clientPort() const { return m_clientPort; }
@@ -49,12 +51,17 @@ public:
NetscapePluginInstanceProxy* pluginInstance(uint32_t pluginID);
+ bool isMenuBarVisible() const { return m_menuBarIsVisible; }
void setMenuBarVisible(bool);
+
void setModal(bool);
void applicationDidBecomeActive();
bool processRequests();
+ bool isProcessingRequests() const { return m_processingRequests; }
+
+ bool shouldCacheMissingPropertiesAndMethods() const { return m_shouldCacheMissingPropertiesAndMethods; }
private:
~NetscapePluginHostProxy();
@@ -80,10 +87,14 @@ private:
RetainPtr<CFMachPortRef> m_deadNameNotificationPort;
RetainPtr<id> m_activationObserver;
- RetainPtr<NSWindow *> m_placeholderWindow;
+ RetainPtr<WebPlaceholderModalWindow *> m_placeholderWindow;
unsigned m_isModal;
bool m_menuBarIsVisible;
const ProcessSerialNumber m_pluginHostPSN;
+
+ unsigned m_processingRequests;
+
+ bool m_shouldCacheMissingPropertiesAndMethods;
};
} // namespace WebKit
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
index c0beb2f..e8874cd 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
@@ -49,6 +49,18 @@ using namespace std;
using namespace JSC;
using namespace WebCore;
+@interface WebPlaceholderModalWindow : NSWindow
+@end
+
+@implementation WebPlaceholderModalWindow
+// Prevent NSApp from calling requestUserAttention: when the window is shown
+// modally, even if the app is inactive. See 6823049.
+- (BOOL)_wantsUserAttention
+{
+ return NO;
+}
+@end
+
namespace WebKit {
class PluginDestroyDeferrer {
@@ -76,13 +88,15 @@ static PluginProxyMap& pluginProxyMap()
return pluginProxyMap;
}
-NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN)
+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_pluginHostPSN(pluginHostPSN)
+ , m_processingRequests(0)
+ , m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods)
{
pluginProxyMap().add(m_clientPort, this);
@@ -201,7 +215,7 @@ void NetscapePluginHostProxy::beginModal()
ASSERT(!m_placeholderWindow);
ASSERT(!m_activationObserver);
- m_placeholderWindow.adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ m_placeholderWindow.adoptNS([[WebPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
m_activationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification object:NSApp queue:nil
usingBlock:^(NSNotification *){ applicationDidBecomeActive(); }];
@@ -210,6 +224,9 @@ void NetscapePluginHostProxy::beginModal()
CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
[NSApp runModalForWindow:m_placeholderWindow.get()];
+
+ [m_placeholderWindow.get() orderOut:nil];
+ m_placeholderWindow = 0;
}
void NetscapePluginHostProxy::endModal()
@@ -223,8 +240,6 @@ void NetscapePluginHostProxy::endModal()
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSModalPanelRunLoopMode);
[NSApp stopModal];
- [m_placeholderWindow.get() orderOut:nil];
- m_placeholderWindow = 0;
// Make ourselves the front process.
ProcessSerialNumber psn;
@@ -248,7 +263,9 @@ void NetscapePluginHostProxy::setModal(bool modal)
bool NetscapePluginHostProxy::processRequests()
{
- if (!m_portSet) {
+ m_processingRequests++;
+
+ if (!m_portSet) {
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
mach_port_insert_member(mach_task_self(), m_clientPort, m_portSet);
mach_port_insert_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
@@ -262,6 +279,7 @@ bool NetscapePluginHostProxy::processRequests()
if (kr != KERN_SUCCESS) {
LOG_ERROR("Could not receive mach message, error %x", kr);
+ m_processingRequests--;
return false;
}
@@ -274,20 +292,24 @@ bool NetscapePluginHostProxy::processRequests()
if (kr != KERN_SUCCESS) {
LOG_ERROR("Could not send mach message, error %x", kr);
+ m_processingRequests--;
return false;
}
}
+ m_processingRequests--;
return true;
}
if (msg->msgh_local_port == CFMachPortGetPort(m_deadNameNotificationPort.get())) {
ASSERT(msg->msgh_id == MACH_NOTIFY_DEAD_NAME);
pluginHostDied();
+ m_processingRequests--;
return false;
}
ASSERT_NOT_REACHED();
+ m_processingRequests--;
return false;
}
@@ -368,11 +390,9 @@ kern_return_t WKPCCancelLoadURL(mach_port_t clientPort, uint32_t pluginID, uint3
if (!instanceProxy)
return KERN_FAILURE;
- HostedNetscapePluginStream* pluginStream = instanceProxy->pluginStream(streamID);
- if (!pluginStream)
+ if (!instanceProxy->cancelStreamLoad(streamID, reason))
return KERN_FAILURE;
-
- pluginStream->cancelLoad(reason);
+
return KERN_SUCCESS;
}
@@ -380,13 +400,22 @@ kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, doub
{
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
- return KERN_FAILURE;
-
- NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ return KERN_SUCCESS;
+
+ if (!hostProxy->isProcessingRequests()) {
+ if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID))
+ instanceProxy->invalidateRect(x, y, width, height);
+ return KERN_SUCCESS;
+ }
+
+ // Defer the work
+ CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{
+ if (NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort)) {
+ if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID))
+ instanceProxy->invalidateRect(x, y, width, height);
+ }
+ });
- instanceProxy->invalidateRect(x, y, width, height);
return KERN_SUCCESS;
}
@@ -500,7 +529,7 @@ kern_return_t WKPCReleaseObject(mach_port_t clientPort, uint32_t pluginID, uint3
return KERN_SUCCESS;
}
-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)
+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)
{
DataDeallocator deallocator(scriptData, scriptLength);
@@ -509,8 +538,10 @@ kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t r
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -518,7 +549,7 @@ 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);
+ boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength, allowPopups);
_WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
if (resultData)
@@ -564,8 +595,10 @@ kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t req
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -598,8 +631,10 @@ kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint3
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -642,12 +677,16 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
- if (!IdentifierRep::isValid(identifier))
- return KERN_FAILURE;
+ if (!IdentifierRep::isValid(identifier)) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -727,8 +766,10 @@ kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanReply(hostProxy->port(), pluginID, requestID, false);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -757,8 +798,10 @@ kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanReply(hostProxy->port(), pluginID, requestID, false);
+ return KERN_SUCCESS;
+ }
PluginDestroyDeferrer deferrer(instanceProxy);
@@ -807,8 +850,10 @@ kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
- if (!instanceProxy)
- return KERN_FAILURE;
+ if (!instanceProxy) {
+ _WKPHBooleanAndDataReply(hostProxy->port(), pluginID, requestID, false, 0, 0);
+ return KERN_SUCCESS;
+ }
data_t resultData = 0;
mach_msg_type_number_t resultLength = 0;
@@ -844,4 +889,172 @@ kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal)
return KERN_SUCCESS;
}
+kern_return_t WKPCGetCookies(mach_port_t clientPort, uint32_t pluginID,
+ data_t urlData, mach_msg_type_number_t urlLength,
+ boolean_t* returnValue, data_t* cookiesData, mach_msg_type_number_t* cookiesLength)
+{
+ *cookiesData = 0;
+ *cookiesLength = 0;
+
+ DataDeallocator deallocator(urlData, urlLength);
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *returnValue = instanceProxy->getCookies(urlData, urlLength, *cookiesData, *cookiesLength);
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCGetProxy(mach_port_t clientPort, uint32_t pluginID,
+ data_t urlData, mach_msg_type_number_t urlLength,
+ boolean_t* returnValue, data_t* proxyData, mach_msg_type_number_t* proxyLength)
+{
+ *proxyData = 0;
+ *proxyLength = 0;
+
+ DataDeallocator deallocator(urlData, urlLength);
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *returnValue = instanceProxy->getProxy(urlData, urlLength, *proxyData, *proxyLength);
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCSetCookies(mach_port_t clientPort, uint32_t pluginID,
+ data_t urlData, mach_msg_type_number_t urlLength,
+ data_t cookiesData, mach_msg_type_number_t cookiesLength,
+ boolean_t* returnValue)
+{
+ DataDeallocator urlDeallocator(urlData, urlLength);
+ DataDeallocator cookiesDeallocator(cookiesData, cookiesLength);
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *returnValue = instanceProxy->setCookies(urlData, urlLength, cookiesData, cookiesLength);
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCGetAuthenticationInfo(mach_port_t clientPort, uint32_t pluginID,
+ data_t protocolData, mach_msg_type_number_t protocolLength,
+ data_t hostData, mach_msg_type_number_t hostLength,
+ uint32_t port,
+ data_t schemeData, mach_msg_type_number_t schemeLength,
+ data_t realmData, mach_msg_type_number_t realmLength,
+ boolean_t* returnValue,
+ data_t* usernameData, mach_msg_type_number_t *usernameLength,
+ data_t* passwordData, mach_msg_type_number_t *passwordLength)
+{
+ DataDeallocator protocolDeallocator(protocolData, protocolLength);
+ DataDeallocator hostDeallocator(hostData, hostLength);
+ DataDeallocator schemeDeallocator(schemeData, schemeLength);
+ DataDeallocator realmDeallocator(realmData, realmLength);
+
+ *usernameData = 0;
+ *usernameLength = 0;
+ *passwordData = 0;
+ *passwordLength = 0;
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *returnValue = instanceProxy->getAuthenticationInfo(protocolData, hostData, port, schemeData, realmData, *usernameData, *usernameLength, *passwordData, *passwordLength);
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCConvertPoint(mach_port_t clientPort, uint32_t pluginID,
+ double sourceX, double sourceY, uint32_t sourceSpace,
+ uint32_t destSpace, boolean_t *returnValue, double *destX, double *destY)
+{
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *returnValue = instanceProxy->convertPoint(sourceX, sourceY, static_cast<NPCoordinateSpace>(sourceSpace),
+ *destX, *destY, static_cast<NPCoordinateSpace>(destSpace));
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCCheckIfAllowedToLoadURL(mach_port_t clientPort, uint32_t pluginID, data_t urlData, mach_msg_type_number_t urlLength,
+ data_t targetData, mach_msg_type_number_t targetLength, uint32_t *checkID)
+{
+ DataDeallocator urlDeallocator(urlData, urlLength);
+ DataDeallocator targetDeallocator(targetData, targetLength);
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ *checkID = instanceProxy->checkIfAllowedToLoadURL(urlData, targetData);
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCCancelCheckIfAllowedToLoadURL(mach_port_t clientPort, uint32_t pluginID, uint32_t checkID)
+{
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ instanceProxy->cancelCheckIfAllowedToLoadURL(checkID);
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCResolveURL(mach_port_t clientPort, uint32_t pluginID, data_t urlData, mach_msg_type_number_t urlLength,
+ data_t targetData, mach_msg_type_number_t targetLength,
+ data_t *resolvedURLData, mach_msg_type_number_t *resolvedURLLength)
+{
+ DataDeallocator urlDeallocator(urlData, urlLength);
+ DataDeallocator targetDeallocator(targetData, targetLength);
+
+ *resolvedURLData = 0;
+ *resolvedURLLength = 0;
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
+ if (!instanceProxy)
+ return KERN_FAILURE;
+
+ instanceProxy->resolveURL(urlData, targetData, *resolvedURLData, *resolvedURLLength);
+ return KERN_SUCCESS;
+}
+
#endif // USE(PLUGIN_HOST_PROCESS)
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
index 3f9132d..1841afd 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
@@ -58,9 +58,9 @@ class ProxyInstance;
class NetscapePluginInstanceProxy : public RefCounted<NetscapePluginInstanceProxy> {
public:
- static PassRefPtr<NetscapePluginInstanceProxy> create(NetscapePluginHostProxy* pluginHostProxy, WebHostedNetscapePluginView *pluginView)
+ static PassRefPtr<NetscapePluginInstanceProxy> create(NetscapePluginHostProxy* pluginHostProxy, WebHostedNetscapePluginView *pluginView, bool fullFramePlugin)
{
- return adoptRef(new NetscapePluginInstanceProxy(pluginHostProxy, pluginView));
+ return adoptRef(new NetscapePluginInstanceProxy(pluginHostProxy, pluginView, fullFramePlugin));
}
~NetscapePluginInstanceProxy();
@@ -79,12 +79,15 @@ public:
WebHostedNetscapePluginView *pluginView() const { return m_pluginView; }
NetscapePluginHostProxy* hostProxy() const { return m_pluginHostProxy; }
- HostedNetscapePluginStream *pluginStream(uint32_t streamID);
+ bool cancelStreamLoad(uint32_t streamID, NPReason);
void disconnectStream(HostedNetscapePluginStream*);
+ void setManualStream(PassRefPtr<HostedNetscapePluginStream>);
+ HostedNetscapePluginStream* manualStream() const { return m_manualStream.get(); }
+
void pluginHostDied();
- void resize(NSRect size, NSRect clipRect);
+ void resize(NSRect size, NSRect clipRect, bool sync);
void destroy();
void focusChanged(bool hasFocus);
void windowFocusChanged(bool hasFocus);
@@ -93,7 +96,9 @@ public:
void mouseEvent(NSView *pluginView, NSEvent *, NPCocoaEventType);
void keyEvent(NSView *pluginView, NSEvent *, NPCocoaEventType);
void insertText(NSString *);
-
+ bool wheelEvent(NSView *pluginView, NSEvent *);
+ void syntheticKeyDownWithCommandModifier(int keyCode, char character);
+ void flagsChanged(NSEvent *);
void print(CGContextRef, unsigned width, unsigned height);
void startTimers(bool throttleTimers);
@@ -106,7 +111,7 @@ public:
bool getPluginElementNPObject(uint32_t& objectID);
void releaseObject(uint32_t objectID);
- bool evaluate(uint32_t objectID, const WebCore::String& script, data_t& resultData, mach_msg_type_number_t& resultLength);
+ bool evaluate(uint32_t objectID, const WebCore::String& script, data_t& resultData, mach_msg_type_number_t& resultLength, bool allowPopups);
bool invoke(uint32_t objectID, const JSC::Identifier& methodName, data_t argumentsData, mach_msg_type_number_t argumentsLength, data_t& resultData, mach_msg_type_number_t& resultLength);
bool invokeDefault(uint32_t objectID, data_t argumentsData, mach_msg_type_number_t argumentsLength, data_t& resultData, mach_msg_type_number_t& resultLength);
bool construct(uint32_t objectID, data_t argumentsData, mach_msg_type_number_t argumentsLength, data_t& resultData, mach_msg_type_number_t& resultLength);
@@ -125,14 +130,24 @@ public:
void status(const char* message);
NPError loadURL(const char* url, const char* target, const char* postData, uint32_t postDataLength, LoadURLFlags, uint32_t& requestID);
+ bool getCookies(data_t urlData, mach_msg_type_number_t urlLength, data_t& cookiesData, mach_msg_type_number_t& cookiesLength);
+ bool setCookies(data_t urlData, mach_msg_type_number_t urlLength, data_t cookiesData, mach_msg_type_number_t cookiesLength);
+
+ bool getProxy(data_t urlData, mach_msg_type_number_t urlLength, data_t& proxyData, mach_msg_type_number_t& proxyLength);
+ bool getAuthenticationInfo(data_t protocolData, data_t hostData, uint32_t port, data_t schemeData, data_t realmData,
+ data_t& usernameData, mach_msg_type_number_t& usernameLength, data_t& passwordData, mach_msg_type_number_t& passwordLength);
+ bool convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
+ double& destX, double& destY, NPCoordinateSpace destSpace);
+
PassRefPtr<JSC::Bindings::Instance> createBindingsInstance(PassRefPtr<JSC::Bindings::RootObject>);
RetainPtr<NSData *> marshalValues(JSC::ExecState*, const JSC::ArgList& args);
- void marshalValue(JSC::ExecState*, JSC::JSValuePtr value, data_t& resultData, mach_msg_type_number_t& resultLength);
- JSC::JSValuePtr demarshalValue(JSC::ExecState*, const char* valueData, mach_msg_type_number_t valueLength);
+ void marshalValue(JSC::ExecState*, JSC::JSValue value, data_t& resultData, mach_msg_type_number_t& resultLength);
+ JSC::JSValue demarshalValue(JSC::ExecState*, const char* valueData, mach_msg_type_number_t valueLength);
void addInstance(ProxyInstance*);
void removeInstance(ProxyInstance*);
+ void cleanup();
void invalidate();
void willCallPluginFunction();
@@ -141,6 +156,12 @@ public:
uint32_t nextRequestID();
+ uint32_t checkIfAllowedToLoadURL(const char* url, const char* target);
+ void cancelCheckIfAllowedToLoadURL(uint32_t checkID);
+ void checkIfAllowedToLoadURLResult(uint32_t checkID, bool allowed);
+
+ void resolveURL(const char* url, const char* target, data_t& resolvedURLData, mach_msg_type_number_t& resolvedURLLength);
+
// Reply structs
struct Reply {
enum Type {
@@ -234,7 +255,7 @@ public:
}
private:
- NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView *);
+ NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView *, bool fullFramePlugin);
NPError loadRequest(NSURLRequest *, const char* cTarget, bool currentEventIsUserGesture, uint32_t& streamID);
@@ -245,8 +266,6 @@ private:
void stopAllStreams();
Reply* processRequestsAndWaitForReply(uint32_t requestID);
- void cleanup();
-
NetscapePluginHostProxy* m_pluginHostProxy;
WebHostedNetscapePluginView *m_pluginView;
@@ -268,10 +287,10 @@ private:
// NPRuntime
uint32_t idForObject(JSC::JSObject*);
- void addValueToArray(NSMutableArray *, JSC::ExecState* exec, JSC::JSValuePtr value);
+ void addValueToArray(NSMutableArray *, JSC::ExecState* exec, JSC::JSValue value);
- bool demarshalValueFromArray(JSC::ExecState*, NSArray *array, NSUInteger& index, JSC::JSValuePtr& result);
- void demarshalValues(JSC::ExecState*, data_t valuesData, mach_msg_type_number_t valuesLength, JSC::ArgList& result);
+ bool demarshalValueFromArray(JSC::ExecState*, NSArray *array, NSUInteger& index, JSC::JSValue& result);
+ void demarshalValues(JSC::ExecState*, data_t valuesData, mach_msg_type_number_t valuesLength, JSC::MarkedArgumentBuffer& result);
uint32_t m_objectIDCounter;
typedef HashMap<uint32_t, JSC::ProtectedPtr<JSC::JSObject> > ObjectMap;
@@ -279,10 +298,17 @@ private:
typedef HashSet<ProxyInstance*> ProxyInstanceSet;
ProxyInstanceSet m_instances;
+
+ uint32_t m_urlCheckCounter;
+ typedef HashMap<uint32_t, RetainPtr<id> > URLCheckMap;
+ URLCheckMap m_urlChecks;
unsigned m_pluginFunctionCallDepth;
bool m_shouldStopSoon;
uint32_t m_currentRequestID;
+ bool m_inDestroy;
+
+ RefPtr<HostedNetscapePluginStream> m_manualStream;
};
} // namespace WebKit
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
index 2ef921a..c01ae92 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
@@ -42,16 +42,20 @@
#import "WebUIDelegatePrivate.h"
#import <mach/mach.h>
+#import <WebCore/CookieJar.h>
+#import <WebCore/CString.h>
#import <WebCore/DocumentLoader.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameLoader.h>
#import <WebCore/FrameTree.h>
+#import <WebCore/KURL.h>
#import <WebCore/npruntime_impl.h>
#import <WebCore/runtime_object.h>
#import <WebCore/ScriptController.h>
#import <WebCore/ScriptValue.h>
-#include <runtime/JSLock.h>
-#include <runtime/PropertyNameArray.h>
+#import <WebKitSystemInterface.h>
+#import <runtime/JSLock.h>
+#import <runtime/PropertyNameArray.h>
#import <utility>
extern "C" {
@@ -68,29 +72,29 @@ namespace WebKit {
class NetscapePluginInstanceProxy::PluginRequest {
public:
- PluginRequest(uint32_t requestID, NSURLRequest *request, NSString *frameName, bool didStartFromUserGesture)
+ PluginRequest(uint32_t requestID, NSURLRequest *request, NSString *frameName, bool allowPopups)
: m_requestID(requestID)
, m_request(request)
, m_frameName(frameName)
- , m_didStartFromUserGesture(didStartFromUserGesture)
+ , m_allowPopups(allowPopups)
{
}
uint32_t requestID() const { return m_requestID; }
NSURLRequest *request() const { return m_request.get(); }
NSString *frameName() const { return m_frameName.get(); }
- bool didStartFromUserGesture() const { return m_didStartFromUserGesture; }
+ bool allowPopups() const { return m_allowPopups; }
private:
uint32_t m_requestID;
RetainPtr<NSURLRequest *> m_request;
RetainPtr<NSString *> m_frameName;
- bool m_didStartFromUserGesture;
+ bool m_allowPopups;
};
static uint32_t pluginIDCounter;
-NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy* pluginHostProxy, WebHostedNetscapePluginView *pluginView)
+NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy* pluginHostProxy, WebHostedNetscapePluginView *pluginView, bool fullFramePlugin)
: m_pluginHostProxy(pluginHostProxy)
, m_pluginView(pluginView)
, m_requestTimer(this, &NetscapePluginInstanceProxy::requestTimerFired)
@@ -99,12 +103,20 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy
, m_useSoftwareRenderer(false)
, m_waitingForReply(false)
, m_objectIDCounter(0)
+ , m_urlCheckCounter(0)
, m_pluginFunctionCallDepth(0)
, m_shouldStopSoon(false)
, m_currentRequestID(0)
+ , m_inDestroy(false)
{
ASSERT(m_pluginView);
+ if (fullFramePlugin) {
+ // For full frame plug-ins, the first requestID will always be the one for the already
+ // open stream.
+ ++m_currentRequestID;
+ }
+
// Assign a plug-in ID.
do {
m_pluginID = ++pluginIDCounter;
@@ -121,9 +133,19 @@ NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy()
deleteAllValues(m_replies);
}
-void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect)
+void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect, bool sync)
{
- _WKPHResizePluginInstance(m_pluginHostProxy->port(), m_pluginID, size.origin.x, size.origin.y, size.size.width, size.size.height);
+ uint32_t requestID = 0;
+
+ if (sync)
+ requestID = nextRequestID();
+
+ _WKPHResizePluginInstance(m_pluginHostProxy->port(), m_pluginID, requestID,
+ size.origin.x, size.origin.y, size.size.width, size.size.height,
+ clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height);
+
+ if (sync)
+ waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
}
void NetscapePluginInstanceProxy::stopAllStreams()
@@ -172,18 +194,44 @@ void NetscapePluginInstanceProxy::destroy()
{
uint32_t requestID = nextRequestID();
+ m_inDestroy = true;
+
_WKPHDestroyPluginInstance(m_pluginHostProxy->port(), m_pluginID, requestID);
+
+ // If the plug-in host crashes while we're waiting for a reply, the last reference to the instance proxy
+ // will go away. Prevent this by protecting it here.
+ RefPtr<NetscapePluginInstanceProxy> protect(this);
// We don't care about the reply here - we just want to block until the plug-in instance has been torn down.
waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ m_inDestroy = false;
+
cleanup();
invalidate();
}
-HostedNetscapePluginStream *NetscapePluginInstanceProxy::pluginStream(uint32_t streamID)
+void NetscapePluginInstanceProxy::setManualStream(PassRefPtr<HostedNetscapePluginStream> manualStream)
+{
+ ASSERT(!m_manualStream);
+
+ m_manualStream = manualStream;
+}
+
+bool NetscapePluginInstanceProxy::cancelStreamLoad(uint32_t streamID, NPReason reason)
{
- return m_streams.get(streamID).get();
+ HostedNetscapePluginStream* stream = 0;
+
+ if (m_manualStream && streamID == 1)
+ stream = m_manualStream.get();
+ else
+ stream = m_streams.get(streamID).get();
+
+ if (!stream)
+ return false;
+
+ stream->cancelLoad(reason);
+ return true;
}
void NetscapePluginInstanceProxy::disconnectStream(HostedNetscapePluginStream* stream)
@@ -213,7 +261,6 @@ void NetscapePluginInstanceProxy::windowFocusChanged(bool hasFocus)
void NetscapePluginInstanceProxy::windowFrameChanged(NSRect frame)
{
_WKPHPluginInstanceWindowFrameChanged(m_pluginHostProxy->port(), m_pluginID, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height,
- // FIXME: Is it always correct to pass the rect of the first screen here?
NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]));
}
@@ -239,7 +286,6 @@ void NetscapePluginInstanceProxy::mouseEvent(NSView *pluginView, NSEvent *event,
type, [event modifierFlags],
pluginPoint.x, pluginPoint.y,
screenPoint.x, screenPoint.y,
- // FIXME: Is it always correct to pass the rect of the first screen here?
NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]),
[event buttonNumber], clickCount,
[event deltaX], [event deltaY], [event deltaZ]);
@@ -255,7 +301,26 @@ void NetscapePluginInstanceProxy::keyEvent(NSView *pluginView, NSEvent *event, N
type, [event modifierFlags],
const_cast<char*>(reinterpret_cast<const char*>([charactersData bytes])), [charactersData length],
const_cast<char*>(reinterpret_cast<const char*>([charactersIgnoringModifiersData bytes])), [charactersIgnoringModifiersData length],
- [event isARepeat], [event keyCode]);
+ [event isARepeat], [event keyCode], WKGetNSEventKeyChar(event));
+}
+
+void NetscapePluginInstanceProxy::syntheticKeyDownWithCommandModifier(int keyCode, char character)
+{
+ NSData *charactersData = [NSData dataWithBytes:&character length:1];
+
+ _WKPHPluginInstanceKeyboardEvent(m_pluginHostProxy->port(), m_pluginID,
+ [NSDate timeIntervalSinceReferenceDate],
+ NPCocoaEventKeyDown, NSCommandKeyMask,
+ const_cast<char*>(reinterpret_cast<const char*>([charactersData bytes])), [charactersData length],
+ const_cast<char*>(reinterpret_cast<const char*>([charactersData bytes])), [charactersData length],
+ false, keyCode, character);
+}
+
+void NetscapePluginInstanceProxy::flagsChanged(NSEvent *event)
+{
+ _WKPHPluginInstanceKeyboardEvent(m_pluginHostProxy->port(), m_pluginID,
+ [event timestamp], NPCocoaEventFlagsChanged,
+ [event modifierFlags], 0, 0, 0, 0, false, [event keyCode], 0);
}
void NetscapePluginInstanceProxy::insertText(NSString *text)
@@ -266,6 +331,26 @@ void NetscapePluginInstanceProxy::insertText(NSString *text)
const_cast<char*>(reinterpret_cast<const char*>([textData bytes])), [textData length]);
}
+bool NetscapePluginInstanceProxy::wheelEvent(NSView *pluginView, NSEvent *event)
+{
+ NSPoint pluginPoint = [pluginView convertPoint:[event locationInWindow] fromView:nil];
+
+ uint32_t requestID = nextRequestID();
+ _WKPHPluginInstanceWheelEvent(m_pluginHostProxy->port(), m_pluginID, requestID,
+ [event timestamp], [event modifierFlags],
+ pluginPoint.x, pluginPoint.y, [event buttonNumber],
+ [event deltaX], [event deltaY], [event deltaZ]);
+
+ // Protect ourselves in case waiting for the reply causes us to be deleted.
+ RefPtr<NetscapePluginInstanceProxy> protect(this);
+
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ if (!reply.get() || !reply->m_result)
+ return false;
+
+ return true;
+}
+
void NetscapePluginInstanceProxy::print(CGContextRef context, unsigned width, unsigned height)
{
uint32_t requestID = nextRequestID();
@@ -375,7 +460,7 @@ NPError NetscapePluginInstanceProxy::loadURL(const char* url, const char* target
[request setHTTPBody:httpBody];
}
- return loadRequest(request, target, flags & CurrentEventIsUserGesture, streamID);
+ return loadRequest(request, target, flags & AllowPopups, streamID);
}
void NetscapePluginInstanceProxy::performRequest(PluginRequest* pluginRequest)
@@ -426,7 +511,7 @@ void NetscapePluginInstanceProxy::evaluateJavaScript(PluginRequest* pluginReques
NSString *JSString = [URL _webkit_scriptIfJavaScriptURL];
ASSERT(JSString);
- NSString *result = [[m_pluginView webFrame] _stringByEvaluatingJavaScriptFromString:JSString forceUserGesture:pluginRequest->didStartFromUserGesture()];
+ NSString *result = [[m_pluginView webFrame] _stringByEvaluatingJavaScriptFromString:JSString forceUserGesture:pluginRequest->allowPopups()];
// Don't continue if stringByEvaluatingJavaScriptFromString caused the plug-in to stop.
if (!m_pluginHostProxy)
@@ -466,7 +551,7 @@ void NetscapePluginInstanceProxy::requestTimerFired(Timer<NetscapePluginInstance
delete request;
}
-NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const char* cTarget, bool currentEventIsUserGesture, uint32_t& requestID)
+NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const char* cTarget, bool allowPopups, uint32_t& requestID)
{
NSURL *URL = [request URL];
@@ -514,7 +599,7 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch
return NPERR_INVALID_PARAM;
}
- PluginRequest* pluginRequest = new PluginRequest(requestID, request, target, currentEventIsUserGesture);
+ PluginRequest* pluginRequest = new PluginRequest(requestID, request, target, allowPopups);
m_pluginRequests.append(pluginRequest);
m_requestTimer.startOneShot(0);
} else {
@@ -588,7 +673,7 @@ void NetscapePluginInstanceProxy::releaseObject(uint32_t objectID)
m_objects.remove(objectID);
}
-bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& script, data_t& resultData, mach_msg_type_number_t& resultLength)
+bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& script, data_t& resultData, mach_msg_type_number_t& resultLength, bool allowPopups)
{
resultData = 0;
resultLength = 0;
@@ -600,17 +685,22 @@ bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& scri
if (!frame)
return false;
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
ProtectedPtr<JSGlobalObject> globalObject = frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
+ bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
+ frame->script()->setAllowPopupsFromPlugin(allowPopups);
+
globalObject->globalData()->timeoutChecker.start();
Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script));
globalObject->globalData()->timeoutChecker.stop();
ComplType type = completion.complType();
+
+ frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
- JSValuePtr result;
+ JSValue result;
if (type == Normal)
result = completion.value();
@@ -627,6 +717,9 @@ bool NetscapePluginInstanceProxy::invoke(uint32_t objectID, const Identifier& me
resultData = 0;
resultLength = 0;
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -636,19 +729,19 @@ bool NetscapePluginInstanceProxy::invoke(uint32_t objectID, const Identifier& me
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
- JSValuePtr function = object->get(exec, methodName);
+ JSLock lock(SilenceAssertionsOnly);
+ JSValue function = object->get(exec, methodName);
CallData callData;
CallType callType = function.getCallData(callData);
if (callType == CallTypeNone)
return false;
-
- ArgList argList;
+
+ MarkedArgumentBuffer argList;
demarshalValues(exec, argumentsData, argumentsLength, argList);
ProtectedPtr<JSGlobalObject> globalObject = frame->script()->globalObject();
globalObject->globalData()->timeoutChecker.start();
- JSValuePtr value = call(exec, function, callType, callData, object, argList);
+ JSValue value = call(exec, function, callType, callData, object, argList);
globalObject->globalData()->timeoutChecker.stop();
marshalValue(exec, value, resultData, resultLength);
@@ -658,6 +751,9 @@ bool NetscapePluginInstanceProxy::invoke(uint32_t objectID, const Identifier& me
bool NetscapePluginInstanceProxy::invokeDefault(uint32_t objectID, data_t argumentsData, mach_msg_type_number_t argumentsLength, data_t& resultData, mach_msg_type_number_t& resultLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -667,18 +763,18 @@ bool NetscapePluginInstanceProxy::invokeDefault(uint32_t objectID, data_t argume
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
CallData callData;
CallType callType = object->getCallData(callData);
if (callType == CallTypeNone)
return false;
-
- ArgList argList;
+
+ MarkedArgumentBuffer argList;
demarshalValues(exec, argumentsData, argumentsLength, argList);
ProtectedPtr<JSGlobalObject> globalObject = frame->script()->globalObject();
globalObject->globalData()->timeoutChecker.start();
- JSValuePtr value = call(exec, object, callType, callData, object, argList);
+ JSValue value = call(exec, object, callType, callData, object, argList);
globalObject->globalData()->timeoutChecker.stop();
marshalValue(exec, value, resultData, resultLength);
@@ -688,6 +784,9 @@ bool NetscapePluginInstanceProxy::invokeDefault(uint32_t objectID, data_t argume
bool NetscapePluginInstanceProxy::construct(uint32_t objectID, data_t argumentsData, mach_msg_type_number_t argumentsLength, data_t& resultData, mach_msg_type_number_t& resultLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -697,19 +796,19 @@ bool NetscapePluginInstanceProxy::construct(uint32_t objectID, data_t argumentsD
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
ConstructData constructData;
ConstructType constructType = object->getConstructData(constructData);
if (constructType == ConstructTypeNone)
return false;
-
- ArgList argList;
+
+ MarkedArgumentBuffer argList;
demarshalValues(exec, argumentsData, argumentsLength, argList);
ProtectedPtr<JSGlobalObject> globalObject = frame->script()->globalObject();
globalObject->globalData()->timeoutChecker.start();
- JSValuePtr value = JSC::construct(exec, object, constructType, constructData, argList);
+ JSValue value = JSC::construct(exec, object, constructType, constructData, argList);
globalObject->globalData()->timeoutChecker.stop();
marshalValue(exec, value, resultData, resultLength);
@@ -719,6 +818,9 @@ bool NetscapePluginInstanceProxy::construct(uint32_t objectID, data_t argumentsD
bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, const Identifier& propertyName, data_t& resultData, mach_msg_type_number_t& resultLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -728,8 +830,8 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, const Identifie
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
- JSValuePtr value = object->get(exec, propertyName);
+ JSLock lock(SilenceAssertionsOnly);
+ JSValue value = object->get(exec, propertyName);
marshalValue(exec, value, resultData, resultLength);
exec->clearException();
@@ -747,8 +849,8 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, unsigned proper
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
- JSValuePtr value = object->get(exec, propertyName);
+ JSLock lock(SilenceAssertionsOnly);
+ JSValue value = object->get(exec, propertyName);
marshalValue(exec, value, resultData, resultLength);
exec->clearException();
@@ -757,6 +859,9 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, unsigned proper
bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, const Identifier& propertyName, data_t valueData, mach_msg_type_number_t valueLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -766,9 +871,9 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, const Identifie
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
- JSValuePtr value = demarshalValue(exec, valueData, valueLength);
+ JSValue value = demarshalValue(exec, valueData, valueLength);
PutPropertySlot slot;
object->put(exec, propertyName, value, slot);
@@ -778,6 +883,9 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, const Identifie
bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned propertyName, data_t valueData, mach_msg_type_number_t valueLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -787,9 +895,9 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned proper
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
- JSValuePtr value = demarshalValue(exec, valueData, valueLength);
+ JSValue value = demarshalValue(exec, valueData, valueLength);
object->put(exec, propertyName, value);
exec->clearException();
@@ -798,6 +906,9 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned proper
bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, const Identifier& propertyName)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -812,7 +923,7 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, const Identi
return false;
}
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
object->deleteProperty(exec, propertyName);
exec->clearException();
return true;
@@ -820,6 +931,9 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, const Identi
bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, unsigned propertyName)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -834,7 +948,7 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, unsigned pro
return false;
}
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
object->deleteProperty(exec, propertyName);
exec->clearException();
return true;
@@ -842,6 +956,9 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, unsigned pro
bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, const Identifier& propertyName)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -859,6 +976,9 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, const Identifie
bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, unsigned propertyName)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -876,6 +996,9 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, unsigned proper
bool NetscapePluginInstanceProxy::hasMethod(uint32_t objectID, const Identifier& methodName)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -885,14 +1008,17 @@ bool NetscapePluginInstanceProxy::hasMethod(uint32_t objectID, const Identifier&
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
- JSValuePtr func = object->get(exec, methodName);
+ JSLock lock(SilenceAssertionsOnly);
+ JSValue func = object->get(exec, methodName);
exec->clearException();
return !func.isUndefined();
}
bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultData, mach_msg_type_number_t& resultLength)
{
+ if (m_inDestroy)
+ return false;
+
JSObject* object = m_objects.get(objectID);
if (!object)
return false;
@@ -902,7 +1028,7 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat
return false;
ExecState* exec = frame->script()->globalObject()->globalExec();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
PropertyNameArray propertyNames(exec);
object->getPropertyNames(exec, propertyNames);
@@ -927,9 +1053,9 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat
return true;
}
-void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecState* exec, JSValuePtr value)
+void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecState* exec, JSValue value)
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
if (value.isString()) {
[array addObject:[NSNumber numberWithInt:StringValueType]];
@@ -958,7 +1084,7 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecSta
[array addObject:[NSNumber numberWithInt:VoidValueType]];
}
-void NetscapePluginInstanceProxy::marshalValue(ExecState* exec, JSValuePtr value, data_t& resultData, mach_msg_type_number_t& resultLength)
+void NetscapePluginInstanceProxy::marshalValue(ExecState* exec, JSValue value, data_t& resultData, mach_msg_type_number_t& resultLength)
{
RetainPtr<NSMutableArray*> array(AdoptNS, [[NSMutableArray alloc] init]);
@@ -978,7 +1104,7 @@ RetainPtr<NSData *> NetscapePluginInstanceProxy::marshalValues(ExecState* exec,
RetainPtr<NSMutableArray*> array(AdoptNS, [[NSMutableArray alloc] init]);
for (unsigned i = 0; i < args.size(); i++)
- addValueToArray(array.get(), exec, args.at(exec, i));
+ addValueToArray(array.get(), exec, args.at(i));
RetainPtr<NSData *> data = [NSPropertyListSerialization dataFromPropertyList:array.get() format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
ASSERT(data);
@@ -986,7 +1112,7 @@ RetainPtr<NSData *> NetscapePluginInstanceProxy::marshalValues(ExecState* exec,
return data;
}
-bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArray *array, NSUInteger& index, JSValuePtr& result)
+bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArray *array, NSUInteger& index, JSValue& result)
{
if (index == [array count])
return false;
@@ -1041,7 +1167,7 @@ bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArr
}
}
-JSValuePtr NetscapePluginInstanceProxy::demarshalValue(ExecState* exec, const char* valueData, mach_msg_type_number_t valueLength)
+JSValue NetscapePluginInstanceProxy::demarshalValue(ExecState* exec, const char* valueData, mach_msg_type_number_t valueLength)
{
RetainPtr<NSData*> data(AdoptNS, [[NSData alloc] initWithBytesNoCopy:(void*)valueData length:valueLength freeWhenDone:NO]);
@@ -1050,14 +1176,14 @@ JSValuePtr NetscapePluginInstanceProxy::demarshalValue(ExecState* exec, const ch
format:0
errorDescription:0];
NSUInteger position = 0;
- JSValuePtr value;
+ JSValue value;
bool result = demarshalValueFromArray(exec, array.get(), position, value);
ASSERT_UNUSED(result, result);
return value;
}
-void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t valuesData, mach_msg_type_number_t valuesLength, ArgList& result)
+void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t valuesData, mach_msg_type_number_t valuesLength, MarkedArgumentBuffer& result)
{
RetainPtr<NSData*> data(AdoptNS, [[NSData alloc] initWithBytesNoCopy:valuesData length:valuesLength freeWhenDone:NO]);
@@ -1066,7 +1192,7 @@ void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t values
format:0
errorDescription:0];
NSUInteger position = 0;
- JSValuePtr value;
+ JSValue value;
while (demarshalValueFromArray(exec, array.get(), position, value))
result.append(value);
}
@@ -1145,9 +1271,150 @@ void NetscapePluginInstanceProxy::invalidateRect(double x, double y, double widt
{
ASSERT(m_pluginView);
- [m_pluginView setNeedsDisplayInRect:NSMakeRect(x, y, width, height)];
+ [m_pluginView invalidatePluginContentRect:NSMakeRect(x, y, width, height)];
}
+
+bool NetscapePluginInstanceProxy::getCookies(data_t urlData, mach_msg_type_number_t urlLength, data_t& cookiesData, mach_msg_type_number_t& cookiesLength)
+{
+ ASSERT(m_pluginView);
+
+ NSURL *url = [m_pluginView URLWithCString:urlData];
+ if (!url)
+ return false;
+
+ if (Frame* frame = core([m_pluginView webFrame])) {
+ String cookieString = cookies(frame->document(), url);
+ WebCore::CString cookieStringUTF8 = cookieString.utf8();
+ if (cookieStringUTF8.isNull())
+ return false;
+
+ cookiesLength = cookieStringUTF8.length();
+ mig_allocate(reinterpret_cast<vm_address_t*>(&cookiesData), cookiesLength);
+ memcpy(cookiesData, cookieStringUTF8.data(), cookiesLength);
+
+ return true;
+ }
+
+ return false;
+}
+
+bool NetscapePluginInstanceProxy::setCookies(data_t urlData, mach_msg_type_number_t urlLength, data_t cookiesData, mach_msg_type_number_t cookiesLength)
+{
+ ASSERT(m_pluginView);
+
+ NSURL *url = [m_pluginView URLWithCString:urlData];
+ if (!url)
+ return false;
+
+ if (Frame* frame = core([m_pluginView webFrame])) {
+ String cookieString = String::fromUTF8(cookiesData, cookiesLength);
+ if (!cookieString)
+ return false;
+
+ WebCore::setCookies(frame->document(), url, cookieString);
+ return true;
+ }
+
+ return false;
+}
+
+bool NetscapePluginInstanceProxy::getProxy(data_t urlData, mach_msg_type_number_t urlLength, data_t& proxyData, mach_msg_type_number_t& proxyLength)
+{
+ ASSERT(m_pluginView);
+ NSURL *url = [m_pluginView URLWithCString:urlData];
+ if (!url)
+ return false;
+
+ WebCore::CString proxyStringUTF8 = proxiesForURL(url);
+
+ proxyLength = proxyStringUTF8.length();
+ mig_allocate(reinterpret_cast<vm_address_t*>(&proxyData), proxyLength);
+ memcpy(proxyData, proxyStringUTF8.data(), proxyLength);
+
+ return true;
+}
+
+bool NetscapePluginInstanceProxy::getAuthenticationInfo(data_t protocolData, data_t hostData, uint32_t port, data_t schemeData, data_t realmData,
+ data_t& usernameData, mach_msg_type_number_t& usernameLength, data_t& passwordData, mach_msg_type_number_t& passwordLength)
+{
+ WebCore::CString username;
+ WebCore::CString password;
+
+ if (!WebKit::getAuthenticationInfo(protocolData, hostData, port, schemeData, realmData, username, password))
+ return false;
+
+ usernameLength = username.length();
+ mig_allocate(reinterpret_cast<vm_address_t*>(&usernameData), usernameLength);
+ memcpy(usernameData, username.data(), usernameLength);
+
+ passwordLength = password.length();
+ mig_allocate(reinterpret_cast<vm_address_t*>(&passwordData), passwordLength);
+ memcpy(passwordData, password.data(), passwordLength);
+
+ return true;
+}
+
+bool NetscapePluginInstanceProxy::convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
+ double& destX, double& destY, NPCoordinateSpace destSpace)
+{
+ ASSERT(m_pluginView);
+
+ return [m_pluginView convertFromX:sourceX andY:sourceY space:sourceSpace toX:&destX andY:&destY space:destSpace];
+}
+
+uint32_t NetscapePluginInstanceProxy::checkIfAllowedToLoadURL(const char* url, const char* target)
+{
+ uint32_t checkID;
+
+ // Assign a check ID
+ do {
+ checkID = ++m_urlCheckCounter;
+ } while (m_urlChecks.contains(checkID) || !m_urlCheckCounter);
+
+ NSString *frameName = target ? [NSString stringWithCString:target encoding:NSISOLatin1StringEncoding] : nil;
+
+ NSNumber *contextInfo = [[NSNumber alloc] initWithUnsignedInt:checkID];
+ WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:[m_pluginView requestWithURLCString:url]
+ target:frameName
+ resultObject:m_pluginView
+ selector:@selector(_containerCheckResult:contextInfo:)
+ controller:m_pluginView
+ contextInfo:contextInfo];
+
+ [contextInfo release];
+ m_urlChecks.set(checkID, check);
+ [check start];
+
+ return checkID;
+}
+
+void NetscapePluginInstanceProxy::cancelCheckIfAllowedToLoadURL(uint32_t checkID)
+{
+ URLCheckMap::iterator it = m_urlChecks.find(checkID);
+ if (it == m_urlChecks.end())
+ return;
+
+ WebPluginContainerCheck *check = it->second.get();
+ [check cancel];
+ m_urlChecks.remove(it);
+}
+
+void NetscapePluginInstanceProxy::checkIfAllowedToLoadURLResult(uint32_t checkID, bool allowed)
+{
+ _WKPHCheckIfAllowedToLoadURLResult(m_pluginHostProxy->port(), m_pluginID, checkID, allowed);
+}
+
+void NetscapePluginInstanceProxy::resolveURL(const char* url, const char* target, data_t& resolvedURLData, mach_msg_type_number_t& resolvedURLLength)
+{
+ ASSERT(m_pluginView);
+
+ WebCore::CString resolvedURL = [m_pluginView resolvedURLStringForURL:url target:target];
+
+ resolvedURLLength = resolvedURL.length();
+ mig_allocate(reinterpret_cast<vm_address_t*>(&resolvedURLData), resolvedURLLength);
+ memcpy(resolvedURLData, resolvedURL.data(), resolvedURLLength);
+}
} // namespace WebKit
diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.h b/WebKit/mac/Plugins/Hosted/ProxyInstance.h
index 1e2e2dc..8a07def 100644
--- a/WebKit/mac/Plugins/Hosted/ProxyInstance.h
+++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.h
@@ -49,8 +49,8 @@ public:
JSC::Bindings::MethodList methodsNamed(const JSC::Identifier&);
JSC::Bindings::Field* fieldNamed(const JSC::Identifier&);
- JSC::JSValuePtr fieldValue(JSC::ExecState*, const JSC::Bindings::Field*) const;
- void setFieldValue(JSC::ExecState*, const JSC::Bindings::Field*, JSC::JSValuePtr) const;
+ JSC::JSValue fieldValue(JSC::ExecState*, const JSC::Bindings::Field*) const;
+ void setFieldValue(JSC::ExecState*, const JSC::Bindings::Field*, JSC::JSValue) const;
void invalidate();
@@ -61,24 +61,24 @@ private:
virtual JSC::Bindings::Class *getClass() const;
- virtual JSC::JSValuePtr invokeMethod(JSC::ExecState*, const JSC::Bindings::MethodList&, const JSC::ArgList& args);
+ virtual JSC::JSValue invokeMethod(JSC::ExecState*, const JSC::Bindings::MethodList&, const JSC::ArgList& args);
virtual bool supportsInvokeDefaultMethod() const;
- virtual JSC::JSValuePtr invokeDefaultMethod(JSC::ExecState*, const JSC::ArgList&);
+ virtual JSC::JSValue invokeDefaultMethod(JSC::ExecState*, const JSC::ArgList&);
virtual bool supportsConstruct() const;
- virtual JSC::JSValuePtr invokeConstruct(JSC::ExecState*, const JSC::ArgList&);
+ virtual JSC::JSValue invokeConstruct(JSC::ExecState*, const JSC::ArgList&);
- virtual JSC::JSValuePtr defaultValue(JSC::ExecState*, JSC::PreferredPrimitiveType) const;
- virtual JSC::JSValuePtr valueOf(JSC::ExecState*) const;
+ virtual JSC::JSValue defaultValue(JSC::ExecState*, JSC::PreferredPrimitiveType) const;
+ virtual JSC::JSValue valueOf(JSC::ExecState*) const;
virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
- JSC::JSValuePtr stringValue(JSC::ExecState*) const;
- JSC::JSValuePtr numberValue(JSC::ExecState*) const;
- JSC::JSValuePtr booleanValue() const;
+ JSC::JSValue stringValue(JSC::ExecState*) const;
+ JSC::JSValue numberValue(JSC::ExecState*) const;
+ JSC::JSValue booleanValue() const;
- JSC::JSValuePtr invoke(JSC::ExecState*, InvokeType, uint64_t identifier, const JSC::ArgList& args);
+ JSC::JSValue invoke(JSC::ExecState*, InvokeType, uint64_t identifier, const JSC::ArgList& args);
NetscapePluginInstanceProxy* m_instanceProxy;
uint32_t m_objectID;
diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
index 01e64ba..75bc639 100644
--- a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
+++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
@@ -77,18 +77,18 @@ public:
uint64_t serverIdentifier() const { return m_serverIdentifier; }
private:
- virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const;
+ virtual JSValue valueFromInstance(ExecState*, const Instance*) const;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const;
uint64_t m_serverIdentifier;
};
-JSValuePtr ProxyField::valueFromInstance(ExecState* exec, const Instance* instance) const
+JSValue ProxyField::valueFromInstance(ExecState* exec, const Instance* instance) const
{
return static_cast<const ProxyInstance*>(instance)->fieldValue(exec, this);
}
-void ProxyField::setValueToInstance(ExecState* exec, const Instance* instance, JSValuePtr value) const
+void ProxyField::setValueToInstance(ExecState* exec, const Instance* instance, JSValue value) const
{
static_cast<const ProxyInstance*>(instance)->setFieldValue(exec, this, value);
}
@@ -134,7 +134,7 @@ JSC::Bindings::Class *ProxyInstance::getClass() const
return proxyClass();
}
-JSValuePtr ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t identifier, const JSC::ArgList& args)
+JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t identifier, const JSC::ArgList& args)
{
RetainPtr<NSData*> arguments(m_instanceProxy->marshalValues(exec, args));
@@ -151,7 +151,7 @@ JSValuePtr ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t
return m_instanceProxy->demarshalValue(exec, (char*)CFDataGetBytePtr(reply->m_result.get()), CFDataGetLength(reply->m_result.get()));
}
-JSValuePtr ProxyInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args)
+JSValue ProxyInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args)
{
ASSERT(methodList.size() == 1);
@@ -176,7 +176,7 @@ bool ProxyInstance::supportsInvokeDefaultMethod() const
return false;
}
-JSValuePtr ProxyInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
+JSValue ProxyInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
{
return invoke(exec, InvokeDefault, 0, args);
}
@@ -197,12 +197,12 @@ bool ProxyInstance::supportsConstruct() const
return false;
}
-JSValuePtr ProxyInstance::invokeConstruct(ExecState* exec, const ArgList& args)
+JSValue ProxyInstance::invokeConstruct(ExecState* exec, const ArgList& args)
{
return invoke(exec, Construct, 0, args);
}
-JSValuePtr ProxyInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValue ProxyInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (hint == PreferString)
return stringValue(exec);
@@ -211,25 +211,25 @@ JSValuePtr ProxyInstance::defaultValue(ExecState* exec, PreferredPrimitiveType h
return valueOf(exec);
}
-JSValuePtr ProxyInstance::stringValue(ExecState* exec) const
+JSValue ProxyInstance::stringValue(ExecState* exec) const
{
// FIXME: Implement something sensible.
return jsString(exec, "");
}
-JSValuePtr ProxyInstance::numberValue(ExecState* exec) const
+JSValue ProxyInstance::numberValue(ExecState* exec) const
{
// FIXME: Implement something sensible.
return jsNumber(exec, 0);
}
-JSValuePtr ProxyInstance::booleanValue() const
+JSValue ProxyInstance::booleanValue() const
{
// FIXME: Implement something sensible.
return jsBoolean(false);
}
-JSValuePtr ProxyInstance::valueOf(ExecState* exec) const
+JSValue ProxyInstance::valueOf(ExecState* exec) const
{
return stringValue(exec);
}
@@ -266,12 +266,15 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr
MethodList ProxyInstance::methodsNamed(const Identifier& identifier)
{
- if (Method* method = m_methods.get(identifier.ustring().rep())) {
+ // If we already have an entry in the map, use it.
+ MethodMap::iterator existingMapEntry = m_methods.find(identifier.ustring().rep());
+ if (existingMapEntry != m_methods.end()) {
MethodList methodList;
- methodList.append(method);
+ if (existingMapEntry->second)
+ methodList.append(existingMapEntry->second);
return methodList;
}
-
+
uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ascii()));
uint32_t requestID = m_instanceProxy->nextRequestID();
@@ -281,23 +284,29 @@ MethodList ProxyInstance::methodsNamed(const Identifier& identifier)
return MethodList();
auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
- if (reply.get() && reply->m_result) {
- Method* method = new ProxyMethod(methodName);
-
- m_methods.set(identifier.ustring().rep(), method);
-
- MethodList methodList;
- methodList.append(method);
- return methodList;
- }
+ if (!reply.get())
+ return MethodList();
- return MethodList();
+ if (!reply->m_result && !m_instanceProxy->hostProxy()->shouldCacheMissingPropertiesAndMethods())
+ return MethodList();
+
+ // Add a new entry to the map unless an entry was added while we were in waitForReply.
+ pair<MethodMap::iterator, bool> mapAddResult = m_methods.add(identifier.ustring().rep(), 0);
+ if (mapAddResult.second && reply->m_result)
+ mapAddResult.first->second = new ProxyMethod(methodName);
+
+ MethodList methodList;
+ if (mapAddResult.first->second)
+ methodList.append(mapAddResult.first->second);
+ return methodList;
}
Field* ProxyInstance::fieldNamed(const Identifier& identifier)
{
- if (Field* field = m_fields.get(identifier.ustring().rep()))
- return field;
+ // If we already have an entry in the map, use it.
+ FieldMap::iterator existingMapEntry = m_fields.find(identifier.ustring().rep());
+ if (existingMapEntry != m_fields.end())
+ return existingMapEntry->second;
uint64_t propertyName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ascii()));
uint32_t requestID = m_instanceProxy->nextRequestID();
@@ -306,20 +315,22 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier)
m_instanceProxy->pluginID(), requestID,
m_objectID, propertyName) != KERN_SUCCESS)
return 0;
-
+
auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
- if (reply.get() && reply->m_result) {
- Field* field = new ProxyField(propertyName);
-
- m_fields.set(identifier.ustring().rep(), field);
+ if (!reply.get())
+ return 0;
- return field;
- }
+ if (!reply->m_result && !m_instanceProxy->hostProxy()->shouldCacheMissingPropertiesAndMethods())
+ return 0;
- return 0;
+ // Add a new entry to the map unless an entry was added while we were in waitForReply.
+ pair<FieldMap::iterator, bool> mapAddResult = m_fields.add(identifier.ustring().rep(), 0);
+ if (mapAddResult.second && reply->m_result)
+ mapAddResult.first->second = new ProxyField(propertyName);
+ return mapAddResult.first->second;
}
-JSC::JSValuePtr ProxyInstance::fieldValue(ExecState* exec, const Field* field) const
+JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) const
{
uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier();
uint32_t requestID = m_instanceProxy->nextRequestID();
@@ -336,7 +347,7 @@ JSC::JSValuePtr ProxyInstance::fieldValue(ExecState* exec, const Field* field) c
return m_instanceProxy->demarshalValue(exec, (char*)CFDataGetBytePtr(reply->m_result.get()), CFDataGetLength(reply->m_result.get()));
}
-void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValuePtr value) const
+void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue value) const
{
uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier();
uint32_t requestID = m_instanceProxy->nextRequestID();
diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
index 8b68b7b..4ff5aba 100644
--- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
+++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
@@ -31,10 +31,11 @@
#import <wtf/RefPtr.h>
namespace WebKit {
+ class HostedNetscapePluginStream;
class NetscapePluginInstanceProxy;
}
-@interface WebHostedNetscapePluginView : WebBaseNetscapePluginView
+@interface WebHostedNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, WebPluginContainerCheckController>
{
RetainPtr<NSArray> _attributeKeys;
RetainPtr<NSArray> _attributeValues;
@@ -42,6 +43,7 @@ namespace WebKit {
RetainPtr<CALayer> _pluginLayer;
WKSoftwareCARendererRef _softwareRenderer;
+ NSSize _previousSize;
RefPtr<WebKit::NetscapePluginInstanceProxy> _proxy;
BOOL _pluginHostDied;
}
diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
index c17d249..0cce014 100644
--- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
@@ -26,15 +26,19 @@
#import "WebHostedNetscapePluginView.h"
+#import "HostedNetscapePluginStream.h"
#import "NetscapePluginInstanceProxy.h"
#import "NetscapePluginHostManager.h"
#import "NetscapePluginHostProxy.h"
#import "WebTextInputWindowController.h"
+#import "WebFrameInternal.h"
#import "WebView.h"
#import "WebViewInternal.h"
#import "WebUIDelegate.h"
#import <CoreFoundation/CoreFoundation.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameLoaderTypes.h>
#import <WebCore/HTMLPlugInElement.h>
#import <WebCore/runtime.h>
#import <WebCore/runtime_root.h>
@@ -42,6 +46,7 @@
#import <runtime/InitializeThreading.h>
#import <wtf/Assertions.h>
+using namespace WebCore;
using namespace WebKit;
extern "C" {
@@ -97,7 +102,7 @@ extern "C" {
NSString *userAgent = [[self webView] userAgentForURL:_baseURL.get()];
- _proxy = NetscapePluginHostManager::shared().instantiatePlugin(_pluginPackage.get(), self, _MIMEType.get(), _attributeKeys.get(), _attributeValues.get(), userAgent, _sourceURL.get());
+ _proxy = NetscapePluginHostManager::shared().instantiatePlugin(_pluginPackage.get(), self, _MIMEType.get(), _attributeKeys.get(), _attributeValues.get(), userAgent, _sourceURL.get(), _mode == NP_FULL);
if (!_proxy)
return NO;
@@ -116,6 +121,7 @@ extern "C" {
- (void)setLayer:(CALayer *)newLayer
{
+ // FIXME: This should use the same implementation as WebNetscapePluginView (and move to the base class).
[super setLayer:newLayer];
if (_pluginLayer)
@@ -140,7 +146,10 @@ extern "C" {
boundsInWindow.origin.y = borderViewHeight - NSMaxY(boundsInWindow);
visibleRectInWindow.origin.y = borderViewHeight - NSMaxY(visibleRectInWindow);
- _proxy->resize(boundsInWindow, visibleRectInWindow);
+ BOOL sizeChanged = !NSEqualSizes(_previousSize, boundsInWindow.size);
+ _previousSize = boundsInWindow.size;
+
+ _proxy->resize(boundsInWindow, visibleRectInWindow, sizeChanged);
}
- (void)windowFocusChanged:(BOOL)hasFocus
@@ -254,6 +263,17 @@ extern "C" {
_proxy->mouseEvent(self, event, NPCocoaEventMouseExited);
}
+- (void)scrollWheel:(NSEvent *)event
+{
+ bool processedEvent = false;
+
+ if (_isStarted && _proxy)
+ processedEvent = _proxy->wheelEvent(self, event);
+
+ if (!processedEvent)
+ [super scrollWheel:event];
+}
+
- (NSTextInputContext *)inputContext
{
return [[WebTextInputWindowController sharedTextInputWindowController] inputContext];
@@ -280,6 +300,18 @@ extern "C" {
_proxy->keyEvent(self, event, NPCocoaEventKeyUp);
}
+- (void)flagsChanged:(NSEvent *)event
+{
+ if (_isStarted && _proxy)
+ _proxy->flagsChanged(event);
+}
+
+- (void)sendModifierEventWithKeyCode:(int)keyCode character:(char)character
+{
+ if (_isStarted && _proxy)
+ _proxy->syntheticKeyDownWithCommandModifier(keyCode, character);
+}
+
- (void)pluginHostDied
{
_pluginHostDied = YES;
@@ -290,7 +322,7 @@ extern "C" {
// No need for us to be layer backed anymore
self.wantsLayer = NO;
- [self setNeedsDisplay:YES];
+ [self invalidatePluginContentRect:[self bounds]];
}
@@ -334,6 +366,72 @@ extern "C" {
return _proxy->createBindingsInstance(rootObject);
}
+- (void)pluginView:(NSView *)pluginView receivedResponse:(NSURLResponse *)response
+{
+ ASSERT(_loadManually);
+ if (!_proxy)
+ return;
+
+ ASSERT(!_proxy->manualStream());
+
+ _proxy->setManualStream(HostedNetscapePluginStream::create(_proxy.get(), core([self webFrame])->loader()));
+ _proxy->manualStream()->startStreamWithResponse(response);
+}
+
+- (void)pluginView:(NSView *)pluginView receivedData:(NSData *)data
+{
+ ASSERT(_loadManually);
+ if (!_proxy)
+ return;
+
+ if (HostedNetscapePluginStream* manualStream = _proxy->manualStream())
+ manualStream->didReceiveData(0, static_cast<const char*>([data bytes]), [data length]);
+}
+
+- (void)pluginView:(NSView *)pluginView receivedError:(NSError *)error
+{
+ ASSERT(_loadManually);
+ if (!_proxy)
+ return;
+
+ if (HostedNetscapePluginStream* manualStream = _proxy->manualStream())
+ manualStream->didFail(0, error);
+}
+
+- (void)pluginViewFinishedLoading:(NSView *)pluginView
+{
+ ASSERT(_loadManually);
+ if (!_proxy)
+ return;
+
+ if (HostedNetscapePluginStream* manualStream = _proxy->manualStream())
+ manualStream->didFinishLoading(0);
+}
+
+- (void)_webPluginContainerCancelCheckIfAllowedToLoadRequest:(id)webPluginContainerCheck
+{
+ ASSERT([webPluginContainerCheck isKindOfClass:[WebPluginContainerCheck class]]);
+
+ id contextInfo = [webPluginContainerCheck contextInfo];
+ ASSERT(contextInfo && [contextInfo isKindOfClass:[NSNumber class]]);
+
+ if (!_proxy)
+ return;
+
+ uint32_t checkID = [(NSNumber *)contextInfo unsignedIntValue];
+ _proxy->cancelCheckIfAllowedToLoadURL(checkID);
+}
+
+- (void)_containerCheckResult:(PolicyAction)policy contextInfo:(id)contextInfo
+{
+ ASSERT([contextInfo isKindOfClass:[NSNumber class]]);
+ if (!_proxy)
+ return;
+
+ uint32_t checkID = [(NSNumber *)contextInfo unsignedIntValue];
+ _proxy->checkIfAllowedToLoadURLResult(checkID, (policy == PolicyUse));
+}
+
@end
#endif
diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
index 6128517..9877d9e 100644
--- a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
+++ b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
@@ -56,6 +56,45 @@ simpleroutine PCInvalidateRect(clientPort :mach_port_t;
width :double;
height :double);
+routine PCGetCookies(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ url :data_t;
+ out returnValue :boolean_t;
+ out cookies :data_t, dealloc);
+
+routine PCSetCookies(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ url :data_t;
+ cookies :data_t;
+ out returnValue :boolean_t);
+
+routine PCGetProxy(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ url :data_t;
+ out returnValue :boolean_t;
+ out proxy :data_t, dealloc);
+
+routine PCGetAuthenticationInfo(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ protocol :data_t;
+ host :data_t;
+ port :uint32_t;
+ scheme :data_t;
+ realm :data_t;
+ out returnValue :boolean_t;
+ out username :data_t, dealloc;
+ out password :data_t, dealloc);
+
+routine PCConvertPoint(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ sourceX :double;
+ sourceY :double;
+ sourceSpace :uint32_t;
+ destSpace :uint32_t;
+ out returnValue :boolean_t;
+ out destX :double;
+ out destY :double);
+
// NPRuntime
routine PCGetStringIdentifier(clientPort :mach_port_t;
@@ -81,7 +120,8 @@ simpleroutine PCEvaluate(clientPort :mach_port_t;
pluginID :uint32_t;
requestID :uint32_t;
objectID :uint32_t;
- script :data_t);
+ script :data_t;
+ allowPopups :boolean_t);
simpleroutine PCInvoke(clientPort :mach_port_t;
pluginID :uint32_t;
@@ -151,6 +191,22 @@ simpleroutine PCSetMenuBarVisible(clientPort :mach_port_t;
simpleroutine PCSetModal(clientPort :mach_port_t;
modal :boolean_t);
+routine PCCheckIfAllowedToLoadURL(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ url :data_t;
+ target :data_t;
+ out checkID :uint32_t);
+
+simpleroutine PCCancelCheckIfAllowedToLoadURL(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ checkID :uint32_t);
+
+routine PCResolveURL(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ url :data_t;
+ target :data_t;
+ out resolvedURL :data_t, dealloc);
+
// Replies
simpleroutine PCInstantiatePluginReply(clientPort :mach_port_t;
pluginID :uint32_t;
diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
index c6c38aa..41d7498 100644
--- a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
+++ b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
@@ -45,11 +45,17 @@ simpleroutine PHInstantiatePlugin(pluginHostPort :mach_port_t;
pluginID :uint32_t);
simpleroutine PHResizePluginInstance(pluginHostPort :mach_port_t;
- pluginID :uint32_t;
- x :double;
- y :double;
- width :double;
- height :double);
+ pluginID :uint32_t;
+ requestID :uint32_t;
+ pluginX :double;
+ pluginY :double;
+ pluginWidth :double;
+ pluginHeight :double;
+ clipX :double;
+ clipY :double;
+ clipWidth :double;
+ clipHeight :double);
+
simpleroutine PHPluginInstanceFocusChanged(pluginHostPort :mach_port_t;
pluginID :uint32_t;
hasFocus :boolean_t);
@@ -88,7 +94,20 @@ simpleroutine PHPluginInstanceKeyboardEvent(pluginHostPort :mach_port_t;
characters :data_t;
charactersIgnoringModifiers :data_t;
isARepeat :boolean_t;
- keyCode :uint16_t);
+ keyCode :uint16_t;
+ keyChar :uint8_t);
+
+simpleroutine PHPluginInstanceWheelEvent(pluginHostPort :mach_port_t;
+ pluginID :uint32_t;
+ requestID :uint32_t;
+ timestamp :double;
+ modifierFlags :uint32_t;
+ pluginX :double;
+ pluginY :double;
+ buttonNumber :int32_t;
+ deltaX :double;
+ deltaY :double;
+ deltaZ: double);
simpleroutine PHPluginInstanceInsertText(pluginHostPort :mach_port_t;
pluginID :uint32_t;
@@ -110,6 +129,10 @@ simpleroutine PHDestroyPluginInstance(pluginHostPort :mach_port_t;
pluginID :uint32_t;
requestID :uint32_t);
+simpleroutine PHCheckIfAllowedToLoadURLResult(clientPort :mach_port_t;
+ pluginID :uint32_t;
+ checkID :uint32_t;
+ result :boolean_t);
// Streams
simpleroutine PHStartStream(pluginHostPort :mach_port_t;
diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginHostTypes.h b/WebKit/mac/Plugins/Hosted/WebKitPluginHostTypes.h
index a5efde9..e8bd82d 100644
--- a/WebKit/mac/Plugins/Hosted/WebKitPluginHostTypes.h
+++ b/WebKit/mac/Plugins/Hosted/WebKitPluginHostTypes.h
@@ -39,7 +39,7 @@ enum LoadURLFlags {
IsPost = 1 << 0,
PostDataIsFile = 1 << 1,
AllowHeadersInPostData = 1 << 2,
- CurrentEventIsUserGesture = 1 << 3,
+ AllowPopups = 1 << 3,
};
enum InvokeType {
diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm
index 96f7644..a5a8a2d 100644
--- a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm
+++ b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm
@@ -348,7 +348,7 @@ void WebNetscapePluginStream::didReceiveResponse(NetscapePlugInStreamLoader*, co
// startStreamResponseURL:... will null-terminate.
}
- startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r _webcore_MIMEType], theHeaders);
+ startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r MIMEType], theHeaders);
}
void WebNetscapePluginStream::startStreamWithResponse(NSURLResponse *response)
@@ -365,7 +365,7 @@ bool WebNetscapePluginStream::wantsAllStreams() const
NPError error;
{
PluginStopDeferrer deferrer(m_pluginView.get());
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
error = m_pluginFuncs->getvalue(m_plugin, NPPVpluginWantsAllNetworkStreams, &value);
}
if (error != NPERR_NO_ERROR)
diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
index ec0a3df..a9fb188 100644
--- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
+++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
@@ -30,7 +30,7 @@
#import <Cocoa/Cocoa.h>
#import "WebNetscapePluginPackage.h"
-
+#import "WebPluginContainerCheck.h"
#import <wtf/PassRefPtr.h>
#import <wtf/RefPtr.h>
#import <wtf/RetainPtr.h>
@@ -41,6 +41,7 @@
@class WebView;
namespace WebCore {
+ class CString;
class HTMLPlugInElement;
}
@@ -52,6 +53,7 @@ namespace WebCore {
int _mode;
+ BOOL _triedAndFailedToCreatePlugin;
BOOL _loadManually;
BOOL _shouldFireTimers;
BOOL _isStarted;
@@ -78,6 +80,7 @@ namespace WebCore {
- (WebNetscapePluginPackage *)pluginPackage;
+- (NSURL *)URLWithCString:(const char *)URLCString;
- (NSMutableURLRequest *)requestWithURLCString:(const char *)URLCString;
// Subclasses must override these.
@@ -102,7 +105,24 @@ namespace WebCore {
- (void)addWindowObservers;
- (void)removeWindowObservers;
+
+- (BOOL)convertFromX:(double)sourceX andY:(double)sourceY space:(NPCoordinateSpace)sourceSpace
+ toX:(double *)destX andY:(double *)destY space:(NPCoordinateSpace)destSpace;
+- (WebCore::CString)resolvedURLStringForURL:(const char*)url target:(const char*)target;
+
+- (void)invalidatePluginContentRect:(NSRect)rect;
+
@end
+
+namespace WebKit {
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+WebCore::CString proxiesForURL(NSURL *);
+#endif
+
+bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
+ WebCore::CString& username, WebCore::CString& password);
+}
+
#endif
diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
index 26057fa..1345fc3 100644
--- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
@@ -34,12 +34,16 @@
#import "WebKitLogging.h"
#import "WebKitNSStringExtras.h"
#import "WebKitSystemInterface.h"
+#import "WebPluginContainerCheck.h"
+#import "WebNetscapeContainerCheckContextInfo.h"
#import "WebNSURLExtras.h"
#import "WebNSURLRequestExtras.h"
#import "WebView.h"
#import "WebViewInternal.h"
#import <WebCore/WebCoreObjCExtras.h>
+#import <WebCore/AuthenticationMac.h>
+#import <WebCore/CString.h>
#import <WebCore/Document.h>
#import <WebCore/Element.h>
#import <WebCore/Frame.h>
@@ -87,14 +91,27 @@ using namespace WebCore;
_baseURL.adoptNS([baseURL copy]);
_MIMEType.adoptNS([MIME copy]);
- [self setAttributeKeys:keys andValues:values];
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ // Enable "kiosk mode" when instantiating the QT plug-in inside of Dashboard. See <rdar://problem/6878105>
+ if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.dashboard.client"] &&
+ [[[_pluginPackage.get() bundle] bundleIdentifier] isEqualToString:@"com.apple.QuickTime Plugin.plugin"]) {
+ RetainPtr<NSMutableArray> mutableKeys(AdoptNS, [keys mutableCopy]);
+ RetainPtr<NSMutableArray> mutableValues(AdoptNS, [values mutableCopy]);
+
+ [mutableKeys.get() addObject:@"kioskmode"];
+ [mutableValues.get() addObject:@"true"];
+ [self setAttributeKeys:mutableKeys.get() andValues:mutableValues.get()];
+ } else
+#endif
+ [self setAttributeKeys:keys andValues:values];
+
if (loadManually)
_mode = NP_FULL;
else
_mode = NP_EMBED;
_loadManually = loadManually;
-
+
return self;
}
@@ -123,7 +140,7 @@ using namespace WebCore;
return YES;
}
-- (NSMutableURLRequest *)requestWithURLCString:(const char *)URLCString
+- (NSURL *)URLWithCString:(const char *)URLCString
{
if (!URLCString)
return nil;
@@ -137,6 +154,15 @@ using namespace WebCore;
if (!URL)
return nil;
+ return URL;
+}
+
+- (NSMutableURLRequest *)requestWithURLCString:(const char *)URLCString
+{
+ NSURL *URL = [self URLWithCString:URLCString];
+ if (!URL)
+ return nil;
+
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
Frame* frame = core([self webFrame]);
if (!frame)
@@ -193,6 +219,11 @@ using namespace WebCore;
ASSERT_NOT_REACHED();
}
+- (void)sendModifierEventWithKeyCode:(int)keyCode character:(char)character
+{
+ ASSERT_NOT_REACHED();
+}
+
- (void)removeTrackingRect
{
if (_trackingTag) {
@@ -327,6 +358,9 @@ using namespace WebCore;
if (_isStarted)
return;
+ if (_triedAndFailedToCreatePlugin)
+ return;
+
ASSERT([self webView]);
if (![[[self webView] preferences] arePlugInsEnabled])
@@ -348,8 +382,10 @@ using namespace WebCore;
if (!wasDeferring)
page->setDefersLoading(false);
- if (!result)
+ if (!result) {
+ _triedAndFailedToCreatePlugin = YES;
return;
+ }
_isStarted = YES;
[[self webView] addPluginInstanceView:self];
@@ -484,14 +520,14 @@ using namespace WebCore;
- (void)windowBecameKey:(NSNotification *)notification
{
[self sendActivateEvent:YES];
- [self setNeedsDisplay:YES];
+ [self invalidatePluginContentRect:[self bounds]];
[self restartTimers];
}
- (void)windowResignedKey:(NSNotification *)notification
{
[self sendActivateEvent:NO];
- [self setNeedsDisplay:YES];
+ [self invalidatePluginContentRect:[self bounds]];
[self restartTimers];
}
@@ -527,7 +563,7 @@ using namespace WebCore;
}
} else {
[self stop];
- [self setNeedsDisplay:YES];
+ [self invalidatePluginContentRect:[self bounds]];
}
}
}
@@ -596,26 +632,24 @@ using namespace WebCore;
return _element.get();
}
-// We want to treat these as regular keyboard events.
-
- (void)cut:(id)sender
{
- [self keyDown:[NSApp currentEvent]];
+ [self sendModifierEventWithKeyCode:7 character:'x'];
}
- (void)copy:(id)sender
{
- [self keyDown:[NSApp currentEvent]];
+ [self sendModifierEventWithKeyCode:8 character:'c'];
}
- (void)paste:(id)sender
{
- [self keyDown:[NSApp currentEvent]];
+ [self sendModifierEventWithKeyCode:9 character:'v'];
}
- (void)selectAll:(id)sender
{
- [self keyDown:[NSApp currentEvent]];
+ [self sendModifierEventWithKeyCode:0 character:'a'];
}
// AppKit doesn't call mouseDown or mouseUp on right-click. Simulate control-click
@@ -630,7 +664,226 @@ using namespace WebCore;
[self mouseUp:theEvent];
}
+
+- (BOOL)convertFromX:(double)sourceX andY:(double)sourceY space:(NPCoordinateSpace)sourceSpace
+ toX:(double *)destX andY:(double *)destY space:(NPCoordinateSpace)destSpace
+{
+ // Nothing to do
+ if (sourceSpace == destSpace)
+ return TRUE;
+
+ NSPoint sourcePoint = NSMakePoint(sourceX, sourceY);
+
+ NSPoint sourcePointInScreenSpace;
+
+ // First convert to screen space
+ switch (sourceSpace) {
+ case NPCoordinateSpacePlugin:
+ sourcePointInScreenSpace = [self convertPoint:sourcePoint toView:nil];
+ sourcePointInScreenSpace = [[self currentWindow] convertBaseToScreen:sourcePointInScreenSpace];
+ break;
+
+ case NPCoordinateSpaceWindow:
+ sourcePointInScreenSpace = [[self currentWindow] convertBaseToScreen:sourcePoint];
+ break;
+
+ case NPCoordinateSpaceFlippedWindow:
+ sourcePoint.y = [[self currentWindow] frame].size.height - sourcePoint.y;
+ sourcePointInScreenSpace = [[self currentWindow] convertBaseToScreen:sourcePoint];
+ break;
+
+ case NPCoordinateSpaceScreen:
+ sourcePointInScreenSpace = sourcePoint;
+ break;
+
+ case NPCoordinateSpaceFlippedScreen:
+ sourcePoint.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - sourcePoint.y;
+ sourcePointInScreenSpace = sourcePoint;
+ break;
+ default:
+ return FALSE;
+ }
+
+ NSPoint destPoint;
+
+ // Then convert back to the destination space
+ switch (destSpace) {
+ case NPCoordinateSpacePlugin:
+ destPoint = [[self currentWindow] convertScreenToBase:sourcePointInScreenSpace];
+ destPoint = [self convertPoint:destPoint fromView:nil];
+ break;
+
+ case NPCoordinateSpaceWindow:
+ destPoint = [[self currentWindow] convertScreenToBase:sourcePointInScreenSpace];
+ break;
+
+ case NPCoordinateSpaceFlippedWindow:
+ destPoint = [[self currentWindow] convertScreenToBase:sourcePointInScreenSpace];
+ destPoint.y = [[self currentWindow] frame].size.height - destPoint.y;
+ break;
+
+ case NPCoordinateSpaceScreen:
+ destPoint = sourcePointInScreenSpace;
+ break;
+
+ case NPCoordinateSpaceFlippedScreen:
+ destPoint = sourcePointInScreenSpace;
+ destPoint.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - destPoint.y;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ if (destX)
+ *destX = destPoint.x;
+ if (destY)
+ *destY = destPoint.y;
+
+ return TRUE;
+}
+
+
+- (CString)resolvedURLStringForURL:(const char*)url target:(const char*)target;
+{
+ String relativeURLString = String::fromUTF8(url);
+ if (relativeURLString.isNull())
+ return CString();
+
+ Frame* frame = core([self webFrame]);
+ if (!frame)
+ return CString();
+
+ Frame* targetFrame = frame->tree()->find(String::fromUTF8(target));
+ if (!targetFrame)
+ return CString();
+
+ if (!frame->document()->securityOrigin()->canAccess(targetFrame->document()->securityOrigin()))
+ return CString();
+
+ KURL absoluteURL = targetFrame->loader()->completeURL(relativeURLString);
+ return absoluteURL.string().utf8();
+}
+
+- (void)invalidatePluginContentRect:(NSRect)rect
+{
+ if (RenderBoxModelObject *renderer = toRenderBoxModelObject(_element->renderer())) {
+ IntRect contentRect(rect);
+ contentRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop());
+
+ renderer->repaintRectangle(contentRect);
+ }
+}
+
@end
+namespace WebKit {
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+CString proxiesForURL(NSURL *url)
+{
+ RetainPtr<CFDictionaryRef> systemProxies(AdoptCF, CFNetworkCopySystemProxySettings());
+ if (!systemProxies)
+ return "DIRECT";
+
+ RetainPtr<CFArrayRef> proxiesForURL(AdoptCF, CFNetworkCopyProxiesForURL((CFURLRef)url, systemProxies.get()));
+ CFIndex proxyCount = proxiesForURL ? CFArrayGetCount(proxiesForURL.get()) : 0;
+ if (!proxyCount)
+ return "DIRECT";
+
+ // proxiesForURL is a CFArray of CFDictionaries. Each dictionary represents a proxy.
+ // The format of the result should be:
+ // "PROXY host[:port]" (for HTTP proxy) or
+ // "SOCKS host[:port]" (for SOCKS proxy) or
+ // A combination of the above, separated by semicolon, in the order that they should be tried.
+ String proxies;
+ for (CFIndex i = 0; i < proxyCount; ++i) {
+ CFDictionaryRef proxy = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(proxiesForURL.get(), i));
+ if (!proxy)
+ continue;
+
+ CFStringRef type = static_cast<CFStringRef>(CFDictionaryGetValue(proxy, kCFProxyTypeKey));
+ bool isHTTP = type == kCFProxyTypeHTTP || type == kCFProxyTypeHTTPS;
+ bool isSOCKS = type == kCFProxyTypeSOCKS;
+
+ // We can only report HTTP and SOCKS proxies.
+ if (!isHTTP && !isSOCKS)
+ continue;
+
+ CFStringRef host = static_cast<CFStringRef>(CFDictionaryGetValue(proxy, kCFProxyHostNameKey));
+ CFNumberRef port = static_cast<CFNumberRef>(CFDictionaryGetValue(proxy, kCFProxyPortNumberKey));
+
+ // If we are inserting multiple entries, add a separator
+ if (!proxies.isEmpty())
+ proxies += ";";
+
+ if (isHTTP)
+ proxies += "PROXY ";
+ else if (isSOCKS)
+ proxies += "SOCKS ";
+
+ proxies += host;
+
+ if (port) {
+ SInt32 intPort;
+ CFNumberGetValue(port, kCFNumberSInt32Type, &intPort);
+
+ proxies += ":" + String::number(intPort);
+ }
+ }
+
+ if (proxies.isEmpty())
+ return "DIRECT";
+
+ return proxies.utf8();
+}
+#endif
+
+bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
+ CString& username, CString& password)
+{
+ if (strcasecmp(protocolStr, "http") != 0 &&
+ strcasecmp(protocolStr, "https") != 0)
+ return false;
+
+ NSString *host = [NSString stringWithUTF8String:hostStr];
+ if (!hostStr)
+ return false;
+
+ NSString *protocol = [NSString stringWithUTF8String:protocolStr];
+ if (!protocol)
+ return false;
+
+ NSString *realm = [NSString stringWithUTF8String:realmStr];
+ if (!realm)
+ return NPERR_GENERIC_ERROR;
+
+ NSString *authenticationMethod = NSURLAuthenticationMethodDefault;
+ if (!strcasecmp(protocolStr, "http")) {
+ if (!strcasecmp(schemeStr, "basic"))
+ authenticationMethod = NSURLAuthenticationMethodHTTPBasic;
+ else if (!strcasecmp(schemeStr, "digest"))
+ authenticationMethod = NSURLAuthenticationMethodHTTPDigest;
+ }
+
+ RetainPtr<NSURLProtectionSpace> protectionSpace(AdoptNS, [[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:authenticationMethod]);
+
+ NSURLCredential *credential = WebCoreCredentialStorage::get(protectionSpace.get());
+ if (!credential)
+ credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace.get()];
+ if (!credential)
+ return false;
+
+ if (![credential hasPassword])
+ return false;
+
+ username = [[credential user] UTF8String];
+ password = [[credential password] UTF8String];
+
+ return true;
+}
+
+} // namespace WebKit
+
#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.h b/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.h
new file mode 100644
index 0000000..e9b14a7
--- /dev/null
+++ b/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebBaseNetscapePluginView.h"
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+
+@interface WebNetscapeContainerCheckContextInfo : NSObject {
+ uint32 _checkRequestID;
+ void (*_callback)(NPP npp, uint32, NPBool, void *);
+ void *_context;
+}
+
+- (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context;
+- (uint32)checkRequestID;
+- (void (*)(NPP npp, uint32, NPBool, void*))callback;
+- (void*)context;
+
+@end
+
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.mm b/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.mm
new file mode 100644
index 0000000..34a0ec1
--- /dev/null
+++ b/WebKit/mac/Plugins/WebNetscapeContainerCheckContextInfo.mm
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebNetscapeContainerCheckContextInfo.h"
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+
+@implementation WebNetscapeContainerCheckContextInfo
+
+- (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _checkRequestID = checkRequestID;
+ _callback = callbackFunc;
+ _context = context;
+ return self;
+}
+
+- (uint32)checkRequestID
+{
+ return _checkRequestID;
+}
+
+- (void (*)(NPP npp, uint32, NPBool, void*))callback
+{
+ return _callback;
+}
+
+- (void*)context
+{
+ return _context;
+}
+
+@end
+
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.h b/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.h
new file mode 100644
index 0000000..dfde2f7
--- /dev/null
+++ b/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebNetscapeContainerCheckPrivate_h
+#define WebNetscapeContainerCheckPrivate_h
+
+#include <WebKit/npapi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WKNVBrowserContainerCheckFuncs 1701
+#define WKNVBrowserContainerCheckFuncsVersion 2
+
+#define WKNVBrowserContainerCheckFuncsVersionHasGetLocation 2
+
+typedef uint32 (*WKN_CheckIfAllowedToLoadURLProcPtr)(NPP npp, const char* url, const char* frame, void (*callbackFunc)(NPP npp, uint32, NPBool allowed, void* context), void* context);
+typedef void (*WKN_CancelCheckIfAllowedToLoadURLProcPtr)(NPP npp, uint32);
+typedef char* (*WKN_ResolveURLProcPtr)(NPP npp, const char* url, const char* target);
+
+uint32 WKN_CheckIfAllowedToLoadURL(NPP npp, const char* url, const char* frame, void (*callbackFunc)(NPP npp, uint32, NPBool allowed, void* context), void* context);
+void WKN_CancelCheckIfAllowedToLoadURL(NPP npp, uint32);
+char* WKN_ResolveURL(NPP npp, const char* url, const char* target);
+
+typedef struct _WKNBrowserContainerCheckFuncs {
+ uint16 size;
+ uint16 version;
+
+ WKN_CheckIfAllowedToLoadURLProcPtr checkIfAllowedToLoadURL;
+ WKN_CancelCheckIfAllowedToLoadURLProcPtr cancelCheckIfAllowedToLoadURL;
+ WKN_ResolveURLProcPtr resolveURL;
+} WKNBrowserContainerCheckFuncs;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WebNetscapeContainerCheckPrivate_h
diff --git a/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.mm b/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.mm
new file mode 100644
index 0000000..d326b56
--- /dev/null
+++ b/WebKit/mac/Plugins/WebNetscapeContainerCheckPrivate.mm
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebNetscapeContainerCheckPrivate.h"
+
+#import "WebNetscapePluginView.h"
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+
+WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs()
+{
+ static WKNBrowserContainerCheckFuncs funcs = {
+ sizeof(WKNBrowserContainerCheckFuncs),
+ WKNVBrowserContainerCheckFuncsVersion,
+ WKN_CheckIfAllowedToLoadURL,
+ WKN_CancelCheckIfAllowedToLoadURL,
+ WKN_ResolveURL
+ };
+
+ return &funcs;
+}
+
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandler.h b/WebKit/mac/Plugins/WebNetscapePluginEventHandler.h
index d00796f..b9bdf7d 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginEventHandler.h
+++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandler.h
@@ -40,7 +40,7 @@ public:
static WebNetscapePluginEventHandler* create(WebNetscapePluginView*);
virtual ~WebNetscapePluginEventHandler() { }
- virtual void drawRect(const NSRect&) = 0;
+ virtual void drawRect(CGContextRef, const NSRect&) = 0;
virtual void mouseDown(NSEvent*) = 0;
virtual void mouseDragged(NSEvent*) = 0;
@@ -53,6 +53,7 @@ public:
virtual void keyDown(NSEvent*) = 0;
virtual void keyUp(NSEvent*) = 0;
virtual void flagsChanged(NSEvent*) = 0;
+ virtual void syntheticKeyDownWithCommandModifier(int keyCode, char character) = 0;
virtual void focusChanged(bool hasFocus) = 0;
virtual void windowFocusChanged(bool hasFocus) = 0;
diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.h b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.h
index b01922a..676fd17 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.h
+++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.h
@@ -37,7 +37,7 @@ class WebNetscapePluginEventHandlerCarbon : public WebNetscapePluginEventHandler
public:
WebNetscapePluginEventHandlerCarbon(WebNetscapePluginView*);
- virtual void drawRect(const NSRect&);
+ virtual void drawRect(CGContextRef, const NSRect&);
virtual void mouseDown(NSEvent*);
virtual void mouseDragged(NSEvent*);
@@ -50,7 +50,8 @@ public:
virtual void keyDown(NSEvent*);
virtual void keyUp(NSEvent*);
virtual void flagsChanged(NSEvent*);
-
+ virtual void syntheticKeyDownWithCommandModifier(int keyCode, char character);
+
virtual void windowFocusChanged(bool hasFocus);
virtual void focusChanged(bool hasFocus);
diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm
index 7612322..d8324f7 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm
@@ -123,7 +123,7 @@ void WebNetscapePluginEventHandlerCarbon::sendNullEvent()
sendEvent(&event);
}
-void WebNetscapePluginEventHandlerCarbon::drawRect(const NSRect&)
+void WebNetscapePluginEventHandlerCarbon::drawRect(CGContextRef, const NSRect&)
{
EventRecord event;
@@ -209,6 +209,17 @@ void WebNetscapePluginEventHandlerCarbon::keyDown(NSEvent *theEvent)
WKSendKeyEventToTSM(theEvent);
}
+void WebNetscapePluginEventHandlerCarbon::syntheticKeyDownWithCommandModifier(int keyCode, char character)
+{
+ EventRecord event;
+ getCarbonEvent(&event);
+
+ event.what = ::keyDown;
+ event.modifiers |= cmdKey;
+ event.message = keyCode << 8 | character;
+ sendEvent(&event);
+}
+
static UInt32 keyMessageForEvent(NSEvent *event)
{
NSData *data = [[event characters] dataUsingEncoding:CFStringConvertEncodingToNSStringEncoding(CFStringGetSystemEncoding())];
diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h
index 4613fcd..3a2f03f 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h
+++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h
@@ -35,7 +35,7 @@ class WebNetscapePluginEventHandlerCocoa : public WebNetscapePluginEventHandler
public:
WebNetscapePluginEventHandlerCocoa(WebNetscapePluginView*);
- virtual void drawRect(const NSRect&);
+ virtual void drawRect(CGContextRef, const NSRect&);
virtual void mouseDown(NSEvent*);
virtual void mouseDragged(NSEvent*);
@@ -48,7 +48,8 @@ public:
virtual void keyDown(NSEvent*);
virtual void keyUp(NSEvent*);
virtual void flagsChanged(NSEvent*);
-
+ virtual void syntheticKeyDownWithCommandModifier(int keyCode, char character);
+
virtual void windowFocusChanged(bool hasFocus);
virtual void focusChanged(bool hasFocus);
diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm
index e3fb362..a8ad861 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm
@@ -46,16 +46,19 @@ static inline void initializeEvent(NPCocoaEvent* event, NPCocoaEventType type)
event->version = 0;
}
-void WebNetscapePluginEventHandlerCocoa::drawRect(const NSRect& rect)
+void WebNetscapePluginEventHandlerCocoa::drawRect(CGContextRef context, const NSRect& rect)
{
NPCocoaEvent event;
initializeEvent(&event, NPCocoaEventDrawRect);
+ event.data.draw.context = context;
event.data.draw.x = rect.origin.x;
event.data.draw.y = rect.origin.y;
event.data.draw.width = rect.size.width;
event.data.draw.height = rect.size.height;
+ RetainPtr<CGContextRef> protect(context);
+
sendEvent(&event);
}
@@ -151,6 +154,23 @@ void WebNetscapePluginEventHandlerCocoa::flagsChanged(NSEvent *nsEvent)
sendEvent(&event);
}
+void WebNetscapePluginEventHandlerCocoa::syntheticKeyDownWithCommandModifier(int keyCode, char character)
+{
+ char nullTerminatedString[] = { character, '\0' };
+
+ RetainPtr<NSString> characters(AdoptNS, [[NSString alloc] initWithUTF8String:nullTerminatedString]);
+
+ NPCocoaEvent event;
+ initializeEvent(&event, NPCocoaEventKeyDown);
+ event.data.key.modifierFlags = NSCommandKeyMask;
+ event.data.key.keyCode = keyCode;
+ event.data.key.isARepeat = false;
+ event.data.key.characters = (NPNSString *)characters.get();
+ event.data.key.charactersIgnoringModifiers = (NPNSString *)characters.get();
+
+ sendEvent(&event);
+}
+
bool WebNetscapePluginEventHandlerCocoa::sendKeyEvent(NSEvent* nsEvent, NPCocoaEventType type)
{
NPCocoaEvent event;
diff --git a/WebKit/mac/Plugins/WebNetscapePluginPackage.mm b/WebKit/mac/Plugins/WebNetscapePluginPackage.mm
index 38ddddc..5c10d95 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginPackage.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginPackage.mm
@@ -31,6 +31,7 @@
#import "WebKitLogging.h"
#import "WebKitNSStringExtras.h"
+#import "WebNSFileManagerExtras.h"
#import "WebNSObjectExtras.h"
#import "WebNetscapeDeprecatedFunctions.h"
#import <WebCore/npruntime_impl.h>
@@ -216,7 +217,8 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
} else {
#ifdef SUPPORT_CFM
// Single-file plug-in with resource fork
- type = [[[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES] fileHFSTypeCode];
+ NSString *destinationPath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:path error:0];
+ type = [[[NSFileManager defaultManager] attributesOfItemAtPath:destinationPath error:0] fileHFSTypeCode];
isBundle = NO;
isCFM = YES;
#else
@@ -455,9 +457,13 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
browserFuncs.pushpopupsenabledstate = (NPN_PushPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PushPopupsEnabledState);
browserFuncs.poppopupsenabledstate = (NPN_PopPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopPopupsEnabledState);
browserFuncs.pluginthreadasynccall = (NPN_PluginThreadAsyncCallProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PluginThreadAsyncCall);
+ browserFuncs.getvalueforurl = (NPN_GetValueForURLProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetValueForURL);
+ browserFuncs.setvalueforurl = (NPN_SetValueForURLProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_SetValueForURL);
+ browserFuncs.getauthenticationinfo = (NPN_GetAuthenticationInfoProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetAuthenticationInfo);
browserFuncs.scheduletimer = (NPN_ScheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ScheduleTimer);
browserFuncs.unscheduletimer = (NPN_UnscheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_UnscheduleTimer);
browserFuncs.popupcontextmenu = (NPN_PopUpContextMenuProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopUpContextMenu);
+ browserFuncs.convertpoint = (NPN_ConvertPointProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ConvertPoint);
browserFuncs.releasevariantvalue = (NPN_ReleaseVariantValueProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_ReleaseVariantValue);
browserFuncs.getstringidentifier = (NPN_GetStringIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifier);
@@ -564,10 +570,14 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
browserFuncs.pluginthreadasynccall = NPN_PluginThreadAsyncCall;
+ browserFuncs.getvalueforurl = NPN_GetValueForURL;
+ browserFuncs.setvalueforurl = NPN_SetValueForURL;
+ browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo;
browserFuncs.scheduletimer = NPN_ScheduleTimer;
browserFuncs.unscheduletimer = NPN_UnscheduleTimer;
browserFuncs.popupcontextmenu = NPN_PopUpContextMenu;
-
+ browserFuncs.convertpoint = NPN_ConvertPoint;
+
browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.h b/WebKit/mac/Plugins/WebNetscapePluginView.h
index 783b7fb..b2583da 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.h
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.h
@@ -30,6 +30,7 @@
#import "WebBaseNetscapePluginView.h"
+#import "WebNetscapeContainerCheckPrivate.h"
#import <WebKit/npfunctions.h>
#import <WebKit/npapi.h>
#import <wtf/HashMap.h>
@@ -57,7 +58,7 @@ typedef union PluginPort {
// for the plug-in to function correctly. (rdar://problem/4699455)
#define WebNetscapePluginView WebNetscapePluginDocumentView
-@interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader>
+@interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, WebPluginContainerCheckController>
{
RefPtr<WebNetscapePluginStream> _manualStream;
#ifndef BUILDING_ON_TIGER
@@ -101,6 +102,9 @@ typedef union PluginPort {
BOOL _isFlash;
BOOL _isSilverlight;
+
+ NSMutableDictionary *_containerChecksInProgress;
+ uint32 _currentContainerCheckRequestID;
}
+ (WebNetscapePluginView *)currentPluginView;
@@ -139,6 +143,8 @@ typedef union PluginPort {
- (void)didCallPlugInFunction;
- (void)handleMouseMoved:(NSEvent *)event;
+- (uint32)checkIfAllowedToLoadURL:(const char*)urlCString frame:(const char*)frameNameCString callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context;
+- (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID;
@end
@@ -164,8 +170,15 @@ typedef union PluginPort {
- (uint32)scheduleTimerWithInterval:(uint32)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32 timerID))timerFunc;
- (void)unscheduleTimer:(uint32)timerID;
- (NPError)popUpContextMenu:(NPMenu *)menu;
-
+- (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32*)length;
+- (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32)length;
+- (NPError)getAuthenticationInfoWithProtocol:(const char*) protocol host:(const char*)host port:(int32)port scheme:(const char*)scheme realm:(const char*)realm
+ username:(char**)username usernameLength:(uint32*)usernameLength
+ password:(char**)password passwordLength:(uint32*)passwordLength;
+- (char*)resolveURL:(const char*)url forTarget:(const char*)target;
@end
+WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs();
+
#endif
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm
index cef33a4..24c5944 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm
@@ -34,9 +34,9 @@
#import "WebDefaultUIDelegate.h"
#import "WebFrameInternal.h"
#import "WebFrameView.h"
-#import "WebGraphicsExtras.h"
#import "WebKitErrorsPrivate.h"
#import "WebKitLogging.h"
+#import "WebNetscapeContainerCheckPrivate.h"
#import "WebKitNSStringExtras.h"
#import "WebKitSystemInterface.h"
#import "WebNSDataExtras.h"
@@ -47,6 +47,8 @@
#import "WebNSViewExtras.h"
#import "WebNetscapePluginPackage.h"
#import "WebBaseNetscapePluginStream.h"
+#import "WebPluginContainerCheck.h"
+#import "WebNetscapeContainerCheckContextInfo.h"
#import "WebNetscapePluginEventHandler.h"
#import "WebNullPluginView.h"
#import "WebPreferences.h"
@@ -56,6 +58,8 @@
#import <Carbon/Carbon.h>
#import <runtime/JSLock.h>
#import <WebCore/npruntime_impl.h>
+#import <WebCore/CookieJar.h>
+#import <WebCore/CString.h>
#import <WebCore/DocumentLoader.h>
#import <WebCore/Element.h>
#import <WebCore/Frame.h>
@@ -80,6 +84,7 @@ using std::max;
#define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification"
using namespace WebCore;
+using namespace WebKit;
static inline bool isDrawingModelQuickDraw(NPDrawingModel drawingModel)
{
@@ -507,14 +512,14 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
portState = (PortState)cgPortState;
cgPortState->context = context;
- // Update the plugin's window/context
-#ifdef NP_NO_CARBON
- nPort.cgPort.window = (NPNSWindow *)[self currentWindow];
-#else
- nPort.cgPort.window = _eventHandler->platformWindow([self currentWindow]);
+#ifndef NP_NO_CARBON
+ if (eventModel != NPEventModelCocoa) {
+ // Update the plugin's window/context
+ nPort.cgPort.window = windowRef;
+ nPort.cgPort.context = context;
+ window.window = &nPort.cgPort;
+ }
#endif /* NP_NO_CARBON */
- nPort.cgPort.context = context;
- window.window = &nPort.cgPort;
// Save current graphics context's state; will be restored by -restorePortState:
CGContextSaveGState(context);
@@ -539,7 +544,6 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
}
case NPDrawingModelCoreAnimation:
- window.window = [self currentWindow];
// Just set the port state to a dummy value.
portState = (PortState)1;
break;
@@ -590,12 +594,15 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
}
#endif /* NP_NO_QUICKDRAW */
- case NPDrawingModelCoreGraphics:
+ case NPDrawingModelCoreGraphics: {
ASSERT([NSView focusView] == self);
- ASSERT(((PortState_CG *)portState)->context == nPort.cgPort.context);
- CGContextRestoreGState(nPort.cgPort.context);
+
+ CGContextRef context = ((PortState_CG *)portState)->context;
+ ASSERT(!nPort.cgPort.context || (context == nPort.cgPort.context));
+ CGContextRestoreGState(context);
break;
-
+ }
+
case NPDrawingModelCoreAnimation:
ASSERT(portState == (PortState)1);
break;
@@ -661,8 +668,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
BOOL acceptedEvent;
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
- acceptedEvent = ![_pluginPackage.get() pluginFuncs]->event(plugin, event);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
+ acceptedEvent = [_pluginPackage.get() pluginFuncs]->event(plugin, event);
}
[self didCallPlugInFunction];
@@ -685,7 +692,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
{
ASSERT(_eventHandler);
- _eventHandler->drawRect(rect);
+ CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+ _eventHandler->drawRect(context, rect);
}
- (void)stopTimers
@@ -822,6 +830,14 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
_eventHandler->flagsChanged(theEvent);
}
+- (void)sendModifierEventWithKeyCode:(int)keyCode character:(char)character
+{
+ if (!_isStarted)
+ return;
+
+ _eventHandler->syntheticKeyDownWithCommandModifier(keyCode, character);
+}
+
#pragma mark WEB_NETSCAPE_PLUGIN
- (BOOL)isNewWindowEqualToOldWindow
@@ -956,7 +972,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
inSetWindow = YES;
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
npErr = [_pluginPackage.get() pluginFuncs]->setwindow(plugin, &window);
}
[self didCallPlugInFunction];
@@ -1077,7 +1093,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
{
[super setLayer:newLayer];
- if (_pluginLayer) {
+ if (newLayer && _pluginLayer) {
+ _pluginLayer.get().frame = [newLayer frame];
_pluginLayer.get().autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
[newLayer addSublayer:_pluginLayer.get()];
}
@@ -1196,6 +1213,83 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
}
}
+- (uint32)checkIfAllowedToLoadURL:(const char*)urlCString frame:(const char*)frameNameCString
+ callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc
+ context:(void*)context
+{
+ if (!_containerChecksInProgress)
+ _containerChecksInProgress = [[NSMutableDictionary alloc] init];
+
+ NSString *frameName = frameNameCString ? [NSString stringWithCString:frameNameCString encoding:NSISOLatin1StringEncoding] : nil;
+
+ ++_currentContainerCheckRequestID;
+ WebNetscapeContainerCheckContextInfo *contextInfo = [[WebNetscapeContainerCheckContextInfo alloc] initWithCheckRequestID:_currentContainerCheckRequestID
+ callbackFunc:callbackFunc
+ context:context];
+
+ WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:[self requestWithURLCString:urlCString]
+ target:frameName
+ resultObject:self
+ selector:@selector(_containerCheckResult:contextInfo:)
+ controller:self
+ contextInfo:contextInfo];
+
+ [contextInfo release];
+ [_containerChecksInProgress setObject:check forKey:[NSNumber numberWithInt:_currentContainerCheckRequestID]];
+ [check start];
+
+ return _currentContainerCheckRequestID;
+}
+
+- (void)_containerCheckResult:(PolicyAction)policy contextInfo:(id)contextInfo
+{
+ ASSERT([contextInfo isKindOfClass:[WebNetscapeContainerCheckContextInfo class]]);
+ void (*pluginCallback)(NPP npp, uint32, NPBool, void*) = [contextInfo callback];
+
+ if (!pluginCallback) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ pluginCallback([self plugin], [contextInfo checkRequestID], (policy == PolicyUse), [contextInfo context]);
+}
+
+- (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID
+{
+ WebPluginContainerCheck *check = (WebPluginContainerCheck *)[_containerChecksInProgress objectForKey:[NSNumber numberWithInt:checkID]];
+
+ if (!check)
+ return;
+
+ [check cancel];
+ [_containerChecksInProgress removeObjectForKey:[NSNumber numberWithInt:checkID]];
+}
+
+// WebPluginContainerCheck automatically calls this method after invoking our _containerCheckResult: selector.
+// It works this way because calling -[WebPluginContainerCheck cancel] allows it to do it's teardown process.
+- (void)_webPluginContainerCancelCheckIfAllowedToLoadRequest:(id)webPluginContainerCheck
+{
+ ASSERT([webPluginContainerCheck isKindOfClass:[WebPluginContainerCheck class]]);
+ WebPluginContainerCheck *check = (WebPluginContainerCheck *)webPluginContainerCheck;
+ ASSERT([check contextInfo] && [[check contextInfo] isKindOfClass:[WebNetscapeContainerCheckContextInfo class]]);
+
+ [self cancelCheckIfAllowedToLoadURL:[[check contextInfo] checkRequestID]];
+}
+
+#ifdef BUILDING_ON_TIGER
+// The Tiger compiler requires these two methods be present. Otherwise it doesn't think WebNetscapePluginView
+// conforms to the WebPluginContainerCheckController protocol.
+- (WebView *)webView
+{
+ return [super webView];
+}
+
+- (WebFrame *)webFrame
+{
+ return [super webFrame];
+}
+#endif
+
#pragma mark NSVIEW
- (id)initWithFrame:(NSRect)frame
@@ -1248,7 +1342,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
if (timers) {
deleteAllValues(*timers);
delete timers;
- }
+ }
+
+ [_containerChecksInProgress release];
}
- (void)disconnectStream:(WebNetscapePluginStream*)stream
@@ -1311,7 +1407,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
NPError error;
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
error = [_pluginPackage.get() pluginFuncs]->getvalue(plugin, NPPVpluginScriptableNPObject, &value);
}
[self didCallPlugInFunction];
@@ -1369,7 +1465,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
contentURL:[response URL]
pluginPageURL:nil
pluginName:nil // FIXME: Get this from somewhere
- MIMEType:[response _webcore_MIMEType]];
+ MIMEType:[response MIMEType]];
[[self dataSource] _documentLoader]->cancelMainResourceLoad(error);
[error release];
return;
@@ -1442,7 +1538,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
if ([JSPluginRequest sendNotification]) {
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[_pluginPackage.get() pluginFuncs]->urlnotify(plugin, [URL _web_URLCString], NPRES_DONE, [JSPluginRequest notifyData]);
}
[self didCallPlugInFunction];
@@ -1474,7 +1570,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[_pluginPackage.get() pluginFuncs]->urlnotify(plugin, [[[pluginRequest request] URL] _web_URLCString], reason, [pluginRequest notifyData]);
}
[self didCallPlugInFunction];
@@ -1518,7 +1614,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
if ([pluginRequest sendNotification]) {
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[_pluginPackage.get() pluginFuncs]->urlnotify(plugin, [[[pluginRequest request] URL] _web_URLCString], NPERR_GENERIC_ERROR, [pluginRequest notifyData]);
}
[self didCallPlugInFunction];
@@ -1808,7 +1904,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
-(void)invalidateRect:(NPRect *)invalidRect
{
LOG(Plugins, "NPN_InvalidateRect");
- [self setNeedsDisplayInRect:NSMakeRect(invalidRect->left, invalidRect->top,
+ [self invalidatePluginContentRect:NSMakeRect(invalidRect->left, invalidRect->top,
(float)invalidRect->right - invalidRect->left, (float)invalidRect->bottom - invalidRect->top)];
}
@@ -1838,13 +1934,13 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
break;
}
- [self setNeedsDisplayInRect:invalidRect];
+ [self invalidatePluginContentRect:invalidRect];
}
-(void)forceRedraw
{
LOG(Plugins, "forceRedraw");
- [self setNeedsDisplay:YES];
+ [self invalidatePluginContentRect:[self bounds]];
[[self window] displayIfNeeded];
}
@@ -1933,6 +2029,11 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
return NPERR_NO_ERROR;
}
+ case WKNVBrowserContainerCheckFuncs:
+ {
+ *(WKNBrowserContainerCheckFuncs **)value = browserContainerCheckFuncs();
+ return NPERR_NO_ERROR;
+ }
default:
break;
}
@@ -2044,6 +2145,118 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
return NPERR_NO_ERROR;
}
+- (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32*)length
+{
+ switch (variable) {
+ case NPNURLVCookie: {
+ if (!value)
+ break;
+
+ NSURL *URL = [self URLWithCString:url];
+ if (!URL)
+ break;
+
+ if (Frame* frame = core([self webFrame])) {
+ String cookieString = cookies(frame->document(), URL);
+ CString cookieStringUTF8 = cookieString.utf8();
+ if (cookieStringUTF8.isNull())
+ return NPERR_GENERIC_ERROR;
+
+ *value = static_cast<char*>(NPN_MemAlloc(cookieStringUTF8.length()));
+ memcpy(*value, cookieStringUTF8.data(), cookieStringUTF8.length());
+
+ if (length)
+ *length = cookieStringUTF8.length();
+ return NPERR_NO_ERROR;
+ }
+ break;
+ }
+ case NPNURLVProxy: {
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ if (!value)
+ break;
+
+ NSURL *URL = [self URLWithCString:url];
+ if (!URL)
+ break;
+
+ CString proxiesUTF8 = proxiesForURL(URL);
+
+ *value = static_cast<char*>(NPN_MemAlloc(proxiesUTF8.length()));
+ memcpy(*value, proxiesUTF8.data(), proxiesUTF8.length());
+
+ if (length)
+ *length = proxiesUTF8.length();
+
+ return NPERR_NO_ERROR;
+#else
+ break;
+#endif
+ }
+ }
+ return NPERR_GENERIC_ERROR;
+}
+
+- (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32)length
+{
+ switch (variable) {
+ case NPNURLVCookie: {
+ NSURL *URL = [self URLWithCString:url];
+ if (!URL)
+ break;
+
+ String cookieString = String::fromUTF8(value, length);
+ if (!cookieString)
+ break;
+
+ if (Frame* frame = core([self webFrame])) {
+ setCookies(frame->document(), URL, cookieString);
+ return NPERR_NO_ERROR;
+ }
+
+ break;
+ }
+ case NPNURLVProxy:
+ // Can't set the proxy for a URL.
+ break;
+ }
+ return NPERR_GENERIC_ERROR;
+}
+
+- (NPError)getAuthenticationInfoWithProtocol:(const char*)protocolStr host:(const char*)hostStr port:(int32)port scheme:(const char*)schemeStr realm:(const char*)realmStr
+ username:(char**)usernameStr usernameLength:(uint32*)usernameLength
+ password:(char**)passwordStr passwordLength:(uint32*)passwordLength
+{
+ if (!protocolStr || !hostStr || !schemeStr || !realmStr || !usernameStr || !usernameLength || !passwordStr || !passwordLength)
+ return NPERR_GENERIC_ERROR;
+
+ CString username;
+ CString password;
+ if (!getAuthenticationInfo(protocolStr, hostStr, port, schemeStr, realmStr, username, password))
+ return NPERR_GENERIC_ERROR;
+
+ *usernameLength = username.length();
+ *usernameStr = static_cast<char*>(NPN_MemAlloc(username.length()));
+ memcpy(*usernameStr, username.data(), username.length());
+
+ *passwordLength = password.length();
+ *passwordStr = static_cast<char*>(NPN_MemAlloc(password.length()));
+ memcpy(*passwordStr, password.data(), password.length());
+
+ return NPERR_NO_ERROR;
+}
+
+- (char*)resolveURL:(const char*)url forTarget:(const char*)target
+{
+ WebCore::CString location = [self resolvedURLStringForURL:url target:target];
+
+ if (location.isNull())
+ return 0;
+
+ // We use strdup here because the caller needs to free it with NPN_MemFree (which calls free).
+ return strdup(location.data());
+}
+
@end
@implementation WebNetscapePluginView (Internal)
@@ -2160,7 +2373,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
// Tell the plugin to print into the GWorld
[self willCallPlugInFunction];
{
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[_pluginPackage.get() pluginFuncs]->print(plugin, &npPrint);
}
[self didCallPlugInFunction];
diff --git a/WebKit/mac/Plugins/WebNullPluginView.mm b/WebKit/mac/Plugins/WebNullPluginView.mm
index 48e0e9d..bcc7a4b 100644
--- a/WebKit/mac/Plugins/WebNullPluginView.mm
+++ b/WebKit/mac/Plugins/WebNullPluginView.mm
@@ -28,9 +28,12 @@
#import "WebNullPluginView.h"
+#import "DOMElementInternal.h"
+#import "WebDelegateImplementationCaching.h"
#import "WebFrameInternal.h"
#import "WebViewInternal.h"
#import <WebCore/Document.h>
+#import <WebCore/Element.h>
@implementation WebNullPluginView
diff --git a/WebKit/mac/Plugins/WebPluginContainerCheck.h b/WebKit/mac/Plugins/WebPluginContainerCheck.h
index 1b7bbda..419be51 100644
--- a/WebKit/mac/Plugins/WebPluginContainerCheck.h
+++ b/WebKit/mac/Plugins/WebPluginContainerCheck.h
@@ -30,26 +30,31 @@
@class NSURLRequest;
@class NSString;
-@class WebPluginController;
+@class WebFrame;
+@class WebView;
@class WebPolicyDecisionListener;
+@protocol WebPluginContainerCheckController <NSObject>
+- (void)_webPluginContainerCancelCheckIfAllowedToLoadRequest:(id)checkIdentifier;
+- (WebFrame *)webFrame;
+- (WebView *)webView;
+@end
+
@interface WebPluginContainerCheck : NSObject
{
NSURLRequest *_request;
NSString *_target;
- WebPluginController *_controller;
+ id <WebPluginContainerCheckController> _controller;
id _resultObject;
SEL _resultSelector;
+ id _contextInfo;
BOOL _done;
WebPolicyDecisionListener *_listener;
}
-+ (id)checkWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(WebPluginController *)controller;
-
-- (id)initWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(WebPluginController *)controller;
-
++ (id)checkWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(id <WebPluginContainerCheckController>)controller contextInfo:(id)/*optional*/contextInfo;
- (void)start;
-
- (void)cancel;
+- (id)contextInfo;
@end
diff --git a/WebKit/mac/Plugins/WebPluginContainerCheck.mm b/WebKit/mac/Plugins/WebPluginContainerCheck.mm
index 5c9ecd7..2180b02 100644
--- a/WebKit/mac/Plugins/WebPluginContainerCheck.mm
+++ b/WebKit/mac/Plugins/WebPluginContainerCheck.mm
@@ -47,27 +47,28 @@ using namespace WebCore;
@implementation WebPluginContainerCheck
-+ (id)checkWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(WebPluginController *)controller
-{
- return [[[self alloc] initWithRequest:request target:target resultObject:obj selector:selector controller:controller] autorelease];
-}
-
-- (id)initWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(WebPluginController *)controller
+- (id)initWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(id <WebPluginContainerCheckController>)controller contextInfo:(id)contextInfo /*optional*/
{
if (!(self = [super init]))
return nil;
-
+
_request = [request copy];
_target = [target copy];
_resultObject = [obj retain];
_resultSelector = selector;
-
+ _contextInfo = [contextInfo retain];
+
// controller owns us so don't retain, to avoid cycle
_controller = controller;
-
+
return self;
}
++ (id)checkWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(id <WebPluginContainerCheckController>)controller contextInfo:(id)contextInfo /*optional*/
+{
+ return [[[self alloc] initWithRequest:request target:target resultObject:obj selector:selector controller:controller contextInfo:contextInfo] autorelease];
+}
+
- (void)finalize
{
// mandatory to complete or cancel before releasing this object
@@ -84,7 +85,10 @@ using namespace WebCore;
- (void)_continueWithPolicy:(PolicyAction)policy
{
- ((void (*)(id, SEL, BOOL))objc_msgSend)(_resultObject, _resultSelector, (policy == PolicyUse));
+ if (_contextInfo)
+ ((void (*)(id, SEL, BOOL, id))objc_msgSend)(_resultObject, _resultSelector, (policy == PolicyUse), _contextInfo);
+ else
+ ((void (*)(id, SEL, BOOL))objc_msgSend)(_resultObject, _resultSelector, (policy == PolicyUse));
// this will call indirectly call cancel
[_controller _webPluginContainerCancelCheckIfAllowedToLoadRequest:self];
@@ -173,8 +177,16 @@ using namespace WebCore;
_resultObject = nil;
_controller = nil;
+
+ [_contextInfo release];
+ _contextInfo = nil;
_done = YES;
}
+- (id)contextInfo
+{
+ return _contextInfo;
+}
+
@end
diff --git a/WebKit/mac/Plugins/WebPluginController.h b/WebKit/mac/Plugins/WebPluginController.h
index 58217c3..ffc07a4 100644
--- a/WebKit/mac/Plugins/WebPluginController.h
+++ b/WebKit/mac/Plugins/WebPluginController.h
@@ -27,6 +27,7 @@
*/
#import <WebKit/WebBasePluginPackage.h>
+#import <WebKit/WebPluginContainerCheck.h>
@class WebFrame;
@class WebHTMLView;
@@ -34,7 +35,7 @@
@class WebView;
@class WebDataSource;
-@interface WebPluginController : NSObject <WebPluginManualLoader>
+@interface WebPluginController : NSObject <WebPluginManualLoader, WebPluginContainerCheckController>
{
NSView *_documentView;
WebDataSource *_dataSource;
diff --git a/WebKit/mac/Plugins/WebPluginController.mm b/WebKit/mac/Plugins/WebPluginController.mm
index 54d9615..357cf7b 100644
--- a/WebKit/mac/Plugins/WebPluginController.mm
+++ b/WebKit/mac/Plugins/WebPluginController.mm
@@ -27,12 +27,27 @@
*/
-#import <WebKit/WebPluginController.h>
-
+#import "WebPluginController.h"
+
+#import "DOMNodeInternal.h"
+#import "WebDataSourceInternal.h"
+#import "WebFrameInternal.h"
+#import "WebFrameView.h"
+#import "WebHTMLViewPrivate.h"
+#import "WebKitErrorsPrivate.h"
+#import "WebKitLogging.h"
+#import "WebNSURLExtras.h"
+#import "WebNSViewExtras.h"
+#import "WebPlugin.h"
+#import "WebPluginContainer.h"
+#import "WebPluginContainerCheck.h"
+#import "WebPluginPackage.h"
+#import "WebPluginPrivate.h"
+#import "WebPluginViewFactory.h"
+#import "WebUIDelegate.h"
+#import "WebViewInternal.h"
#import <Foundation/NSURLRequest.h>
-#import <runtime/JSLock.h>
#import <WebCore/DocumentLoader.h>
-#import <WebCore/DOMNodeInternal.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameLoader.h>
#import <WebCore/HTMLMediaElement.h>
@@ -42,22 +57,7 @@
#import <WebCore/ResourceRequest.h>
#import <WebCore/ScriptController.h>
#import <WebCore/WebCoreURLResponse.h>
-#import <WebKit/WebDataSourceInternal.h>
-#import <WebKit/WebFrameInternal.h>
-#import <WebKit/WebFrameView.h>
-#import <WebKit/WebHTMLViewPrivate.h>
-#import <WebKit/WebKitErrorsPrivate.h>
-#import <WebKit/WebKitLogging.h>
-#import <WebKit/WebNSURLExtras.h>
-#import <WebKit/WebNSViewExtras.h>
-#import <WebKit/WebPlugin.h>
-#import <WebKit/WebPluginContainer.h>
-#import <WebKit/WebPluginContainerCheck.h>
-#import <WebKit/WebPluginPackage.h>
-#import <WebKit/WebPluginPrivate.h>
-#import <WebKit/WebPluginViewFactory.h>
-#import <WebKit/WebUIDelegate.h>
-#import <WebKit/WebViewInternal.h>
+#import <runtime/JSLock.h>
using namespace WebCore;
using namespace HTMLNames;
@@ -90,10 +90,10 @@ static NSMutableSet *pluginViews = nil;
NSView *view = nil;
if ([viewFactory respondsToSelector:@selector(plugInViewWithArguments:)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
view = [viewFactory plugInViewWithArguments:arguments];
} else if ([viewFactory respondsToSelector:@selector(pluginViewWithArguments:)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
view = [viewFactory pluginViewWithArguments:arguments];
}
@@ -147,10 +147,10 @@ static NSMutableSet *pluginViews = nil;
for (i = 0; i < count; i++) {
id aView = [_views objectAtIndex:i];
if ([aView respondsToSelector:@selector(webPlugInStart)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView webPlugInStart];
} else if ([aView respondsToSelector:@selector(pluginStart)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView pluginStart];
}
}
@@ -170,10 +170,10 @@ static NSMutableSet *pluginViews = nil;
for (i = 0; i < count; i++) {
id aView = [_views objectAtIndex:i];
if ([aView respondsToSelector:@selector(webPlugInStop)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView webPlugInStop];
} else if ([aView respondsToSelector:@selector(pluginStop)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView pluginStop];
}
}
@@ -197,10 +197,10 @@ static NSMutableSet *pluginViews = nil;
LOG(Plugins, "initializing plug-in %@", view);
if ([view respondsToSelector:@selector(webPlugInInitialize)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view webPlugInInitialize];
} else if ([view respondsToSelector:@selector(pluginInitialize)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view pluginInitialize];
}
@@ -210,15 +210,15 @@ static NSMutableSet *pluginViews = nil;
if (_started) {
LOG(Plugins, "starting plug-in %@", view);
if ([view respondsToSelector:@selector(webPlugInStart)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view webPlugInStart];
} else if ([view respondsToSelector:@selector(pluginStart)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view pluginStart];
}
if ([view respondsToSelector:@selector(setContainingWindow:)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view setContainingWindow:[_documentView window]];
}
}
@@ -230,24 +230,26 @@ static NSMutableSet *pluginViews = nil;
if ([_views containsObject:view]) {
if (_started) {
if ([view respondsToSelector:@selector(webPlugInStop)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view webPlugInStop];
} else if ([view respondsToSelector:@selector(pluginStop)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view pluginStop];
}
}
if ([view respondsToSelector:@selector(webPlugInDestroy)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view webPlugInDestroy];
} else if ([view respondsToSelector:@selector(pluginDestroy)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[view pluginDestroy];
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
if (Frame* frame = core([self webFrame]))
frame->script()->cleanupScriptObjectsForPlugin(self);
+#endif
[pluginViews removeObject:view];
[[_documentView _webView] removePluginInstanceView:view];
@@ -289,15 +291,17 @@ static void cancelOutstandingCheck(const void *item, void *context)
for (i = 0; i < count; i++) {
id aView = [_views objectAtIndex:i];
if ([aView respondsToSelector:@selector(webPlugInDestroy)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView webPlugInDestroy];
} else if ([aView respondsToSelector:@selector(pluginDestroy)]) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
[aView pluginDestroy];
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
if (Frame* frame = core([self webFrame]))
frame->script()->cleanupScriptObjectsForPlugin(self);
+#endif
[pluginViews removeObject:aView];
[[_documentView _webView] removePluginInstanceView:aView];
@@ -311,7 +315,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
- (id)_webPluginContainerCheckIfAllowedToLoadRequest:(NSURLRequest *)request inFrame:(NSString *)target resultObject:(id)obj selector:(SEL)selector
{
- WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:request target:target resultObject:obj selector:selector controller:self];
+ WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:request target:target resultObject:obj selector:selector controller:self contextInfo:nil];
[_checksInProgress addObject:check];
[check start];
@@ -419,7 +423,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
contentURL:[response URL]
pluginPageURL:nil
pluginName:nil // FIXME: Get this from somewhere
- MIMEType:[response _webcore_MIMEType]];
+ MIMEType:[response MIMEType]];
[_dataSource _documentLoader]->cancelMainResourceLoad(error);
[error release];
}
@@ -451,7 +455,7 @@ static WebCore::HTMLMediaElement* mediaProxyClient(DOMElement* element)
return nil;
}
- Node* node = [element _node];
+ Element* node = core(element);
if (!node || (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))) {
LOG_ERROR("invalid media element passed");
return nil;
diff --git a/WebKit/mac/Plugins/WebPluginDatabase.mm b/WebKit/mac/Plugins/WebPluginDatabase.mm
index 4f2bdd8..1856fe1 100644
--- a/WebKit/mac/Plugins/WebPluginDatabase.mm
+++ b/WebKit/mac/Plugins/WebPluginDatabase.mm
@@ -333,7 +333,11 @@ static NSArray *additionalWebPlugInPaths;
for (subviewIndex = 0; subviewIndex < subviewCount; subviewIndex++) {
NSView *subview = [subviews objectAtIndex:subviewIndex];
- if ([subview isKindOfClass:[WebBaseNetscapePluginView class]] || [WebPluginController isPlugInView:subview])
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ if ([subview isKindOfClass:[WebBaseNetscapePluginView class]] || [WebPluginController isPlugInView:subview])
+#else
+ if ([WebPluginController isPlugInView:subview])
+#endif
[pluginInstanceViews removeObject:subview];
}
}
@@ -345,10 +349,13 @@ static NSArray *additionalWebPlugInPaths;
NSArray *pli = [pluginInstanceViews allObjects];
NSEnumerator *enumerator = [pli objectEnumerator];
while ((view = [enumerator nextObject]) != nil) {
+#if ENABLE(NETSCAPE_PLUGIN_API)
if ([view isKindOfClass:[WebBaseNetscapePluginView class]]) {
ASSERT([view respondsToSelector:@selector(stop)]);
[view performSelector:@selector(stop)];
- } else if ([WebPluginController isPlugInView:view]) {
+ } else
+#endif
+ if ([WebPluginController isPlugInView:view]) {
ASSERT([[view superview] isKindOfClass:[WebHTMLView class]]);
ASSERT([[view superview] respondsToSelector:@selector(_destroyAllWebPlugins)]);
// this will actually destroy all plugin instances for a webHTMLView and remove them from this list
diff --git a/WebKit/mac/Plugins/npapi.mm b/WebKit/mac/Plugins/npapi.mm
index 79eff2a..51c37ae 100644
--- a/WebKit/mac/Plugins/npapi.mm
+++ b/WebKit/mac/Plugins/npapi.mm
@@ -191,4 +191,45 @@ NPError NPN_PopUpContextMenu(NPP instance, NPMenu *menu)
return [pluginViewForInstance(instance) popUpContextMenu:menu];
}
+NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32* len)
+{
+ return [pluginViewForInstance(instance) getVariable:variable forURL:url value:value length:len];
+}
+
+NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32 len)
+{
+ return [pluginViewForInstance(instance) setVariable:variable forURL:url value:value length:len];
+}
+
+NPError NPN_GetAuthenticationInfo(NPP instance, const char* protocol, const char* host, int32 port, const char* scheme, const char *realm, char** username, uint32* ulen, char** password, uint32* plen)
+{
+ return [pluginViewForInstance(instance) getAuthenticationInfoWithProtocol:protocol
+ host:host
+ port:port
+ scheme:scheme
+ realm:realm
+ username:username usernameLength:ulen
+ password:password passwordLength:plen];
+}
+
+NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace)
+{
+ return [pluginViewForInstance(instance) convertFromX:sourceX andY:sourceY space:sourceSpace toX:destX andY:destY space:destSpace];
+}
+
+uint32 WKN_CheckIfAllowedToLoadURL(NPP instance, const char* url, const char* frame, void (*callbackFunc)(NPP npp, uint32, NPBool, void*), void* context)
+{
+ return [pluginViewForInstance(instance) checkIfAllowedToLoadURL:url frame:frame callbackFunc:callbackFunc context:context];
+}
+
+void WKN_CancelCheckIfAllowedToLoadURL(NPP instance, uint32 checkID)
+{
+ [pluginViewForInstance(instance) cancelCheckIfAllowedToLoadURL:checkID];
+}
+
+char* WKN_ResolveURL(NPP instance, const char* url, const char* target)
+{
+ return [pluginViewForInstance(instance) resolveURL:url forTarget:target];
+}
+
#endif