Cannot use NSKeyedArchiver in WK2 for ResourceResponses
[WebKit-https.git] / WebKitLibraries / WebKitSystemInterface.h
1 /*      
2     WebKitSystemInterface.h
3     Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4
5     Public header file.
6 */
7
8 #import <Cocoa/Cocoa.h>
9 #import <Carbon/Carbon.h>
10
11 @class QTMovie;
12 @class QTMovieView;
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 typedef enum {
19     WKCertificateParseResultSucceeded  = 0,
20     WKCertificateParseResultFailed     = 1,
21     WKCertificateParseResultPKCS7      = 2,
22 } WKCertificateParseResult;
23
24 CFStringRef WKCopyCFLocalizationPreferredName(CFStringRef localization);
25 CFStringRef WKSignedPublicKeyAndChallengeString(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
26 WKCertificateParseResult WKAddCertificatesToKeychainFromData(const void *bytes, unsigned length);
27
28 NSString *WKGetPreferredExtensionForMIMEType(NSString *type);
29 NSArray *WKGetExtensionsForMIMEType(NSString *type);
30 NSString *WKGetMIMETypeForExtension(NSString *extension);
31
32 NSDate *WKGetNSURLResponseLastModifiedDate(NSURLResponse *response);
33 NSTimeInterval WKGetNSURLResponseFreshnessLifetime(NSURLResponse *response);
34 NSString *WKCopyNSURLResponseStatusLine(NSURLResponse *response);
35
36 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
37 CFArrayRef WKCopyNSURLResponseCertificateChain(NSURLResponse *response);
38 #endif
39
40 CFStringEncoding WKGetWebDefaultCFStringEncoding(void);
41
42 void WKSetMetadataURL(NSString *URLString, NSString *referrer, NSString *path);
43 void WKSetNSURLConnectionDefersCallbacks(NSURLConnection *connection, BOOL defers);
44
45 void WKShowKeyAndMain(void);
46 #ifndef __LP64__
47 OSStatus WKSyncWindowWithCGAfterMove(WindowRef);
48 unsigned WKCarbonWindowMask(void);
49 void *WKGetNativeWindowFromWindowRef(WindowRef);
50 OSType WKCarbonWindowPropertyCreator(void);
51 OSType WKCarbonWindowPropertyTag(void);
52 #endif
53
54 typedef id WKNSURLConnectionDelegateProxyPtr;
55
56 WKNSURLConnectionDelegateProxyPtr WKCreateNSURLConnectionDelegateProxy(void);
57
58 void WKDisableCGDeferredUpdates(void);
59
60 Class WKNSURLProtocolClassForRequest(NSURLRequest *request);
61 void WKSetNSURLRequestShouldContentSniff(NSMutableURLRequest *request, BOOL shouldContentSniff);
62
63 void WKSetCookieStoragePrivateBrowsingEnabled(BOOL enabled);
64
65 unsigned WKGetNSAutoreleasePoolCount(void);
66
67 void WKAdvanceDefaultButtonPulseAnimation(NSButtonCell *button);
68
69 NSString *WKMouseMovedNotification(void);
70 NSString *WKWindowWillOrderOnScreenNotification(void);
71 void WKSetNSWindowShouldPostEventNotifications(NSWindow *window, BOOL post);
72
73 CFTypeID WKGetAXTextMarkerTypeID(void);
74 CFTypeID WKGetAXTextMarkerRangeTypeID(void);
75 CFTypeRef WKCreateAXTextMarker(const void *bytes, size_t len);
76 BOOL WKGetBytesFromAXTextMarker(CFTypeRef textMarker, void *bytes, size_t length);
77 CFTypeRef WKCreateAXTextMarkerRange(CFTypeRef start, CFTypeRef end);
78 CFTypeRef WKCopyAXTextMarkerRangeStart(CFTypeRef range);
79 CFTypeRef WKCopyAXTextMarkerRangeEnd(CFTypeRef range);
80 void WKAccessibilityHandleFocusChanged(void);
81 AXUIElementRef WKCreateAXUIElementRef(id element);
82 void WKUnregisterUniqueIdForElement(id element);
83
84 void WKSetUpFontCache(void);
85
86 void WKSignalCFReadStreamEnd(CFReadStreamRef stream);
87 void WKSignalCFReadStreamHasBytes(CFReadStreamRef stream);
88 void WKSignalCFReadStreamError(CFReadStreamRef stream, CFStreamError *error);
89
90 CFReadStreamRef WKCreateCustomCFReadStream(void *(*formCreate)(CFReadStreamRef, void *), 
91     void (*formFinalize)(CFReadStreamRef, void *), 
92     Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *), 
93     CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *), 
94     Boolean (*formCanRead)(CFReadStreamRef, void *), 
95     void (*formClose)(CFReadStreamRef, void *), 
96     void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *), 
97     void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
98     void *context);
99
100 void WKDrawCapsLockIndicator(CGContextRef, CGRect);
101
102 void WKDrawFocusRing(CGContextRef context, CGColorRef color, int radius);
103     // The CG context's current path is the focus ring's path.
104     // A color of 0 means "use system focus ring color".
105     // A radius of 0 means "use default focus ring radius".
106
107 void WKSetDragImage(NSImage *image, NSPoint offset);
108
109 void WKDrawBezeledTextFieldCell(NSRect, BOOL enabled);
110 void WKDrawTextFieldCellFocusRing(NSTextFieldCell*, NSRect);
111 void WKDrawBezeledTextArea(NSRect, BOOL enabled);
112 void WKPopupMenu(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
113
114 void WKSendUserChangeNotifications(void);
115 #ifndef __LP64__
116 BOOL WKConvertNSEventToCarbonEvent(EventRecord *carbonEvent, NSEvent *cocoaEvent);
117 void WKSendKeyEventToTSM(NSEvent *theEvent);
118 void WKCallDrawingNotification(CGrafPtr port, Rect *bounds);
119 #endif
120
121 BOOL WKGetGlyphTransformedAdvances(CGFontRef, NSFont*, CGAffineTransform *m, ATSGlyphRef *glyph, CGSize *advance);
122 NSFont *WKGetFontInLanguageForRange(NSFont *font, NSString *string, NSRange range);
123 NSFont *WKGetFontInLanguageForCharacter(NSFont *font, UniChar ch);
124 void WKSetCGFontRenderingMode(CGContextRef cgContext, NSFont *font);
125 BOOL WKCGContextGetShouldSmoothFonts(CGContextRef cgContext);
126
127 #ifdef BUILDING_ON_TIGER
128 // CGFontGetAscent, CGFontGetDescent, CGFontGetLeading and CGFontGetUnitsPerEm were not available until Leopard
129 void WKGetFontMetrics(CGFontRef font, int *ascent, int *descent, int *lineGap, unsigned *unitsPerEm);
130 // CTFontCopyGraphicsFont was not available until Leopard
131 CGFontRef WKGetCGFontFromNSFont(NSFont *font);
132 // CTFontGetPlatformFont was not available until Leopard
133 ATSUFontID WKGetNSFontATSUFontId(NSFont *font);
134 // CGFontCopyFullName was not available until Leopard
135 CFStringRef WKCopyFullFontName(CGFontRef font);
136 #endif
137
138 void WKSetPatternBaseCTM(CGContextRef, CGAffineTransform);
139 void WKSetPatternPhaseInUserSpace(CGContextRef, CGPoint);
140 CGAffineTransform WKGetUserToBaseCTM(CGContextRef);
141
142 #ifndef BUILDING_ON_TIGER
143 void WKGetGlyphsForCharacters(CGFontRef, const UniChar[], CGGlyph[], size_t);
144 #else
145 typedef void *WKGlyphVectorRef;
146 OSStatus WKConvertCharToGlyphs(void *styleGroup, const UniChar* characters, unsigned numCharacters, WKGlyphVectorRef glyphs);
147 OSStatus WKGetATSStyleGroup(ATSUStyle fontStyle, void **styleGroup);
148 void WKReleaseStyleGroup(void *group);
149 OSStatus WKInitializeGlyphVector(int count, WKGlyphVectorRef glyphs);
150 void WKClearGlyphVector(WKGlyphVectorRef glyphs);
151
152 int WKGetGlyphVectorNumGlyphs(WKGlyphVectorRef glyphVector);
153 ATSLayoutRecord *WKGetGlyphVectorFirstRecord(WKGlyphVectorRef glyphVector);
154 size_t WKGetGlyphVectorRecordSize(WKGlyphVectorRef glyphVector);
155 #endif
156
157 CTLineRef WKCreateCTLineWithUniCharProvider(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
158 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
159 CTTypesetterRef WKCreateCTTypesetterWithUniCharProviderAndOptions(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
160 #endif
161
162 #ifndef __LP64__
163 NSEvent *WKCreateNSEventWithCarbonEvent(EventRef eventRef);
164 NSEvent *WKCreateNSEventWithCarbonMouseMoveEvent(EventRef inEvent, NSWindow *window);
165 NSEvent *WKCreateNSEventWithCarbonClickEvent(EventRef inEvent, WindowRef windowRef);
166 #endif
167
168 CGContextRef WKNSWindowOverrideCGContext(NSWindow *, CGContextRef);
169 void WKNSWindowRestoreCGContext(NSWindow *, CGContextRef);
170
171 void WKNSWindowMakeBottomCornersSquare(NSWindow *);
172
173 // These constants match the ones used by ThemeScrollbarArrowStyle (some of the values are private, so we can't just
174 // use that enum directly).
175 typedef enum {
176     WKThemeScrollBarArrowsSingle     = 0,
177     WKThemeScrollBarArrowsLowerRight = 1,
178     WKThemeScrollBarArrowsDouble     = 2,
179     WKThemeScrollBarArrowsUpperLeft  = 3,
180 } WKThemeScrollBarArrowStyle;
181
182 OSStatus WKThemeDrawTrack(const HIThemeTrackDrawInfo* inDrawInfo, CGContextRef inContext, int inArrowStyle);
183
184 #ifdef BUILDING_ON_TIGER
185 // WKSupportsMultipartXMixedReplace is not required on Leopard as multipart/x-mixed-replace is always handled by NSURLRequest
186 BOOL WKSupportsMultipartXMixedReplace(NSMutableURLRequest *request);
187 #endif
188
189 BOOL WKCGContextIsBitmapContext(CGContextRef context);
190
191 void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
192
193 BOOL WKAppVersionCheckLessThan(NSString *, int, double);
194
195 typedef enum {
196     WKMovieTypeUnknown,
197     WKMovieTypeDownload,
198     WKMovieTypeStoredStream,
199     WKMovieTypeLiveStream
200 } WKMovieType;
201
202 int WKQTMovieGetType(QTMovie* movie);
203
204 BOOL WKQTMovieHasClosedCaptions(QTMovie* movie);
205 void WKQTMovieSetShowClosedCaptions(QTMovie* movie, BOOL showClosedCaptions);
206 void WKQTMovieSelectPreferredAlternates(QTMovie* movie);
207 void WKQTMovieSelectPreferredAlternateTrackForMediaType(QTMovie* movie, NSString* mediaType);
208
209 unsigned WKQTIncludeOnlyModernMediaFileTypes(void);
210 int WKQTMovieDataRate(QTMovie* movie);
211 float WKQTMovieMaxTimeLoaded(QTMovie* movie);
212 float WKQTMovieMaxTimeSeekable(QTMovie* movie);
213 NSString *WKQTMovieMaxTimeLoadedChangeNotification(void);
214 void WKQTMovieViewSetDrawSynchronously(QTMovieView* view, BOOL sync);
215 void WKQTMovieDisableComponent(uint32_t[5]);
216
217 CFStringRef WKCopyFoundationCacheDirectory(void);
218
219 void WKSetVisibleApplicationName(CFStringRef);
220
221 typedef enum {
222     WKMediaUIPartFullscreenButton   = 0,
223     WKMediaUIPartMuteButton,
224     WKMediaUIPartPlayButton,
225     WKMediaUIPartSeekBackButton,
226     WKMediaUIPartSeekForwardButton,
227     WKMediaUIPartTimelineSlider,
228     WKMediaUIPartTimelineSliderThumb,
229     WKMediaUIPartRewindButton,
230     WKMediaUIPartSeekToRealtimeButton,
231     WKMediaUIPartShowClosedCaptionsButton,
232     WKMediaUIPartHideClosedCaptionsButton,
233     WKMediaUIPartUnMuteButton,
234     WKMediaUIPartPauseButton,
235     WKMediaUIPartBackground,
236     WKMediaUIPartCurrentTimeDisplay,
237     WKMediaUIPartTimeRemainingDisplay,
238     WKMediaUIPartStatusDisplay,
239     WKMediaUIPartControlsPanel,
240     WKMediaUIPartVolumeSliderContainer,
241     WKMediaUIPartVolumeSlider,
242     WKMediaUIPartVolumeSliderThumb
243 } WKMediaUIPart;
244
245 typedef enum {
246     WKMediaControllerThemeClassic   = 1,
247     WKMediaControllerThemeQuickTime = 2
248 } WKMediaControllerThemeStyle;
249
250 typedef enum {
251     WKMediaControllerFlagDisabled = 1 << 0,
252     WKMediaControllerFlagPressed = 1 << 1,
253     WKMediaControllerFlagDrawEndCaps = 1 << 3,
254     WKMediaControllerFlagFocused = 1 << 4
255 } WKMediaControllerThemeState;
256
257 BOOL WKMediaControllerThemeAvailable(int themeStyle);
258 BOOL WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
259 void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
260 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
261 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
262 NSView *WKCreateMediaUIBackgroundView(void);
263
264 typedef enum {
265     WKMediaUIControlTimeline,
266     WKMediaUIControlSlider,
267     WKMediaUIControlPlayPauseButton,
268     WKMediaUIControlExitFullscreenButton,
269     WKMediaUIControlRewindButton,
270     WKMediaUIControlFastForwardButton,
271     WKMediaUIControlVolumeUpButton,
272     WKMediaUIControlVolumeDownButton
273 } WKMediaUIControlType;
274     
275 NSControl *WKCreateMediaUIControl(int controlType);
276
277 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
278 mach_port_t WKInitializeRenderServer(void);
279     
280 @class CALayer;
281
282 CALayer *WKMakeRenderLayer(uint32_t contextID);
283     
284 typedef struct __WKSoftwareCARendererRef *WKSoftwareCARendererRef;
285
286 WKSoftwareCARendererRef WKSoftwareCARendererCreate(uint32_t contextID);
287 void WKSoftwareCARendererDestroy(WKSoftwareCARendererRef);
288 void WKSoftwareCARendererRender(WKSoftwareCARendererRef, CGContextRef, CGRect);
289
290 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
291
292 WKCARemoteLayerClientRef WKCARemoteLayerClientMakeWithServerPort(mach_port_t port);
293 void WKCARemoteLayerClientInvalidate(WKCARemoteLayerClientRef);
294 uint32_t WKCARemoteLayerClientGetClientId(WKCARemoteLayerClientRef);
295 void WKCARemoteLayerClientSetLayer(WKCARemoteLayerClientRef, CALayer *);
296 CALayer *WKCARemoteLayerClientGetLayer(WKCARemoteLayerClientRef);
297
298 typedef struct __WKWindowBounceAnimationContext *WKWindowBounceAnimationContextRef;
299
300 WKWindowBounceAnimationContextRef WKWindowBounceAnimationContextCreate(NSWindow *window);
301 void WKWindowBounceAnimationContextDestroy(WKWindowBounceAnimationContextRef context);
302 void WKWindowBounceAnimationSetAnimationProgress(WKWindowBounceAnimationContextRef context, double animationProgress);
303
304 #if defined(__x86_64__)
305 #import <mach/mig.h>
306 CFRunLoopSourceRef WKCreateMIGServerSource(mig_subsystem_t subsystem, mach_port_t serverPort);
307 #endif // defined(__x86_64__)
308
309 NSUInteger WKGetInputPanelWindowStyle(void);
310 UInt8 WKGetNSEventKeyChar(NSEvent *);
311 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
312
313 @class CAPropertyAnimation;
314 void WKSetCAAnimationValueFunction(CAPropertyAnimation*, NSString* function);
315
316 unsigned WKInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
317
318 void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
319 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
320 CFHTTPMessageRef WKCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL);
321
322 BOOL WKIsLatchingWheelEvent(NSEvent *);
323
324 #ifndef BUILDING_ON_TIGER
325 void WKWindowSetAlpha(NSWindow *window, float alphaValue);
326 void WKWindowSetScaledFrame(NSWindow *window, NSRect scaleFrame, NSRect nonScaledFrame);
327 #endif
328
329 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
330 void WKSyncSurfaceToView(NSView *view);
331
332 void WKEnableSettingCursorWhenInBackground(void);
333
334 CFDictionaryRef WKNSURLRequestCreateSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull);
335 NSURLRequest *WKNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
336
337 CFDictionaryRef WKNSURLResponseCreateSerializableRepresentation(NSURLResponse *response, CFTypeRef tokenNull);
338 NSURLResponse *WKNSURLResponseFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
339     
340 #endif
341
342 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
343 CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
344 #endif
345
346 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
347 typedef enum {
348     WKSandboxExtensionTypeReadOnly,
349     WKSandboxExtensionTypeWriteOnly,    
350     WKSandboxExtensionTypeReadWrite,
351 } WKSandboxExtensionType;
352 typedef struct __WKSandboxExtension *WKSandboxExtensionRef;
353
354 WKSandboxExtensionRef WKSandboxExtensionCreate(const char* path, WKSandboxExtensionType type);
355 void WKSandboxExtensionDestroy(WKSandboxExtensionRef sandboxExtension);
356
357 bool WKSandboxExtensionConsume(WKSandboxExtensionRef sandboxExtension);
358 bool WKSandboxExtensionInvalidate(WKSandboxExtensionRef sandboxExtension);
359
360 const char* WKSandboxExtensionGetSerializedFormat(WKSandboxExtensionRef sandboxExtension, size_t* length);
361 WKSandboxExtensionRef WKSandboxExtensionCreateFromSerializedFormat(const char* serializationFormat, size_t length);
362
363 #endif
364
365 #ifdef __cplusplus
366 }
367 #endif