1 /* 2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 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. 16 * 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. 27 */ 28 29 #if ENABLE(NETSCAPE_PLUGIN_API) 30 31 #import "WebBaseNetscapePluginView.h" 32 33 #import "WebNetscapeContainerCheckPrivate.h" 34 #import <WebKit/npfunctions.h> 35 #import <WebKit/npapi.h> 36 #import <wtf/HashMap.h> 37 #import <wtf/HashSet.h> 38 #import <wtf/OwnPtr.h> 39 40 @class WebDataSource; 41 @class WebFrame; 42 @class WebNetscapePluginPackage; 43 @class WebView; 44 45 class PluginTimer; 46 class WebNetscapePluginStream; 47 class WebNetscapePluginEventHandler; 48 49 typedef union PluginPort { 50 #ifndef NP_NO_QUICKDRAW 51 NP_Port qdPort; 52 #endif 53 NP_CGContext cgPort; 54 } PluginPort; 55 56 // Because the Adobe 7.x Acrobat plug-in has a hard coded check for a view named 57 // "WebNetscapePluginDocumentView", this class must retain the old name in order 58 // for the plug-in to function correctly. (rdar://problem/4699455) 59 #define WebNetscapePluginView WebNetscapePluginDocumentView 60 61 @interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, WebPluginContainerCheckController> 62 { 63 RefPtr<WebNetscapePluginStream> _manualStream; 64 #ifndef BUILDING_ON_TIGER 65 RetainPtr<CALayer> _pluginLayer; 66 #endif 67 unsigned _dataLengthReceived; 68 RetainPtr<NSError> _error; 69 70 unsigned argsCount; 71 char **cAttributes; 72 char **cValues; 73 74 NPP plugin; 75 NPWindow window; 76 NPWindow lastSetWindow; 77 PluginPort nPort; 78 PluginPort lastSetPort; 79 NPDrawingModel drawingModel; 80 NPEventModel eventModel; 81 82 #ifndef NP_NO_QUICKDRAW 83 // This is only valid when drawingModel is NPDrawingModelQuickDraw 84 GWorldPtr offscreenGWorld; 85 #endif 86 87 OwnPtr<WebNetscapePluginEventHandler> _eventHandler; 88 89 BOOL inSetWindow; 90 BOOL shouldStopSoon; 91 92 uint32 currentTimerID; 93 HashMap<uint32, PluginTimer*>* timers; 94 95 unsigned pluginFunctionCallDepth; 96 97 int32 specifiedHeight; 98 int32 specifiedWidth; 99 100 HashSet<RefPtr<WebNetscapePluginStream> > streams; 101 RetainPtr<NSMutableDictionary> _pendingFrameLoads; 102 103 BOOL _isFlash; 104 BOOL _isSilverlight; 105 106 NSMutableDictionary *_containerChecksInProgress; 107 uint32 _currentContainerCheckRequestID; 108 } 109 110 + (WebNetscapePluginView *)currentPluginView; 111 112 113 - (id)initWithFrame:(NSRect)r 114 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage 115 URL:(NSURL *)URL 116 baseURL:(NSURL *)baseURL 117 MIMEType:(NSString *)MIME 118 attributeKeys:(NSArray *)keys 119 attributeValues:(NSArray *)values 120 loadManually:(BOOL)loadManually 121 element:(PassRefPtr<WebCore::HTMLPlugInElement>)element; 122 123 124 - (NPP)plugin; 125 126 - (void)disconnectStream:(WebNetscapePluginStream*)stream; 127 128 // Returns the NPObject that represents the plugin interface. 129 // The return value is expected to be retained. 130 - (NPObject *)createPluginScriptableObject; 131 132 // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin. 133 // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash 134 // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy() 135 // to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a 136 // document.write(), which clears the document and destroys the plug-in. 137 // See <rdar://problem/4480737>. 138 - (void)willCallPlugInFunction; 139 140 // -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly 141 // once for every call to -willCallPlugInFunction. 142 // See <rdar://problem/4480737>. 143 - (void)didCallPlugInFunction; 144 145 - (void)handleMouseMoved:(NSEvent *)event; 146 - (uint32)checkIfAllowedToLoadURL:(const char*)urlCString frame:(const char*)frameNameCString callbackFunc:(void (*)(NPP npp, uint32 checkID, NPBool allowed, void* context))callbackFunc context:(void*)context; 147 - (void)cancelCheckIfAllowedToLoadURL:(uint32)checkID; 148 149 @end 150 151 @interface WebNetscapePluginView (WebInternal) 152 - (BOOL)sendEvent:(void*)event isDrawRect:(BOOL)eventIsDrawRect; 153 - (NPEventModel)eventModel; 154 155 - (NPError)loadRequest:(NSURLRequest *)request inTarget:(NSString *)target withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification; 156 - (NPError)getURLNotify:(const char *)URL target:(const char *)target notifyData:(void *)notifyData; 157 - (NPError)getURL:(const char *)URL target:(const char *)target; 158 - (NPError)postURLNotify:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData; 159 - (NPError)postURL:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file; 160 - (NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream; 161 - (NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer; 162 - (NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason; 163 - (void)status:(const char *)message; 164 - (const char *)userAgent; 165 - (void)invalidateRect:(NPRect *)invalidRect; 166 - (void)invalidateRegion:(NPRegion)invalidateRegion; 167 - (void)forceRedraw; 168 - (NPError)getVariable:(NPNVariable)variable value:(void *)value; 169 - (NPError)setVariable:(NPPVariable)variable value:(void *)value; 170 - (uint32)scheduleTimerWithInterval:(uint32)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32 timerID))timerFunc; 171 - (void)unscheduleTimer:(uint32)timerID; 172 - (NPError)popUpContextMenu:(NPMenu *)menu; 173 - (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32*)length; 174 - (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32)length; 175 - (NPError)getAuthenticationInfoWithProtocol:(const char*) protocol host:(const char*)host port:(int32)port scheme:(const char*)scheme realm:(const char*)realm 176 username:(char**)username usernameLength:(uint32*)usernameLength 177 password:(char**)password passwordLength:(uint32*)passwordLength; 178 - (char*)resolveURL:(const char*)url forTarget:(const char*)target; 179 @end 180 181 WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs(); 182 183 #endif 184 185