• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_t currentTimerID;
93     HashMap<uint32_t, PluginTimer*>* timers;
94 
95     unsigned pluginFunctionCallDepth;
96 
97     int32_t specifiedHeight;
98     int32_t specifiedWidth;
99 
100     HashSet<RefPtr<WebNetscapePluginStream> > streams;
101     RetainPtr<NSMutableDictionary> _pendingFrameLoads;
102 
103     BOOL _isFlash;
104     BOOL _isSilverlight;
105 
106     NSMutableDictionary *_containerChecksInProgress;
107     uint32_t _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 - (void)handleMouseEntered:(NSEvent *)event;
147 - (void)handleMouseExited:(NSEvent *)event;
148 
149 - (uint32_t)checkIfAllowedToLoadURL:(const char*)urlCString frame:(const char*)frameNameCString callbackFunc:(void (*)(NPP npp, uint32_t checkID, NPBool allowed, void* context))callbackFunc context:(void*)context;
150 - (void)cancelCheckIfAllowedToLoadURL:(uint32_t)checkID;
151 
152 @end
153 
154 @interface WebNetscapePluginView (WebInternal)
155 - (BOOL)sendEvent:(void*)event isDrawRect:(BOOL)eventIsDrawRect;
156 - (NPEventModel)eventModel;
157 #ifndef BUILDING_ON_TIGER
158 - (CALayer *)pluginLayer;
159 #endif
160 - (NPError)loadRequest:(NSURLRequest *)request inTarget:(NSString *)target withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification;
161 - (NPError)getURLNotify:(const char *)URL target:(const char *)target notifyData:(void *)notifyData;
162 - (NPError)getURL:(const char *)URL target:(const char *)target;
163 - (NPError)postURLNotify:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData;
164 - (NPError)postURL:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file;
165 - (NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream;
166 - (NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer;
167 - (NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason;
168 - (void)status:(const char *)message;
169 - (const char *)userAgent;
170 - (void)invalidateRect:(NPRect *)invalidRect;
171 - (void)invalidateRegion:(NPRegion)invalidateRegion;
172 - (void)forceRedraw;
173 - (NPError)getVariable:(NPNVariable)variable value:(void *)value;
174 - (NPError)setVariable:(NPPVariable)variable value:(void *)value;
175 - (uint32_t)scheduleTimerWithInterval:(uint32_t)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32_t timerID))timerFunc;
176 - (void)unscheduleTimer:(uint32_t)timerID;
177 - (NPError)popUpContextMenu:(NPMenu *)menu;
178 - (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32_t*)length;
179 - (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32_t)length;
180 - (NPError)getAuthenticationInfoWithProtocol:(const char*) protocol host:(const char*)host port:(int32_t)port scheme:(const char*)scheme realm:(const char*)realm
181                                     username:(char**)username usernameLength:(uint32_t*)usernameLength
182                                     password:(char**)password passwordLength:(uint32_t*)passwordLength;
183 - (char*)resolveURL:(const char*)url forTarget:(const char*)target;
184 @end
185 
186 WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs();
187 
188 #endif
189 
190