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>
37 #import <wtf/OwnPtr.h>
38 #import <wtf/RetainPtr.h>
43 @
class WebNetscapePluginPackage
;
47 class WebNetscapePluginStream
;
48 class WebNetscapePluginEventHandler
;
50 typedef union PluginPort
{
51 #ifndef NP_NO_QUICKDRAW
57 typedef struct _NPPluginTextInputFuncs NPPluginTextInputFuncs
;
59 // Because the Adobe 7.x Acrobat plug-in has a hard coded check for a view named
60 // "WebNetscapePluginDocumentView", this class must retain the old name in order
61 // for the plug-in to function correctly. (rdar://problem/4699455)
62 #define WebBaseNetscapePluginView WebNetscapePluginDocumentView
64 @interface WebBaseNetscapePluginView
: NSView
<WebPluginManualLoader
, NSTextInput
>
66 RetainPtr
<WebNetscapePluginPackage
> _pluginPackage
;
68 RetainPtr
<NSURL
> _sourceURL
;
72 RefPtr
<WebNetscapePluginStream
> _manualStream
;
73 #ifndef BUILDING_ON_TIGER
74 RetainPtr
<CALayer
> _layer
;
76 unsigned _dataLengthReceived
;
77 RetainPtr
<NSError
> _error
;
87 NPWindow lastSetWindow
;
89 PluginPort lastSetPort
;
90 NPDrawingModel drawingModel
;
91 NPEventModel eventModel
;
93 #ifndef NP_NO_QUICKDRAW
94 // This is only valid when drawingModel is NPDrawingModelQuickDraw
95 GWorldPtr offscreenGWorld
;
98 OwnPtr
<WebNetscapePluginEventHandler
> _eventHandler
;
103 BOOL isCompletelyObscured
;
106 BOOL shouldFireTimers
;
107 uint32 currentTimerID
;
108 HashMap
<uint32
, PluginTimer
*>* timers
;
110 unsigned pluginFunctionCallDepth
;
112 RetainPtr
<DOMElement
> _element
;
114 int32 specifiedHeight
;
115 int32 specifiedWidth
;
117 RetainPtr
<NSString
> _MIMEType
;
118 RetainPtr
<NSURL
> _baseURL
;
119 NSTrackingRectTag trackingTag
;
121 HashSet
<RefPtr
<WebNetscapePluginStream
> > streams
;
122 RetainPtr
<NSMutableDictionary
> _pendingFrameLoads
;
124 NPPluginTextInputFuncs
*textInputFuncs
;
126 NPP_NewProcPtr NPP_New
;
127 NPP_DestroyProcPtr NPP_Destroy
;
128 NPP_SetWindowProcPtr NPP_SetWindow
;
129 NPP_NewStreamProcPtr NPP_NewStream
;
130 NPP_DestroyStreamProcPtr NPP_DestroyStream
;
131 NPP_StreamAsFileProcPtr NPP_StreamAsFile
;
132 NPP_WriteReadyProcPtr NPP_WriteReady
;
133 NPP_WriteProcPtr NPP_Write
;
134 NPP_PrintProcPtr NPP_Print
;
135 NPP_HandleEventProcPtr NPP_HandleEvent
;
136 NPP_URLNotifyProcPtr NPP_URLNotify
;
137 NPP_GetValueProcPtr NPP_GetValue
;
138 NPP_SetValueProcPtr NPP_SetValue
;
141 + (WebBaseNetscapePluginView
*)currentPluginView
;
144 - (id
)initWithFrame
:(NSRect
)r
145 pluginPackage
:(WebNetscapePluginPackage
*)thePluginPackage
147 baseURL
:(NSURL
*)baseURL
148 MIMEType
:(NSString
*)MIME
149 attributeKeys
:(NSArray
*)keys
150 attributeValues
:(NSArray
*)values
151 loadManually
:(BOOL
)loadManually
152 DOMElement
:(DOMElement
*)anElement
;
159 - (void)restartTimers
;
161 - (WebFrame
*)webFrame
;
162 - (WebDataSource
*)dataSource
;
163 - (WebView
*)webView
;
164 - (NSWindow
*)currentWindow
;
168 - (WebNetscapePluginPackage
*)pluginPackage
;
169 - (void)setPluginPackage
:(WebNetscapePluginPackage
*)thePluginPackage
;
170 - (void)viewWillMoveToHostWindow
:(NSWindow
*)hostWindow
;
171 - (void)viewDidMoveToHostWindow
;
172 - (void)disconnectStream
:(WebNetscapePluginStream
*)stream
;
174 // Returns the NPObject that represents the plugin interface.
175 // The return value is expected to be retained.
176 - (NPObject
*)createPluginScriptableObject
;
178 // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
179 // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash
180 // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
181 // to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
182 // document.write(), which clears the document and destroys the plug-in.
183 // See <rdar://problem/4480737>.
184 - (void)willCallPlugInFunction
;
186 // -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly
187 // once for every call to -willCallPlugInFunction.
188 // See <rdar://problem/4480737>.
189 - (void)didCallPlugInFunction
;
191 - (void)handleMouseMoved
:(NSEvent
*)event
;
195 @interface
WebBaseNetscapePluginView (WebInternal
)
196 - (BOOL
)sendEvent
:(void*)event isDrawRect
:(BOOL
)eventIsDrawRect
;
197 - (NPEventModel
)eventModel
;
199 - (NPError
)loadRequest
:(NSURLRequest
*)request inTarget
:(NSString
*)target withNotifyData
:(void *)notifyData sendNotification
:(BOOL
)sendNotification
;
200 - (NPError
)getURLNotify
:(const char *)URL target
:(const char *)target notifyData
:(void *)notifyData
;
201 - (NPError
)getURL
:(const char *)URL target
:(const char *)target
;
202 - (NPError
)postURLNotify
:(const char *)URL target
:(const char *)target len
:(UInt32
)len buf
:(const char *)buf file
:(NPBool
)file notifyData
:(void *)notifyData
;
203 - (NPError
)postURL
:(const char *)URL target
:(const char *)target len
:(UInt32
)len buf
:(const char *)buf file
:(NPBool
)file
;
204 - (NPError
)newStream
:(NPMIMEType
)type target
:(const char *)target stream
:(NPStream
**)stream
;
205 - (NPError
)write
:(NPStream
*)stream len
:(SInt32
)len buffer
:(void *)buffer
;
206 - (NPError
)destroyStream
:(NPStream
*)stream reason
:(NPReason
)reason
;
207 - (void)status
:(const char *)message
;
208 - (const char *)userAgent
;
209 - (void)invalidateRect
:(NPRect
*)invalidRect
;
210 - (void)invalidateRegion
:(NPRegion
)invalidateRegion
;
212 - (NPError
)getVariable
:(NPNVariable
)variable value
:(void *)value
;
213 - (NPError
)setVariable
:(NPPVariable
)variable value
:(void *)value
;
214 - (uint32
)scheduleTimerWithInterval
:(uint32
)interval repeat
:(NPBool
)repeat timerFunc
:(void (*)(NPP npp
, uint32 timerID
))timerFunc
;
215 - (void)unscheduleTimer
:(uint32
)timerID
;
216 - (NPError
)popUpContextMenu
:(NPMenu
*)menu
;