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)
31
#import "WebBaseNetscapePluginView.h"
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>
42
@class WebNetscapePluginPackage;
46
class WebNetscapePluginStream;
47
class WebNetscapePluginEventHandler;
49
typedef union PluginPort {
50
#ifndef NP_NO_QUICKDRAW
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
61
@interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, WebPluginContainerCheckController>
63
RefPtr<WebNetscapePluginStream> _manualStream;
64
RetainPtr<CALayer> _pluginLayer;
65
unsigned _dataLengthReceived;
66
RetainPtr<NSError> _error;
74
NPWindow lastSetWindow;
76
PluginPort lastSetPort;
77
NPDrawingModel drawingModel;
78
NPEventModel eventModel;
80
#ifndef NP_NO_QUICKDRAW
81
// This is only valid when drawingModel is NPDrawingModelQuickDraw
82
GWorldPtr offscreenGWorld;
85
OwnPtr<WebNetscapePluginEventHandler> _eventHandler;
90
uint32_t currentTimerID;
91
HashMap<uint32_t, PluginTimer*>* timers;
93
unsigned pluginFunctionCallDepth;
95
int32_t specifiedHeight;
96
int32_t specifiedWidth;
98
HashSet<RefPtr<WebNetscapePluginStream> > streams;
99
RetainPtr<NSMutableDictionary> _pendingFrameLoads;
104
NSMutableDictionary *_containerChecksInProgress;
105
uint32_t _currentContainerCheckRequestID;
108
+ (WebNetscapePluginView *)currentPluginView;
111
- (id)initWithFrame:(NSRect)r
112
pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
114
baseURL:(NSURL *)baseURL
115
MIMEType:(NSString *)MIME
116
attributeKeys:(NSArray *)keys
117
attributeValues:(NSArray *)values
118
loadManually:(BOOL)loadManually
119
element:(PassRefPtr<WebCore::HTMLPlugInElement>)element;
124
- (void)disconnectStream:(WebNetscapePluginStream*)stream;
126
// Returns the NPObject that represents the plugin interface.
127
// The return value is expected to be retained.
128
- (NPObject *)createPluginScriptableObject;
130
// Returns the form value associated with the plugin instance.
131
- (BOOL)getFormValue:(NSString **)value;
133
// -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
134
// This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash
135
// at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
136
// to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
137
// document.write(), which clears the document and destroys the plug-in.
138
// See <rdar://problem/4480737>.
139
- (void)willCallPlugInFunction;
141
// -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly
142
// once for every call to -willCallPlugInFunction.
143
// See <rdar://problem/4480737>.
144
- (void)didCallPlugInFunction;
146
- (void)handleMouseMoved:(NSEvent *)event;
147
- (void)handleMouseEntered:(NSEvent *)event;
148
- (void)handleMouseExited:(NSEvent *)event;
150
- (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;
151
- (void)cancelCheckIfAllowedToLoadURL:(uint32_t)checkID;
155
@interface WebNetscapePluginView (WebInternal)
156
- (BOOL)sendEvent:(void*)event isDrawRect:(BOOL)eventIsDrawRect;
157
- (NPEventModel)eventModel;
158
- (CALayer *)pluginLayer;
159
- (NPError)loadRequest:(NSURLRequest *)request inTarget:(NSString *)target withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification;
160
- (NPError)getURLNotify:(const char *)URL target:(const char *)target notifyData:(void *)notifyData;
161
- (NPError)getURL:(const char *)URL target:(const char *)target;
162
- (NPError)postURLNotify:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData;
163
- (NPError)postURL:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file;
164
- (NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream;
165
- (NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer;
166
- (NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason;
167
- (void)status:(const char *)message;
168
- (const char *)userAgent;
169
- (void)invalidateRect:(NPRect *)invalidRect;
170
- (void)invalidateRegion:(NPRegion)invalidateRegion;
172
- (NPError)getVariable:(NPNVariable)variable value:(void *)value;
173
- (NPError)setVariable:(NPPVariable)variable value:(void *)value;
174
- (uint32_t)scheduleTimerWithInterval:(uint32_t)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32_t timerID))timerFunc;
175
- (void)unscheduleTimer:(uint32_t)timerID;
176
- (NPError)popUpContextMenu:(NPMenu *)menu;
177
- (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32_t*)length;
178
- (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32_t)length;
179
- (NPError)getAuthenticationInfoWithProtocol:(const char*) protocol host:(const char*)host port:(int32_t)port scheme:(const char*)scheme realm:(const char*)realm
180
username:(char**)username usernameLength:(uint32_t*)usernameLength
181
password:(char**)password passwordLength:(uint32_t*)passwordLength;
182
- (char*)resolveURL:(const char*)url forTarget:(const char*)target;
185
WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs();