2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #if ENABLE(NETSCAPE_PLUGIN_API)
30 #import <Cocoa/Cocoa.h>
32 #import <WebKit/npfunctions.h>
33 #import <WebKit/npapi.h>
34 #import <WebKit/WebBasePluginPackage.h>
35 #import <wtf/HashMap.h>
36 #import <wtf/HashSet.h>
41 @
class WebNetscapePluginPackage
;
42 @
class WebNetscapePluginNullEventSender
;
46 class WebNetscapePluginStream
;
47 class WebNetscapePluginEventHandler
;
49 typedef union PluginPort
{
50 #ifndef NP_NO_QUICKDRAW
56 typedef struct _NPPluginTextInputFuncs NPPluginTextInputFuncs
;
58 // Because the Adobe 7.x Acrobat plug-in has a hard coded check for a view named
59 // "WebNetscapePluginDocumentView", this class must retain the old name in order
60 // for the plug-in to function correctly. (rdar://problem/4699455)
61 #define WebBaseNetscapePluginView WebNetscapePluginDocumentView
63 @interface WebBaseNetscapePluginView
: NSView
<WebPluginManualLoader
, NSTextInput
>
65 WebNetscapePluginPackage
*pluginPackage
;
71 RefPtr
<WebNetscapePluginStream
> _manualStream
;
72 unsigned _dataLengthReceived
;
83 NPWindow lastSetWindow
;
85 PluginPort lastSetPort
;
86 NPDrawingModel drawingModel
;
87 NPEventModel eventModel
;
90 #ifndef NP_NO_QUICKDRAW
91 // This is only valid when drawingModel is NPDrawingModelQuickDraw
92 GWorldPtr offscreenGWorld
;
95 WebNetscapePluginEventHandler
*eventHandler
;
101 BOOL isCompletelyObscured
;
104 BOOL shouldFireTimers
;
105 uint32 currentTimerID
;
106 HashMap
<uint32
, PluginTimer
*>* timers
;
108 unsigned pluginFunctionCallDepth
;
112 int32 specifiedHeight
;
113 int32 specifiedWidth
;
117 NSTrackingRectTag trackingTag
;
119 HashSet
<RefPtr
<WebNetscapePluginStream
> > streams
;
120 NSMutableDictionary
*pendingFrameLoads
;
122 NPPluginTextInputFuncs
*textInputFuncs
;
124 NPP_NewProcPtr NPP_New
;
125 NPP_DestroyProcPtr NPP_Destroy
;
126 NPP_SetWindowProcPtr NPP_SetWindow
;
127 NPP_NewStreamProcPtr NPP_NewStream
;
128 NPP_DestroyStreamProcPtr NPP_DestroyStream
;
129 NPP_StreamAsFileProcPtr NPP_StreamAsFile
;
130 NPP_WriteReadyProcPtr NPP_WriteReady
;
131 NPP_WriteProcPtr NPP_Write
;
132 NPP_PrintProcPtr NPP_Print
;
133 NPP_HandleEventProcPtr NPP_HandleEvent
;
134 NPP_URLNotifyProcPtr NPP_URLNotify
;
135 NPP_GetValueProcPtr NPP_GetValue
;
136 NPP_SetValueProcPtr NPP_SetValue
;
139 + (WebBaseNetscapePluginView
*)currentPluginView
;
142 - (id
)initWithFrame
:(NSRect
)r
143 pluginPackage
:(WebNetscapePluginPackage
*)thePluginPackage
145 baseURL
:(NSURL
*)baseURL
146 MIMEType
:(NSString
*)MIME
147 attributeKeys
:(NSArray
*)keys
148 attributeValues
:(NSArray
*)values
149 loadManually
:(BOOL
)loadManually
150 DOMElement
:(DOMElement
*)anElement
;
157 - (void)restartTimers
;
159 - (WebFrame
*)webFrame
;
160 - (WebDataSource
*)dataSource
;
161 - (WebView
*)webView
;
162 - (NSWindow
*)currentWindow
;
166 - (WebNetscapePluginPackage
*)pluginPackage
;
167 - (void)setPluginPackage
:(WebNetscapePluginPackage
*)thePluginPackage
;
168 - (void)setMIMEType
:(NSString
*)theMIMEType
;
169 - (void)setBaseURL
:(NSURL
*)theBaseURL
;
170 - (void)setAttributeKeys
:(NSArray
*)keys andValues
:(NSArray
*)values
;
171 - (void)setMode
:(int)theMode
;
172 - (void)viewWillMoveToHostWindow
:(NSWindow
*)hostWindow
;
173 - (void)viewDidMoveToHostWindow
;
174 - (void)disconnectStream
:(WebNetscapePluginStream
*)stream
;
176 // Returns the NPObject that represents the plugin interface.
177 // The return value is expected to be retained.
178 - (NPObject
*)createPluginScriptableObject
;
180 // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
181 // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash
182 // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
183 // to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
184 // document.write(), which clears the document and destroys the plug-in.
185 // See <rdar://problem/4480737>.
186 - (void)willCallPlugInFunction
;
188 // -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly
189 // once for every call to -willCallPlugInFunction.
190 // See <rdar://problem/4480737>.
191 - (void)didCallPlugInFunction
;
193 - (void)handleMouseMoved
:(NSEvent
*)event
;
197 @interface
WebBaseNetscapePluginView (WebInternal
)
198 - (BOOL
)sendEvent
:(void*)event isDrawRect
:(BOOL
)eventIsDrawRect
;
199 - (NPEventModel
)eventModel
;
201 - (NPError
)loadRequest
:(NSURLRequest
*)request inTarget
:(NSString
*)target withNotifyData
:(void *)notifyData sendNotification
:(BOOL
)sendNotification
;
202 - (NPError
)getURLNotify
:(const char *)URL target
:(const char *)target notifyData
:(void *)notifyData
;
203 - (NPError
)getURL
:(const char *)URL target
:(const char *)target
;
204 - (NPError
)postURLNotify
:(const char *)URL target
:(const char *)target len
:(UInt32
)len buf
:(const char *)buf file
:(NPBool
)file notifyData
:(void *)notifyData
;
205 - (NPError
)postURL
:(const char *)URL target
:(const char *)target len
:(UInt32
)len buf
:(const char *)buf file
:(NPBool
)file
;
206 - (NPError
)newStream
:(NPMIMEType
)type target
:(const char *)target stream
:(NPStream
**)stream
;
207 - (NPError
)write
:(NPStream
*)stream len
:(SInt32
)len buffer
:(void *)buffer
;
208 - (NPError
)destroyStream
:(NPStream
*)stream reason
:(NPReason
)reason
;
209 - (void)status
:(const char *)message
;
210 - (const char *)userAgent
;
211 - (void)invalidateRect
:(NPRect
*)invalidRect
;
212 - (void)invalidateRegion
:(NPRegion
)invalidateRegion
;
214 - (NPError
)getVariable
:(NPNVariable
)variable value
:(void *)value
;
215 - (NPError
)setVariable
:(NPPVariable
)variable value
:(void *)value
;
216 - (uint32
)scheduleTimerWithInterval
:(uint32
)interval repeat
:(NPBool
)repeat timerFunc
:(void (*)(NPP npp
, uint32 timerID
))timerFunc
;
217 - (void)unscheduleTimer
:(uint32
)timerID
;
218 - (NPError
)popUpContextMenu
:(NPMenu
*)menu
;