Commit 7c286111 authored by kdecker@apple.com's avatar kdecker@apple.com

Reviewed by Anders Carlson.

        Allow WKN_CheckIfAllowedToLoadURL() to take an optional void* context parameter.
        
        * Plugins/WebNetscapeContainerCheckContextInfo.h:
        * Plugins/WebNetscapeContainerCheckContextInfo.mm:
        (-[WebNetscapeContainerCheckContextInfo initWithCheckRequestID:callbackFunc:context:]):
        (-[WebNetscapeContainerCheckContextInfo callback]):
        (-[WebNetscapeContainerCheckContextInfo context]):
        * Plugins/WebNetscapeContainerCheckPrivate.h:
        * Plugins/WebNetscapeContainerCheckPrivate.mm:
        (browserContainerCheckFuncs):
        * Plugins/WebNetscapePluginView.h:
        * Plugins/WebNetscapePluginView.mm:
        (-[WebNetscapePluginView checkIfAllowedToLoadURL:frame:callbackFunc:context:]):
        (-[WebNetscapePluginView _containerCheckResult:contextInfo:]):
        * Plugins/npapi.mm:
        (WKN_CheckIfAllowedToLoadURL):



git-svn-id: svn://svn.chromium.org/blink/trunk@43009 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d93606fb
2009-04-29 Kevin Decker <kdecker@apple.com>
Reviewed by Anders Carlson.
Allow WKN_CheckIfAllowedToLoadURL() to take an optional void* context parameter.
* Plugins/WebNetscapeContainerCheckContextInfo.h:
* Plugins/WebNetscapeContainerCheckContextInfo.mm:
(-[WebNetscapeContainerCheckContextInfo initWithCheckRequestID:callbackFunc:context:]):
(-[WebNetscapeContainerCheckContextInfo callback]):
(-[WebNetscapeContainerCheckContextInfo context]):
* Plugins/WebNetscapeContainerCheckPrivate.h:
* Plugins/WebNetscapeContainerCheckPrivate.mm:
(browserContainerCheckFuncs):
* Plugins/WebNetscapePluginView.h:
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView checkIfAllowedToLoadURL:frame:callbackFunc:context:]):
(-[WebNetscapePluginView _containerCheckResult:contextInfo:]):
* Plugins/npapi.mm:
(WKN_CheckIfAllowedToLoadURL):
2009-04-29 David Hyatt <hyatt@apple.com> 2009-04-29 David Hyatt <hyatt@apple.com>
Reviewed by John Sullivan. Reviewed by John Sullivan.
......
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
@interface WebNetscapeContainerCheckContextInfo : NSObject { @interface WebNetscapeContainerCheckContextInfo : NSObject {
uint32 _checkRequestID; uint32 _checkRequestID;
void (*_callback)(NPP npp, uint32, NPBool); void (*_callback)(NPP npp, uint32, NPBool, void *);
void *_context;
} }
- (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed))callbackFunc; - (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context;
- (uint32)checkRequestID; - (uint32)checkRequestID;
- (void (*)(NPP npp, uint32, NPBool))callback; - (void (*)(NPP npp, uint32, NPBool, void*))callback;
- (void*)context;
@end @end
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
@implementation WebNetscapeContainerCheckContextInfo @implementation WebNetscapeContainerCheckContextInfo
- (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed))callbackFunc; - (id)initWithCheckRequestID:(uint32)checkRequestID callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context
{ {
self = [super init]; self = [super init];
if (!self) if (!self)
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
_checkRequestID = checkRequestID; _checkRequestID = checkRequestID;
_callback = callbackFunc; _callback = callbackFunc;
_context = context;
return self; return self;
} }
...@@ -43,9 +44,14 @@ ...@@ -43,9 +44,14 @@
return _checkRequestID; return _checkRequestID;
} }
- (void (*)(NPP npp, uint32, NPBool))callback - (void (*)(NPP npp, uint32, NPBool, void*))callback
{ {
return _callback; return _callback;
} }
- (void*)context
{
return _context;
}
@end @end
...@@ -36,11 +36,12 @@ extern "C" { ...@@ -36,11 +36,12 @@ extern "C" {
#endif #endif
#define WKNVBrowserContainerCheckFuncs 1701 #define WKNVBrowserContainerCheckFuncs 1701
#define WKNVBrowserContainerCheckFuncsVersion 1
typedef uint32 (*WKN_CheckIfAllowedToLoadURLProcPtr)(NPP npp, const char* url, const char* frame, void (*callbackFunc)(NPP npp, uint32, NPBool allowed)); 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 void (*WKN_CancelCheckIfAllowedToLoadURLProcPtr)(NPP npp, uint32);
uint32 WKN_CheckIfAllowedToLoadURL(NPP npp, const char* url, const char* frame, void (*callbackFunc)(NPP npp, uint32, NPBool allowed)); 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); void WKN_CancelCheckIfAllowedToLoadURL(NPP npp, uint32);
typedef struct _WKNBrowserContainerCheckFuncs { typedef struct _WKNBrowserContainerCheckFuncs {
......
...@@ -34,7 +34,7 @@ WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs() ...@@ -34,7 +34,7 @@ WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs()
{ {
static WKNBrowserContainerCheckFuncs funcs = { static WKNBrowserContainerCheckFuncs funcs = {
sizeof(WKNBrowserContainerCheckFuncs), sizeof(WKNBrowserContainerCheckFuncs),
0, WKNVBrowserContainerCheckFuncsVersion,
WKN_CheckIfAllowedToLoadURL, WKN_CheckIfAllowedToLoadURL,
WKN_CancelCheckIfAllowedToLoadURL WKN_CancelCheckIfAllowedToLoadURL
}; };
......
...@@ -143,7 +143,7 @@ typedef union PluginPort { ...@@ -143,7 +143,7 @@ typedef union PluginPort {
- (void)didCallPlugInFunction; - (void)didCallPlugInFunction;
- (void)handleMouseMoved:(NSEvent *)event; - (void)handleMouseMoved:(NSEvent *)event;
- (uint32)checkIfAllowedToLoadURL:(const char*) url frame:(const char*) frame callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed))callbackFunc; - (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; - (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID;
@end @end
......
...@@ -1213,7 +1213,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) ...@@ -1213,7 +1213,9 @@ 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))callbackFunc - (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) if (!_containerChecksInProgress)
_containerChecksInProgress = [[NSMutableDictionary alloc] init]; _containerChecksInProgress = [[NSMutableDictionary alloc] init];
...@@ -1221,7 +1223,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) ...@@ -1221,7 +1223,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
NSString *frameName = frameNameCString ? [NSString stringWithCString:frameNameCString encoding:NSISOLatin1StringEncoding] : nil; NSString *frameName = frameNameCString ? [NSString stringWithCString:frameNameCString encoding:NSISOLatin1StringEncoding] : nil;
++_currentContainerCheckRequestID; ++_currentContainerCheckRequestID;
WebNetscapeContainerCheckContextInfo *contextInfo = [[WebNetscapeContainerCheckContextInfo alloc] initWithCheckRequestID:_currentContainerCheckRequestID callbackFunc:callbackFunc]; WebNetscapeContainerCheckContextInfo *contextInfo = [[WebNetscapeContainerCheckContextInfo alloc] initWithCheckRequestID:_currentContainerCheckRequestID
callbackFunc:callbackFunc
context:context];
WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:[self requestWithURLCString:urlCString] WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:[self requestWithURLCString:urlCString]
target:frameName target:frameName
...@@ -1240,14 +1244,14 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) ...@@ -1240,14 +1244,14 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
- (void)_containerCheckResult:(PolicyAction)policy contextInfo:(id)contextInfo - (void)_containerCheckResult:(PolicyAction)policy contextInfo:(id)contextInfo
{ {
ASSERT([contextInfo isKindOfClass:[WebNetscapeContainerCheckContextInfo class]]); ASSERT([contextInfo isKindOfClass:[WebNetscapeContainerCheckContextInfo class]]);
void (*pluginCallback)(NPP npp, uint32, NPBool) = [contextInfo callback]; void (*pluginCallback)(NPP npp, uint32, NPBool, void*) = [contextInfo callback];
if (!pluginCallback) { if (!pluginCallback) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return; return;
} }
pluginCallback([self plugin], [contextInfo checkRequestID], (policy == PolicyUse)); pluginCallback([self plugin], [contextInfo checkRequestID], (policy == PolicyUse), [contextInfo context]);
} }
- (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID - (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID
......
...@@ -217,9 +217,9 @@ NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordina ...@@ -217,9 +217,9 @@ NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordina
return [pluginViewForInstance(instance) convertFromX:sourceX andY:sourceY space:sourceSpace toX:destX andY:destY space: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)) 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]; return [pluginViewForInstance(instance) checkIfAllowedToLoadURL:url frame:frame callbackFunc:callbackFunc context:context];
} }
void WKN_CancelCheckIfAllowedToLoadURL(NPP instance, uint32 checkID) void WKN_CancelCheckIfAllowedToLoadURL(NPP instance, uint32 checkID)
......
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