2008-10-29 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebKit / mac / Plugins / WebBaseNetscapePluginView.h
blob80ffd1bb08a645a7a8a7627e043f5d1e183ef739
1 /*
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
6 * are met:
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>
38 @class DOMElement;
39 @class WebDataSource;
40 @class WebFrame;
41 @class WebNetscapePluginPackage;
42 @class WebNetscapePluginNullEventSender;
43 @class WebView;
45 class PluginTimer;
46 class WebNetscapePluginStream;
47 class WebNetscapePluginEventHandler;
49 typedef union PluginPort {
50 #ifndef NP_NO_QUICKDRAW
51 NP_Port qdPort;
52 #endif
53 NP_CGContext cgPort;
54 } PluginPort;
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;
67 NSURL *sourceURL;
68 WebFrame *_webFrame;
70 BOOL _loadManually;
71 RefPtr<WebNetscapePluginStream> _manualStream;
72 unsigned _dataLengthReceived;
73 NSError *_error;
75 int mode;
77 unsigned argsCount;
78 char **cAttributes;
79 char **cValues;
81 NPP plugin;
82 NPWindow window;
83 NPWindow lastSetWindow;
84 PluginPort nPort;
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;
93 #endif
95 WebNetscapePluginEventHandler *eventHandler;
97 BOOL isStarted;
98 BOOL inSetWindow;
99 BOOL hasFocus;
100 BOOL isTransparent;
101 BOOL isCompletelyObscured;
102 BOOL shouldStopSoon;
104 BOOL shouldFireTimers;
105 uint32 currentTimerID;
106 HashMap<uint32, PluginTimer*>* timers;
108 unsigned pluginFunctionCallDepth;
110 DOMElement *element;
112 int32 specifiedHeight;
113 int32 specifiedWidth;
115 NSString *MIMEType;
116 NSURL *baseURL;
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
144 URL:(NSURL *)URL
145 baseURL:(NSURL *)baseURL
146 MIMEType:(NSString *)MIME
147 attributeKeys:(NSArray *)keys
148 attributeValues:(NSArray *)values
149 loadManually:(BOOL)loadManually
150 DOMElement:(DOMElement *)anElement;
153 - (BOOL)start;
154 - (BOOL)isStarted;
155 - (void)stop;
156 - (void)stopTimers;
157 - (void)restartTimers;
159 - (WebFrame *)webFrame;
160 - (WebDataSource *)dataSource;
161 - (WebView *)webView;
162 - (NSWindow *)currentWindow;
164 - (NPP)plugin;
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;
195 @end
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;
213 - (void)forceRedraw;
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;
220 @end
222 #endif