Make adjustMIMETypeIfNecessary use CFNetwork directly
[WebKit-https.git] / Source / WebCore / platform / mac / WebCoreSystemInterface.mm
1 /*
2  * Copyright 2006, 2007, 2008, 2009, 2010 Apple Computer, 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  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #import "config.h"
27 #import "WebCoreSystemInterface.h"
28 #import <Foundation/Foundation.h>
29
30 void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
31 BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
32 CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
33 NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
34 NSString* (*wkCreateURLPasteboardFlavorTypeName)(void);
35 NSString* (*wkCreateURLNPasteboardFlavorTypeName)(void);
36 void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
37 void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
38 void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
39 void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
40 void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
41 NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
42 NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
43 BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
44 void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, 
45     float duration, unsigned state);
46 BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point);
47 void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
48 void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
49 BOOL (*wkMediaControllerThemeAvailable)(int themeStyle);
50 NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
51 NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
52 NSString* (*wkGetMIMETypeForExtension)(NSString*);
53 NSTimeInterval (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
54 NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
55 BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
56 void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
57 void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
58 unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
59 int (*wkQTMovieDataRate)(QTMovie*);
60 void (*wkQTMovieDisableComponent)(uint32_t[5]);
61 float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
62 NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
63 float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
64 int (*wkQTMovieGetType)(QTMovie*);
65 BOOL (*wkQTMovieHasClosedCaptions)(QTMovie*);
66 void (*wkQTMovieSetShowClosedCaptions)(QTMovie*, BOOL);
67 void (*wkQTMovieSelectPreferredAlternates)(QTMovie*);
68 void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
69 void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
70 void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
71 void (*wkSetDragImage)(NSImage*, NSPoint offset);
72 void (*wkSetPatternBaseCTM)(CGContextRef, CGAffineTransform);
73 void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint point);
74 CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
75 void (*wkSetUpFontCache)();
76 void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
77 void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
78 void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
79 CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *), 
80     void (*formFinalize)(CFReadStreamRef, void *), 
81     Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *), 
82     CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *), 
83     Boolean (*formCanRead)(CFReadStreamRef, void *), 
84     void (*formClose)(CFReadStreamRef, void *), 
85     void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *), 
86     void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
87     void *context);
88 void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
89 void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
90 id (*wkCreateNSURLConnectionDelegateProxy)(void);
91 unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
92 int (*wkGetHTTPPipeliningPriority)(NSURLRequest *);
93 void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
94 void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
95 void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
96 CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
97 BOOL (*wkIsLatchingWheelEvent)(NSEvent *);
98
99 #ifndef BUILDING_ON_TIGER
100 void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
101 #else
102 void (*wkClearGlyphVector)(void* glyphs);
103 OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
104 CFStringRef (*wkCopyFullFontName)(CGFontRef font);
105 OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
106 CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
107 void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm);
108 ATSLayoutRecord* (*wkGetGlyphVectorFirstRecord)(void* glyphVector);
109 void* wkGetGlyphsForCharacters;
110 int (*wkGetGlyphVectorNumGlyphs)(void* glyphVector);
111 size_t (*wkGetGlyphVectorRecordSize)(void* glyphVector);
112 OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
113 void (*wkReleaseStyleGroup)(void* group);
114 ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
115 BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
116 #endif
117
118 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
119 void* wkGetHyphenationLocationBeforeIndex;
120 #else
121 CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
122 #endif
123
124 CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
125 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
126 CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
127
128 CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
129 CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
130
131 WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
132 WKScrollbarPainterRef (*wkMakeScrollbarReplacementPainter)(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal);
133 void (*wkScrollbarPainterSetDelegate)(WKScrollbarPainterRef, id scrollbarPainterDelegate);
134 void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
135 int (*wkScrollbarThickness)(int controlSize);
136 int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
137 int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
138 CGFloat (*wkScrollbarPainterKnobAlpha)(WKScrollbarPainterRef);
139 void (*wkSetScrollbarPainterKnobAlpha)(WKScrollbarPainterRef, CGFloat);
140 CGFloat (*wkScrollbarPainterTrackAlpha)(WKScrollbarPainterRef);
141 void (*wkSetScrollbarPainterTrackAlpha)(WKScrollbarPainterRef, CGFloat);
142 bool (*wkScrollbarPainterIsHorizontal)(WKScrollbarPainterRef);
143 void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState);
144
145 WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate);
146 void (*wkSetPainterForPainterController)(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal);
147 WKScrollbarPainterRef (*wkVerticalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
148 WKScrollbarPainterRef (*wkHorizontalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
149 void (*wkSetScrollbarPainterControllerStyle)(WKScrollbarPainterControllerRef, int newStyle);
150 void (*wkContentAreaScrolled)(WKScrollbarPainterControllerRef);
151 void (*wkContentAreaWillPaint)(WKScrollbarPainterControllerRef);
152 void (*wkMouseEnteredContentArea)(WKScrollbarPainterControllerRef);
153 void (*wkMouseExitedContentArea)(WKScrollbarPainterControllerRef);
154 void (*wkMouseMovedInContentArea)(WKScrollbarPainterControllerRef);
155 void (*wkWillStartLiveResize)(WKScrollbarPainterControllerRef);
156 void (*wkContentAreaResized)(WKScrollbarPainterControllerRef);
157 void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef);
158 void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef);
159 void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef);
160
161 bool (*wkScrollbarPainterUsesOverlayScrollers)(void);
162 #endif
163
164 void (*wkUnregisterUniqueIdForElement)(id element);
165 void (*wkAccessibilityHandleFocusChanged)(void);
166 CFTypeID (*wkGetAXTextMarkerTypeID)(void);
167 CFTypeID (*wkGetAXTextMarkerRangeTypeID)(void);
168 CFTypeRef (*wkCreateAXTextMarkerRange)(CFTypeRef start, CFTypeRef end);
169 CFTypeRef (*wkCopyAXTextMarkerRangeStart)(CFTypeRef range);
170 CFTypeRef (*wkCopyAXTextMarkerRangeEnd)(CFTypeRef range);
171 CFTypeRef (*wkCreateAXTextMarker)(const void *bytes, size_t len);
172 BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length);
173 AXUIElementRef (*wkCreateAXUIElementRef)(id element);
174
175 CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
176 NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
177 CFHTTPCookieStorageRef (*wkCopyHTTPCookieStorage)(CFURLStorageSessionRef);
178 unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
179 NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
180 void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
181 void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
182
183 CFStringRef (*wkGetCFURLResponseMIMEType)(CFURLResponseRef);
184 CFURLRef (*wkGetCFURLResponseURL)(CFURLResponseRef);
185 CFHTTPMessageRef (*wkGetCFURLResponseHTTPResponse)(CFURLResponseRef);
186 CFStringRef (*wkCopyCFURLResponseSuggestedFilename)(CFURLResponseRef);
187 void (*wkSetCFURLResponseMIMEType)(CFURLResponseRef, CFStringRef mimeType);