Commit 99cebaf9 authored by andersca@apple.com's avatar andersca@apple.com

2009-04-17 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam Weinig.

        WebKit side of <rdar://problem/6449642>.
        
        * Plugins/Hosted/HostedNetscapePluginStream.h:
        (WebKit::HostedNetscapePluginStream::create):
        New function that creates a stream from a frame loader.
        
        * Plugins/Hosted/HostedNetscapePluginStream.mm:
        (WebKit::HostedNetscapePluginStream::HostedNetscapePluginStream):
        Add the constructor that takes a frame loader.
        
        * Plugins/Hosted/NetscapePluginHostManager.h:
        * Plugins/Hosted/NetscapePluginHostManager.mm:
        (WebKit::NetscapePluginHostManager::instantiatePlugin):
        Pass "fullFrame" to the plug-in host.
        
        * Plugins/Hosted/NetscapePluginHostProxy.mm:
        (WKPCCancelLoadURL):
        Call NetscapePluginInstanceProxy::cancelStreamLoad.
        
        * Plugins/Hosted/NetscapePluginInstanceProxy.h:
        (WebKit::NetscapePluginInstanceProxy::create):
        Pass "fullFrame" to the constructor.
        
        (WebKit::NetscapePluginInstanceProxy::manualStream):
        New getter for the manual stream.
        
        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
        (WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy):
        Take the implicit request into account if we have a full frame plug-in.
        
        (WebKit::NetscapePluginInstanceProxy::setManualStream):
        Setter for the manual stream.
        
        (WebKit::NetscapePluginInstanceProxy::cancelStreamLoad):
        Cancel the manual stream if necessary.
        
        * Plugins/Hosted/WebHostedNetscapePluginView.h:
        WebHostedNetscapePluginView now conforms to the WebPluginManualLoader protocol.
        
        * Plugins/Hosted/WebHostedNetscapePluginView.mm:
        (-[WebHostedNetscapePluginView createPlugin]):
        Pass "fullFrame" to instantiatePlugin.
        
        (-[WebHostedNetscapePluginView pluginView:receivedResponse:]):
        (-[WebHostedNetscapePluginView pluginView:receivedData:]):
        (-[WebHostedNetscapePluginView pluginView:receivedError:]):
        (-[WebHostedNetscapePluginView pluginViewFinishedLoading:]):
        Call the equivalent manual stream functions.
        
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::createPlugin):
        Use a macro for getting the plug-in view type.



