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#import <Cocoa/Cocoa.h>
31
32#import "WebNetscapePluginPackage.h"
33#import "WebPluginContainerCheck.h"
34#import <wtf/Forward.h>
35#import <wtf/OwnPtr.h>
36#import <wtf/PassRefPtr.h>
37#import <wtf/RefPtr.h>
38#import <wtf/RetainPtr.h>
39
40@class DOMElement;
41@class WebDataSource;
42@class WebFrame;
43@class WebView;
44
45namespace WebCore {
46    class HTMLPlugInElement;
47}
48
49// Also declared in WebCore/WidgetMac.mm
50@interface NSView (Widget)
51- (void)visibleRectDidChange;
52@end
53
54@interface WebBaseNetscapePluginView : NSView
55{
56    RetainPtr<WebNetscapePluginPackage> _pluginPackage;
57
58    WebFrame *_webFrame;
59
60    int _mode;
61
62    BOOL _triedAndFailedToCreatePlugin;
63    BOOL _loadManually;
64    BOOL _shouldFireTimers;
65    BOOL _isStarted;
66    BOOL _hasFocus;
67    BOOL _isCompletelyObscured;
68    BOOL _isPrivateBrowsingEnabled;
69    BOOL _snapshotting;
70
71    RefPtr<WebCore::HTMLPlugInElement> _element;
72    RetainPtr<NSString> _MIMEType;
73    RetainPtr<NSURL> _baseURL;
74    RetainPtr<NSURL> _sourceURL;
75    RetainPtr<NSImage> _cachedSnapshot;
76
77    NSTrackingRectTag _trackingTag;
78}
79
80- (id)initWithFrame:(NSRect)r
81      pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
82                URL:(NSURL *)URL
83            baseURL:(NSURL *)baseURL
84           MIMEType:(NSString *)MIME
85      attributeKeys:(NSArray *)keys
86    attributeValues:(NSArray *)values
87       loadManually:(BOOL)loadManually
88            element:(PassRefPtr<WebCore::HTMLPlugInElement>)element;
89
90- (WebNetscapePluginPackage *)pluginPackage;
91
92- (NSURL *)URLWithCString:(const char *)URLCString;
93- (NSMutableURLRequest *)requestWithURLCString:(const char *)URLCString;
94
95// Subclasses must override these.
96// The "handle" prefix is needed to avoid overriding NSView methods.
97- (void)handleMouseMoved:(NSEvent *)event;
98- (void)handleMouseEntered:(NSEvent *)event;
99- (void)handleMouseExited:(NSEvent *)event;
100- (void)setAttributeKeys:(NSArray *)keys andValues:(NSArray *)values;
101- (void)focusChanged;
102- (void)updateAndSetWindow;
103
104- (WebFrame *)webFrame;
105- (WebDataSource *)dataSource;
106- (WebView *)webView;
107- (NSWindow *)currentWindow;
108- (WebCore::HTMLPlugInElement*)element;
109
110- (void)removeTrackingRect;
111- (void)resetTrackingRect;
112
113- (void)stopTimers;
114- (void)startTimers;
115- (void)restartTimers;
116
117- (void)start;
118- (void)stop;
119
120- (void)addWindowObservers;
121- (void)removeWindowObservers;
122- (BOOL)shouldClipOutPlugin;
123- (BOOL)inFlatteningPaint;
124
125- (BOOL)supportsSnapshotting;
126- (void)cacheSnapshot;
127- (void)clearCachedSnapshot;
128
129- (BOOL)convertFromX:(double)sourceX andY:(double)sourceY space:(NPCoordinateSpace)sourceSpace
130                 toX:(double *)destX andY:(double *)destY space:(NPCoordinateSpace)destSpace;
131- (WTF::CString)resolvedURLStringForURL:(const char*)url target:(const char*)target;
132
133- (void)invalidatePluginContentRect:(NSRect)rect;
134
135- (NSRect)actualVisibleRectInWindow; // takes transforms into account.
136
137- (CALayer *)pluginLayer;
138
139- (BOOL)getFormValue:(NSString **)value;
140
141@end
142
143
144namespace WebKit {
145bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
146                           WTF::CString& username, WTF::CString& password);
147}
148
149#endif
150
151