[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:50:20 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit fcf1e7c30ef63a879a30e22b33968d8808d12ea9
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Aug 6 17:38:56 2003 +0000
Fixed: <rdar://problem/3106525>: Results of JavaScript requests are not returned to plug-ins
Reviewed by darin.
* Plugins.subproj/WebBaseNetscapePluginStream.h:
* Plugins.subproj/WebBaseNetscapePluginStream.m:
(-[WebBaseNetscapePluginStream setNotifyData:]): new
(-[WebBaseNetscapePluginStream startStreamWithURL:expectedContentLength:lastModifiedDate:MIMEType:]): renamed from setResponse
(-[WebBaseNetscapePluginStream startStreamWithResponse:]): new
(-[WebBaseNetscapePluginStream receivedData:]): tweak
(-[WebBaseNetscapePluginStream destroyStreamWithReason:]): tweak
(-[WebBaseNetscapePluginStream finishedLoadingWithData:]): tweak
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView evaluateJavaScriptPluginRequest:targetFrame:]): new
(-[WebBaseNetscapePluginView loadPluginRequest:]): call evaluateJavaScriptPluginRequest::
(-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]): call loadPluginRequest for JS requests
* Plugins.subproj/WebNetscapePluginRepresentation.m:
(-[WebNetscapePluginRepresentation receivedData:withDataSource:]): call renamed startStreamWithResponse
* Plugins.subproj/WebNetscapePluginStream.m:
(-[WebNetscapePluginStream initWithRequest:pluginPointer:notifyData:]): call setNotifyData
(-[WebNetscapePluginConnectionDelegate connection:didReceiveResponse:]): call renamed startStreamWithResponse
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4775 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1403cb4..c20ba30 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,27 @@
+2003-08-04 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: <rdar://problem/3106525>: Results of JavaScript requests are not returned to plug-ins
+
+ Reviewed by darin.
+
+ * Plugins.subproj/WebBaseNetscapePluginStream.h:
+ * Plugins.subproj/WebBaseNetscapePluginStream.m:
+ (-[WebBaseNetscapePluginStream setNotifyData:]): new
+ (-[WebBaseNetscapePluginStream startStreamWithURL:expectedContentLength:lastModifiedDate:MIMEType:]): renamed from setResponse
+ (-[WebBaseNetscapePluginStream startStreamWithResponse:]): new
+ (-[WebBaseNetscapePluginStream receivedData:]): tweak
+ (-[WebBaseNetscapePluginStream destroyStreamWithReason:]): tweak
+ (-[WebBaseNetscapePluginStream finishedLoadingWithData:]): tweak
+ * Plugins.subproj/WebBaseNetscapePluginView.m:
+ (-[WebBaseNetscapePluginView evaluateJavaScriptPluginRequest:targetFrame:]): new
+ (-[WebBaseNetscapePluginView loadPluginRequest:]): call evaluateJavaScriptPluginRequest::
+ (-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]): call loadPluginRequest for JS requests
+ * Plugins.subproj/WebNetscapePluginRepresentation.m:
+ (-[WebNetscapePluginRepresentation receivedData:withDataSource:]): call renamed startStreamWithResponse
+ * Plugins.subproj/WebNetscapePluginStream.m:
+ (-[WebNetscapePluginStream initWithRequest:pluginPointer:notifyData:]): call setNotifyData
+ (-[WebNetscapePluginConnectionDelegate connection:didReceiveResponse:]): call renamed startStreamWithResponse
+
2003-08-05 Ken Kocienda <kocienda at apple.com>
Reviewed by Richard
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
index 4e837db..75bbd04 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
@@ -31,7 +31,13 @@
}
- (void)setPluginPointer:(NPP)pluginPointer;
-- (void)setResponse:(NSURLResponse *)theReponse;
+- (void)setNotifyData:(void *)theNotifyData;
+
+- (void)startStreamWithURL:(NSURL *)theURL
+ expectedContentLength:(long long)expectedContentLength
+ lastModifiedDate:(NSDate *)lastModifiedDate
+ MIMEType:(NSString *)MIMEType;
+- (void)startStreamWithResponse:(NSURLResponse *)r;
- (void)receivedData:(NSData *)data;
- (void)receivedError:(NPReason)reason;
- (void)finishedLoadingWithData:(NSData *)data;
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
index 27d11b8..a6d64a7 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
@@ -12,6 +12,7 @@
#import <Foundation/NSURLResponse.h>
#import <Foundation/NSURLResponsePrivate.h>
#import <Foundation/NSFileManager_NSURLExtras.h>
+#import <Foundation/NSURL_NSURLExtras.h>
@implementation WebBaseNetscapePluginStream
@@ -53,31 +54,42 @@
NPP_URLNotify = [plugin NPP_URLNotify];
}
-- (void)setResponse:(NSURLResponse *)r
+- (void)setNotifyData:(void *)theNotifyData
{
- if(![plugin isLoaded]){
+ notifyData = theNotifyData;
+}
+
+- (void)startStreamWithURL:(NSURL *)theURL
+ expectedContentLength:(long long)expectedContentLength
+ lastModifiedDate:(NSDate *)lastModifiedDate
+ MIMEType:(NSString *)MIMEType
+{
+ if (![plugin isLoaded]) {
return;
}
+ [theURL retain];
[URL release];
- URL = [[r URL] retain];
-
- stream.ndata = self;
+ URL = theURL;
+
+ free((void *)stream.URL);
stream.URL = strdup([URL _web_URLCString]);
- stream.end = [r expectedContentLength];
- stream.lastmodified = [[r _lastModifiedDate] timeIntervalSince1970];
- stream.notifyData = notifyData;
+ stream.ndata = self;
+ stream.end = expectedContentLength;
+ stream.lastmodified = [lastModifiedDate timeIntervalSince1970];
+ stream.notifyData = notifyData;
+
+ transferMode = NP_NORMAL;
offset = 0;
// FIXME: Need a way to check if stream is seekable
- NPError npErr;
- npErr = NPP_NewStream(instance, (char *)[[r MIMEType] cString], &stream, NO, &transferMode);
+ NPError npErr = NPP_NewStream(instance, (char *)[MIMEType cString], &stream, NO, &transferMode);
LOG(Plugins, "NPP_NewStream: %d %@", npErr, URL);
if (npErr != NPERR_NO_ERROR) {
- ERROR("NPP_NewStream failed with error: %d", npErr);
+ ERROR("NPP_NewStream failed with error: %d URLString: %s", npErr, [URL _web_URLCString]);
stream.ndata = nil;
return;
}
@@ -101,9 +113,17 @@
}
}
+- (void)startStreamWithResponse:(NSURLResponse *)r
+{
+ [self startStreamWithURL:[r URL]
+ expectedContentLength:[r expectedContentLength]
+ lastModifiedDate:[r _lastModifiedDate]
+ MIMEType:[r MIMEType]];
+}
+
- (void)receivedData:(NSData *)data
{
- if(![plugin isLoaded] || !stream.ndata) {
+ if (![plugin isLoaded] || !stream.ndata || [data length] == 0) {
return;
}
@@ -122,7 +142,7 @@
- (void)destroyStreamWithReason:(NPReason)reason
{
- if(![plugin isLoaded] || !stream.ndata) {
+ if (![plugin isLoaded] || !stream.ndata) {
return;
}
@@ -139,11 +159,11 @@
- (void)finishedLoadingWithData:(NSData *)data
{
- if(![plugin isLoaded] || !stream.ndata) {
+ if (![plugin isLoaded] || !stream.ndata) {
return;
}
- if (transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
+ if ((transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) && [data length] > 0) {
if (!path) {
path = strdup("/tmp/WebKitPlugInStreamXXXXXX");
int fd = mkstemp(path);
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
index 29e6f21..6d905ca 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
@@ -26,6 +26,7 @@
#import <Foundation/NSData_NSURLExtras.h>
#import <Foundation/NSString_NSURLExtras.h>
+#import <Foundation/NSURL_NSURLExtras.h>
#import <AppKit/NSEvent_Private.h>
#import <Carbon/Carbon.h>
@@ -1198,39 +1199,81 @@ typedef struct {
return [NSMutableURLRequest requestWithURL:URL];
}
+- (void)evaluateJavaScriptPluginRequest:(WebPluginRequest *)JSPluginRequest targetFrame:(WebFrame *)targetFrame
+{
+ if (!isStarted) {
+ return;
+ }
+
+ NSURL *URL = [[JSPluginRequest request] URL];
+ NSString *JSString = [URL _web_scriptIfJavaScriptURL];
+ ASSERT(JSString);
+
+ WebFrame *evaluatingFrame = targetFrame ? targetFrame : [self webFrame];
+ NSString *result = [[evaluatingFrame _bridge] stringByEvaluatingJavaScriptFromString:JSString];
+ void *notifyData = [JSPluginRequest notifyData];
+
+ if (targetFrame) {
+ // FIXME: If the result is a string, we probably want to put that string into the frame, just
+ // like we do in KHTMLPartBrowserExtension::openURLRequest.
+ if (notifyData) {
+ NPP_URLNotify(instance, [URL _web_URLCString], NPRES_DONE, notifyData);
+ }
+ } else {
+ NSData *JSData = nil;
+
+ if ([result length] > 0) {
+ JSData = [result dataUsingEncoding:NSUTF8StringEncoding];
+ }
+
+ WebBaseNetscapePluginStream *stream = [[WebBaseNetscapePluginStream alloc] init];
+ [stream setPluginPointer:instance];
+ [stream setNotifyData:notifyData];
+ [stream startStreamWithURL:URL
+ expectedContentLength:[JSData length]
+ lastModifiedDate:nil
+ MIMEType:@"text/plain"];
+ [stream receivedData:JSData];
+ [stream finishedLoadingWithData:JSData];
+ [stream release];
+ }
+}
+
- (void)loadPluginRequest:(WebPluginRequest *)pluginRequest
{
NSURLRequest *request = [pluginRequest request];
NSString *frameName = [pluginRequest frameName];
void *notifyData = [pluginRequest notifyData];
-
- // FIXME - need to get rid of this window creation which
- // bypasses normal targeted link handling
- WebFrame *frame = [[self webFrame] findFrameNamed:frameName];
-
- if (frame == nil) {
- WebView *newWebView = nil;
- WebView *currentWebView = [self webView];
- id wd = [currentWebView UIDelegate];
- if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)])
- newWebView = [wd webView:currentWebView createWebViewWithRequest:nil];
- else
- newWebView = [[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:nil];
-
- [newWebView _setTopLevelFrameName:frameName];
- [[newWebView _UIDelegateForwarder] webViewShow:newWebView];
- frame = [newWebView mainFrame];
+ WebFrame *frame = nil;
+
+ NSURL *URL = [request URL];
+ NSString *JSString = [URL _web_scriptIfJavaScriptURL];
+
+ ASSERT(frameName || JSString);
+
+ if (frameName) {
+ // FIXME - need to get rid of this window creation which
+ // bypasses normal targeted link handling
+ frame = [[self webFrame] findFrameNamed:frameName];
+
+ if (frame == nil) {
+ WebView *newWebView = nil;
+ WebView *currentWebView = [self webView];
+ id wd = [currentWebView UIDelegate];
+ if ([wd respondsToSelector:@selector(webView:createWebViewWithRequest:)]) {
+ newWebView = [wd webView:currentWebView createWebViewWithRequest:nil];
+ } else {
+ newWebView = [[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:nil];
+ }
+
+ [newWebView _setTopLevelFrameName:frameName];
+ [[newWebView _UIDelegateForwarder] webViewShow:newWebView];
+ frame = [newWebView mainFrame];
+ }
}
- NSURL *URL = [request URL];
- NSString *JSString = [URL _webkit_scriptIfJavaScriptURL];
if (JSString) {
- [[frame _bridge] stringByEvaluatingJavaScriptFromString:JSString];
- // FIXME: If the result is a string, we probably want to put that string into the frame, just
- // like we do in KHTMLPartBrowserExtension::openURLRequest.
- if (notifyData && isStarted) {
- NPP_URLNotify(instance, [URL _web_URLCString], NPRES_DONE, notifyData);
- }
+ [self evaluateJavaScriptPluginRequest:pluginRequest targetFrame:frame];
} else {
[frame loadRequest:request];
if (notifyData) {
@@ -1253,11 +1296,28 @@ typedef struct {
- (NPError)loadRequest:(NSMutableURLRequest *)request inTarget:(const char *)cTarget withNotifyData:(void *)notifyData
{
- if (![request URL]) {
+ NSURL *URL = [request URL];
+
+ if (!URL) {
return NPERR_INVALID_URL;
}
- if (!cTarget) {
+ NSString *JSString = [URL _web_scriptIfJavaScriptURL];
+
+ if (cTarget || JSString) {
+ // Make when targetting a frame or evaluating a JS string, perform the request after a delay because we don't
+ // want to potentially kill the plug-in inside of its URL request.
+ NSString *target = nil;
+ if (cTarget) {
+ // Find the frame given the target string.
+ target = (NSString *)CFStringCreateWithCString(kCFAllocatorDefault, cTarget, kCFStringEncodingWindowsLatin1);
+ }
+ [request setHTTPReferrer:[[[[[self webFrame] dataSource] request] URL] absoluteString]];
+ WebPluginRequest *pluginRequest = [[WebPluginRequest alloc] initWithRequest:request frameName:target notifyData:notifyData];
+ [self performSelector:@selector(loadPluginRequest:) withObject:pluginRequest afterDelay:0];
+ [pluginRequest release];
+ [target release];
+ } else {
WebNetscapePluginStream *stream = [[WebNetscapePluginStream alloc]
initWithRequest:request pluginPointer:instance notifyData:notifyData];
if (!stream) {
@@ -1266,17 +1326,6 @@ typedef struct {
[streams addObject:stream];
[stream start];
[stream release];
- } else {
- // Find the frame given the target string.
- NSString *target = (NSString *)CFStringCreateWithCString(kCFAllocatorDefault, cTarget, kCFStringEncodingWindowsLatin1);
-
- [request setHTTPReferrer:[[[[[self webFrame] dataSource] request] URL] absoluteString]];
- // Make a request, but don't do it right away because it could make the plugin view go away.
- WebPluginRequest *pluginRequest = [[WebPluginRequest alloc]
- initWithRequest:request frameName:target notifyData:notifyData];
- [self performSelector:@selector(loadPluginRequest:) withObject:pluginRequest afterDelay:0];
- [pluginRequest release];
- [target release];
}
return NPERR_NO_ERROR;
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
index df351f9..89890ab 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
@@ -46,7 +46,7 @@
if(!instance){
[self setPluginPointer:[view pluginPointer]];
- [self setResponse:[ds response]];
+ [self startStreamWithResponse:[ds response]];
}
ASSERT(instance);
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginStream.m b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
index 6421d4e..b732a97 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
@@ -40,13 +40,12 @@
_startingRequest = [theRequest copy];
[self setPluginPointer:thePluginPointer];
+ [self setNotifyData:theNotifyData];
WebBaseNetscapePluginView *view = (WebBaseNetscapePluginView *)instance->ndata;
_loader = [[WebNetscapePluginConnectionDelegate alloc] initWithStream:self view:view];
[_loader setDataSource:[view dataSource]];
- notifyData = theNotifyData;
-
return self;
}
@@ -99,7 +98,7 @@
// retain/release self in this delegate method since the additional processing can do
// anything including possibly releasing self; one example of this is 3266216
[self retain];
- [stream setResponse:theResponse];
+ [stream startStreamWithResponse:theResponse];
[super connection:con didReceiveResponse:theResponse];
if ([theResponse isKindOfClass:[NSHTTPURLResponse class]] &&
[NSHTTPURLResponse isErrorStatusCode:[(NSHTTPURLResponse *)theResponse statusCode]]) {
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list