git-svn-id: svn://svn.chromium.org/blink/trunk@42615 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 03b7b7db
2009-04-17 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
WebKit side of <rdar://problem/6449642>.
* Plugins/Hosted/HostedNetscapePluginStream.h:
(WebKit::HostedNetscapePluginStream::create):
New function that creates a stream from a frame loader.
* Plugins/Hosted/HostedNetscapePluginStream.mm:
(WebKit::HostedNetscapePluginStream::HostedNetscapePluginStream):
Add the constructor that takes a frame loader.
* Plugins/Hosted/NetscapePluginHostManager.h:
* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::instantiatePlugin):
Pass "fullFrame" to the plug-in host.
* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WKPCCancelLoadURL):
Call NetscapePluginInstanceProxy::cancelStreamLoad.
* Plugins/Hosted/NetscapePluginInstanceProxy.h:
(WebKit::NetscapePluginInstanceProxy::create):
Pass "fullFrame" to the constructor.
(WebKit::NetscapePluginInstanceProxy::manualStream):
New getter for the manual stream.
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy):
Take the implicit request into account if we have a full frame plug-in.
(WebKit::NetscapePluginInstanceProxy::setManualStream):
Setter for the manual stream.
(WebKit::NetscapePluginInstanceProxy::cancelStreamLoad):
Cancel the manual stream if necessary.
* Plugins/Hosted/WebHostedNetscapePluginView.h:
WebHostedNetscapePluginView now conforms to the WebPluginManualLoader protocol.
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView createPlugin]):
Pass "fullFrame" to instantiatePlugin.
(-[WebHostedNetscapePluginView pluginView:receivedResponse:]):
(-[WebHostedNetscapePluginView pluginView:receivedData:]):
(-[WebHostedNetscapePluginView pluginView:receivedError:]):
(-[WebHostedNetscapePluginView pluginViewFinishedLoading:]):
Call the equivalent manual stream functions.
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createPlugin):
Use a macro for getting the plug-in view type.
2009-04-14 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein
......
......@@ -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;
......
......@@ -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);
......
......@@ -43,7 +43,7 @@ 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*);
......
......@@ -197,7 +197,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,10 +220,12 @@ 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) {
......@@ -234,7 +236,7 @@ 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());
}
......
......@@ -368,11 +368,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;
}
......
......@@ -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,9 +79,12 @@ 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);
......@@ -242,7 +245,7 @@ public:
}
private:
NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView *);
NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView *, bool fullFramePlugin);
NPError loadRequest(NSURLRequest *, const char* cTarget, bool currentEventIsUserGesture, uint32_t& streamID);
......@@ -291,6 +294,8 @@ private:
unsigned m_pluginFunctionCallDepth;
bool m_shouldStopSoon;
uint32_t m_currentRequestID;
RefPtr<HostedNetscapePluginStream> m_manualStream;
};
} // namespace WebKit
......
......@@ -93,7 +93,7 @@ private:
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)
......@@ -108,6 +108,12 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy
{
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;
......@@ -186,9 +192,27 @@ void NetscapePluginInstanceProxy::destroy()
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 (!streamID)
return false;
stream->cancelLoad(reason);
return true;
}
void NetscapePluginInstanceProxy::disconnectStream(HostedNetscapePluginStream* stream)
......
......@@ -31,10 +31,11 @@
#import <wtf/RefPtr.h>
namespace WebKit {
class HostedNetscapePluginStream;
class NetscapePluginInstanceProxy;
}
@interface WebHostedNetscapePluginView : WebBaseNetscapePluginView
@interface WebHostedNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader>
{
RetainPtr<NSArray> _attributeKeys;
RetainPtr<NSArray> _attributeValues;
......
......@@ -26,15 +26,18 @@
#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/HTMLPlugInElement.h>
#import <WebCore/runtime.h>
#import <WebCore/runtime_root.h>
......@@ -97,7 +100,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;
......@@ -345,6 +348,48 @@ 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);
}
@end
#endif
......@@ -1375,14 +1375,11 @@ public:
#endif // ENABLE(NETSCAPE_PLUGIN_API)
static Class netscapePluginViewClass()
{
#if USE(PLUGIN_HOST_PROCESS)
return [WebHostedNetscapePluginView class];
#define NETSCAPE_PLUGIN_VIEW WebHostedNetscapePluginView
#else
return [WebNetscapePluginView class];
#define NETSCAPE_PLUGIN_VIEW WebNetscapePluginView
#endif
}
Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url,
const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
......@@ -1452,7 +1449,7 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElemen
#if ENABLE(NETSCAPE_PLUGIN_API)
else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
WebBaseNetscapePluginView *pluginView = [[[netscapePluginViewClass() alloc]
WebBaseNetscapePluginView *pluginView = [[[NETSCAPE_PLUGIN_VIEW alloc]
initWithFrame:NSMakeRect(0, 0, size.width(), size.height())
pluginPackage:(WebNetscapePluginPackage *)pluginPackage
URL:URL
......@@ -1501,8 +1498,8 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
NSView *pluginView = pluginWidget->platformWidget();
#if ENABLE(NETSCAPE_PLUGIN_API)
if ([pluginView isKindOfClass:[WebNetscapePluginView class]])
[representation _redirectDataToManualLoader:(WebNetscapePluginView *)pluginView forPluginView:pluginView];
if ([pluginView isKindOfClass:[NETSCAPE_PLUGIN_VIEW class]])
[representation _redirectDataToManualLoader:(NETSCAPE_PLUGIN_VIEW *)pluginView forPluginView:pluginView];
else {
#else
{
......@@ -1545,7 +1542,7 @@ Widget* WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAp
}
#if ENABLE(NETSCAPE_PLUGIN_API)
else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
view = [[[netscapePluginViewClass() alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height())
view = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height())
pluginPackage:(WebNetscapePluginPackage *)pluginPackage
URL:nil
baseURL:baseURL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment