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>
33 #import <WebKit/npfunctions.h>
34 #import <WebKit/npapi.h>
35 #import <WebKit/WebBasePluginPackage.h>
36 #import <wtf/HashMap.h>
41 @class WebNetscapePluginPackage;
42 @class WebNetscapePluginNullEventSender;
43 @class WebBaseNetscapePluginStream;
44 @class WebNetscapePluginStream;
48 class WebNetscapePluginEventHandler;
50 typedef union PluginPort {
51 #ifndef NP_NO_QUICKDRAW
58 @interface WebBaseNetscapePluginView : NSView <WebPluginManualLoader>
60 WebNetscapePluginPackage *pluginPackage;
66 WebNetscapePluginStream *_manualStream;
67 unsigned _dataLengthReceived;
78 NPWindow lastSetWindow;
80 PluginPort lastSetPort;
81 NPDrawingModel drawingModel;
82 NPEventModel eventModel;
84 // These are only valid when drawingModel is NPDrawingModelOpenGL
85 AGLContext aglContext;
88 #ifndef NP_NO_QUICKDRAW
89 // This is only valid when drawingModel is NPDrawingModelQuickDraw
90 GWorldPtr offscreenGWorld;
93 WebNetscapePluginEventHandler *eventHandler;
99 BOOL isCompletelyObscured;
102 BOOL shouldFireTimers;
103 uint32 currentTimerID;
104 HashMap<uint32, PluginTimer*>* timers;
106 unsigned pluginFunctionCallDepth;
110 int32 specifiedHeight;
111 int32 specifiedWidth;
115 NSTrackingRectTag trackingTag;
116 NSMutableArray *streams;
117 NSMutableDictionary *pendingFrameLoads;
119 NPP_NewProcPtr NPP_New;
120 NPP_DestroyProcPtr NPP_Destroy;
121 NPP_SetWindowProcPtr NPP_SetWindow;
122 NPP_NewStreamProcPtr NPP_NewStream;
123 NPP_DestroyStreamProcPtr NPP_DestroyStream;
124 NPP_StreamAsFileProcPtr NPP_StreamAsFile;
125 NPP_WriteReadyProcPtr NPP_WriteReady;
126 NPP_WriteProcPtr NPP_Write;
127 NPP_PrintProcPtr NPP_Print;
128 NPP_HandleEventProcPtr NPP_HandleEvent;
129 NPP_URLNotifyProcPtr NPP_URLNotify;
130 NPP_GetValueProcPtr NPP_GetValue;
131 NPP_SetValueProcPtr NPP_SetValue;
134 + (WebBaseNetscapePluginView *)currentPluginView;
137 - (id)initWithFrame:(NSRect)r
138 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
140 baseURL:(NSURL *)baseURL
141 MIMEType:(NSString *)MIME
142 attributeKeys:(NSArray *)keys
143 attributeValues:(NSArray *)values
144 loadManually:(BOOL)loadManually
145 DOMElement:(DOMElement *)anElement;
152 - (WebFrame *)webFrame;
153 - (WebDataSource *)dataSource;
154 - (WebView *)webView;
155 - (NSWindow *)currentWindow;
159 - (WebNetscapePluginPackage *)pluginPackage;
160 - (void)setPluginPackage:(WebNetscapePluginPackage *)thePluginPackage;
161 - (void)setMIMEType:(NSString *)theMIMEType;
162 - (void)setBaseURL:(NSURL *)theBaseURL;
163 - (void)setAttributeKeys:(NSArray *)keys andValues:(NSArray *)values;
164 - (void)setMode:(int)theMode;
165 - (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
166 - (void)viewDidMoveToHostWindow;
167 - (void)disconnectStream:(WebBaseNetscapePluginStream*)stream;
169 // Returns the NPObject that represents the plugin interface.
170 // The return value is expected to be retained.
171 - (NPObject *)createPluginScriptableObject;
173 // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
174 // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash
175 // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
176 // to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
177 // document.write(), which clears the document and destroys the plug-in.
178 // See <rdar://problem/4480737>.
179 - (void)willCallPlugInFunction;
181 // -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly
182 // once for every call to -willCallPlugInFunction.
183 // See <rdar://problem/4480737>.
184 - (void)didCallPlugInFunction;
186 - (void)handleMouseMoved:(NSEvent *)event;