Add serialization for CFURLRequestRef and CFURLResponseRef.
[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
161 CGContextRef WKIOSurfaceContextCreate(IOSurfaceRef, unsigned width, unsigned height, CGColorSpaceRef);
162 CGImageRef WKIOSurfaceContextCreateImage(CGContextRef context);
163 #endif
164
165 #ifndef __LP64__
166 NSEvent *WKCreateNSEventWithCarbonEvent(EventRef eventRef);
167 NSEvent *WKCreateNSEventWithCarbonMouseMoveEvent(EventRef inEvent, NSWindow *window);
168 NSEvent *WKCreateNSEventWithCarbonClickEvent(EventRef inEvent, WindowRef windowRef);
169 #endif
170
171 CGContextRef WKNSWindowOverrideCGContext(NSWindow *, CGContextRef);
172 void WKNSWindowRestoreCGContext(NSWindow *, CGContextRef);
173
174 void WKNSWindowMakeBottomCornersSquare(NSWindow *);
175
176 // These constants match the ones used by ThemeScrollbarArrowStyle (some of the values are private, so we can't just
177 // use that enum directly).
178 typedef enum {
179     WKThemeScrollBarArrowsSingle     = 0,
180     WKThemeScrollBarArrowsLowerRight = 1,
181     WKThemeScrollBarArrowsDouble     = 2,
182     WKThemeScrollBarArrowsUpperLeft  = 3,
183 } WKThemeScrollBarArrowStyle;
184
185 OSStatus WKThemeDrawTrack(const HIThemeTrackDrawInfo* inDrawInfo, CGContextRef inContext, int inArrowStyle);
186
187 #ifdef BUILDING_ON_TIGER
188 // WKSupportsMultipartXMixedReplace is not required on Leopard as multipart/x-mixed-replace is always handled by NSURLRequest
189 BOOL WKSupportsMultipartXMixedReplace(NSMutableURLRequest *request);
190 #endif
191
192 BOOL WKCGContextIsBitmapContext(CGContextRef context);
193
194 void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
195
196 BOOL WKAppVersionCheckLessThan(NSString *, int, double);
197
198 typedef enum {
199     WKMovieTypeUnknown,
200     WKMovieTypeDownload,
201     WKMovieTypeStoredStream,
202     WKMovieTypeLiveStream
203 } WKMovieType;
204
205 int WKQTMovieGetType(QTMovie* movie);
206
207 BOOL WKQTMovieHasClosedCaptions(QTMovie* movie);
208 void WKQTMovieSetShowClosedCaptions(QTMovie* movie, BOOL showClosedCaptions);
209 void WKQTMovieSelectPreferredAlternates(QTMovie* movie);
210 void WKQTMovieSelectPreferredAlternateTrackForMediaType(QTMovie* movie, NSString* mediaType);
211
212 unsigned WKQTIncludeOnlyModernMediaFileTypes(void);
213 int WKQTMovieDataRate(QTMovie* movie);
214 float WKQTMovieMaxTimeLoaded(QTMovie* movie);
215 float WKQTMovieMaxTimeSeekable(QTMovie* movie);
216 NSString *WKQTMovieMaxTimeLoadedChangeNotification(void);
217 void WKQTMovieViewSetDrawSynchronously(QTMovieView* view, BOOL sync);
218 void WKQTMovieDisableComponent(uint32_t[5]);
219
220 CFStringRef WKCopyFoundationCacheDirectory(void);
221
222 void WKSetVisibleApplicationName(CFStringRef);
223
224 typedef enum {
225     WKMediaUIPartFullscreenButton   = 0,
226     WKMediaUIPartMuteButton,
227     WKMediaUIPartPlayButton,
228     WKMediaUIPartSeekBackButton,
229     WKMediaUIPartSeekForwardButton,
230     WKMediaUIPartTimelineSlider,
231     WKMediaUIPartTimelineSliderThumb,
232     WKMediaUIPartRewindButton,
233     WKMediaUIPartSeekToRealtimeButton,
234     WKMediaUIPartShowClosedCaptionsButton,
235     WKMediaUIPartHideClosedCaptionsButton,
236     WKMediaUIPartUnMuteButton,
237     WKMediaUIPartPauseButton,
238     WKMediaUIPartBackground,
239     WKMediaUIPartCurrentTimeDisplay,
240     WKMediaUIPartTimeRemainingDisplay,
241     WKMediaUIPartStatusDisplay,
242     WKMediaUIPartControlsPanel,
243     WKMediaUIPartVolumeSliderContainer,
244     WKMediaUIPartVolumeSlider,
245     WKMediaUIPartVolumeSliderThumb
246 } WKMediaUIPart;
247
248 typedef enum {
249     WKMediaControllerThemeClassic   = 1,
250     WKMediaControllerThemeQuickTime = 2
251 } WKMediaControllerThemeStyle;
252
253 typedef enum {
254     WKMediaControllerFlagDisabled = 1 << 0,
255     WKMediaControllerFlagPressed = 1 << 1,
256     WKMediaControllerFlagDrawEndCaps = 1 << 3,
257     WKMediaControllerFlagFocused = 1 << 4
258 } WKMediaControllerThemeState;
259
260 BOOL WKMediaControllerThemeAvailable(int themeStyle);
261 BOOL WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
262 void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
263 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
264 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
265 NSView *WKCreateMediaUIBackgroundView(void);
266
267 typedef enum {
268     WKMediaUIControlTimeline,
269     WKMediaUIControlSlider,
270     WKMediaUIControlPlayPauseButton,
271     WKMediaUIControlExitFullscreenButton,
272     WKMediaUIControlRewindButton,
273     WKMediaUIControlFastForwardButton,
274     WKMediaUIControlVolumeUpButton,
275     WKMediaUIControlVolumeDownButton
276 } WKMediaUIControlType;
277     
278 NSControl *WKCreateMediaUIControl(int controlType);
279
280 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
281 mach_port_t WKInitializeRenderServer(void);
282     
283 @class CALayer;
284
285 CALayer *WKMakeRenderLayer(uint32_t contextID);
286     
287 typedef struct __WKSoftwareCARendererRef *WKSoftwareCARendererRef;
288
289 WKSoftwareCARendererRef WKSoftwareCARendererCreate(uint32_t contextID);
290 void WKSoftwareCARendererDestroy(WKSoftwareCARendererRef);
291 void WKSoftwareCARendererRender(WKSoftwareCARendererRef, CGContextRef, CGRect);
292
293 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
294
295 WKCARemoteLayerClientRef WKCARemoteLayerClientMakeWithServerPort(mach_port_t port);
296 void WKCARemoteLayerClientInvalidate(WKCARemoteLayerClientRef);
297 uint32_t WKCARemoteLayerClientGetClientId(WKCARemoteLayerClientRef);
298 void WKCARemoteLayerClientSetLayer(WKCARemoteLayerClientRef, CALayer *);
299 CALayer *WKCARemoteLayerClientGetLayer(WKCARemoteLayerClientRef);
300
301 typedef struct __WKWindowBounceAnimationContext *WKWindowBounceAnimationContextRef;
302
303 WKWindowBounceAnimationContextRef WKWindowBounceAnimationContextCreate(NSWindow *window);
304 void WKWindowBounceAnimationContextDestroy(WKWindowBounceAnimationContextRef context);
305 void WKWindowBounceAnimationSetAnimationProgress(WKWindowBounceAnimationContextRef context, double animationProgress);
306
307 #if defined(__x86_64__)
308 #import <mach/mig.h>
309 CFRunLoopSourceRef WKCreateMIGServerSource(mig_subsystem_t subsystem, mach_port_t serverPort);
310 #endif // defined(__x86_64__)
311
312 NSUInteger WKGetInputPanelWindowStyle(void);
313 UInt8 WKGetNSEventKeyChar(NSEvent *);
314 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
315
316 @class CAPropertyAnimation;
317 void WKSetCAAnimationValueFunction(CAPropertyAnimation*, NSString* function);
318
319 unsigned WKInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
320
321 void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
322 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
323 CFHTTPMessageRef WKCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL);
324
325 BOOL WKIsLatchingWheelEvent(NSEvent *);
326
327 #ifndef BUILDING_ON_TIGER
328 void WKWindowSetAlpha(NSWindow *window, float alphaValue);
329 void WKWindowSetScaledFrame(NSWindow *window, NSRect scaleFrame, NSRect nonScaledFrame);
330 #endif
331
332 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
333 void WKSyncSurfaceToView(NSView *view);
334
335 void WKEnableSettingCursorWhenInBackground(void);
336
337 CFDictionaryRef WKNSURLRequestCreateSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull);
338 NSURLRequest *WKNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
339
340 CFDictionaryRef WKNSURLResponseCreateSerializableRepresentation(NSURLResponse *response, CFTypeRef tokenNull);
341 NSURLResponse *WKNSURLResponseFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
342
343 #ifndef __LP64__
344 ScriptCode WKGetScriptCodeFromCurrentKeyboardInputSource(void);
345 #endif
346
347 #endif
348
349 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
350 CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
351 #endif
352
353 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
354 typedef enum {
355     WKSandboxExtensionTypeReadOnly,
356     WKSandboxExtensionTypeWriteOnly,    
357     WKSandboxExtensionTypeReadWrite,
358 } WKSandboxExtensionType;
359 typedef struct __WKSandboxExtension *WKSandboxExtensionRef;
360
361 WKSandboxExtensionRef WKSandboxExtensionCreate(const char* path, WKSandboxExtensionType type);
362 void WKSandboxExtensionDestroy(WKSandboxExtensionRef sandboxExtension);
363
364 bool WKSandboxExtensionConsume(WKSandboxExtensionRef sandboxExtension);
365 bool WKSandboxExtensionInvalidate(WKSandboxExtensionRef sandboxExtension);
366
367 const char* WKSandboxExtensionGetSerializedFormat(WKSandboxExtensionRef sandboxExtension, size_t* length);
368 WKSandboxExtensionRef WKSandboxExtensionCreateFromSerializedFormat(const char* serializationFormat, size_t length);
369
370 #endif
371
372 #ifdef __cplusplus
373 }
374 #endif