1 /* Cydget - open-source AwayView plugin multiplexer
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
22 #include <CydiaSubstrate/CydiaSubstrate.h>
23 #include <UIKit/UIKit.h>
25 #include <sys/sysctl.h>
28 #include <SpringBoardUI/SBAwayViewPluginController.h>
30 #include <WebKit/WebFrame.h>
31 #include <WebKit/WebView.h>
32 #include <WebKit/WebPreferences-WebPrivate.h>
34 #include "yieldToSelector.h"
37 #include <unicode/uregex.h>
43 #define _forever for (;;)
45 _disused static unsigned trace_;
47 #define _trace() do { \
48 NSLog(@"_trace(%u)@%s:%u[%s](%p)\n", \
49 trace_++, __FILE__, __LINE__, __FUNCTION__, pthread_self() \
53 #define _assert(test) do \
55 NSLog(@"_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
60 #define _syscall(expr) \
61 do if ((long) (expr) != -1) \
63 else switch (errno) { \
70 extern "C" UIImage *_UIImageWithName(NSString *name);
72 typedef uint16_t UChar;
74 @interface TPBottomLockBar
75 - (CGFloat) defaultHeight;
78 @interface UIApplication (Apple)
79 - (void) applicationOpenURL:(NSURL *)url;
82 @interface UIScroller : UIView
83 - (CGSize) contentSize;
84 - (void) setDirectionalScrolling:(BOOL)directional;
85 - (void) setOffset:(CGPoint)offset;
86 - (void) setScrollDecelerationFactor:(CGFloat)factor;
87 - (void) setScrollHysteresis:(CGFloat)hysteresis;
88 - (void) setThumbDetectionEnabled:(BOOL)enabled;
91 @interface UIWebDocumentView : UIView
92 - (CGRect) documentBounds;
93 - (void) enableReachability;
94 - (void) loadRequest:(NSURLRequest *)request;
95 - (void) redrawScaledDocument;
96 - (void) setAllowsImageSheet:(BOOL)allows;
97 - (void) setAllowsMessaging:(BOOL)allows;
98 - (void) setAutoresizes:(BOOL)autoresizes;
99 - (void) setContentsPosition:(NSInteger)position;
100 - (void) setDrawsBackground:(BOOL)draws;
101 - (void) _setDocumentType:(NSInteger)type;
102 - (void) setDrawsGrid:(BOOL)draws;
103 - (void) setInitialScale:(float)scale forDocumentTypes:(NSInteger)types;
104 - (void) setLogsTilingChanges:(BOOL)logs;
105 - (void) setMinimumScale:(float)scale forDocumentTypes:(NSInteger)types;
106 - (void) setMinimumSize:(CGSize)size;
107 - (void) setMaximumScale:(float)scale forDocumentTypes:(NSInteger)tpyes;
108 - (void) setSmoothsFonts:(BOOL)smooths;
109 - (void) setTileMinificationFilter:(NSString *)filter;
110 - (void) setTileSize:(CGSize)size;
111 - (void) setTilingEnabled:(BOOL)enabled;
112 - (void) setViewportSize:(CGSize)size forDocumentTypes:(NSInteger)types;
113 - (void) setZoomsFocusedFormControl:(BOOL)zooms;
114 - (void) useSelectionAssistantWithMode:(NSInteger)mode;
115 - (WebView *) webView;
118 @interface UIView (Apple)
119 - (UIScroller *) _scroller;
120 - (void) setClipsSubviews:(BOOL)clips;
121 - (void) setEnabledGestures:(NSInteger)gestures;
122 - (void) setFixedBackgroundPattern:(BOOL)fixed;
123 - (void) setGestureDelegate:(id)delegate;
124 - (void) setNeedsDisplayOnBoundsChange:(BOOL)needs;
125 - (void) setValue:(NSValue *)value forGestureAttribute:(NSInteger)attribute;
126 - (void) setZoomScale:(float)scale duration:(double)duration;
127 - (void) _setZoomScale:(float)scale duration:(double)duration;
130 @protocol CydgetController
131 - (NSDictionary *) currentConfiguration;
132 - (NSString *) currentPath;
135 static Class $CydgetController(objc_getClass("CydgetController"));
137 static bool iOS32, iOS4;
139 @interface NSString (UIKit)
140 - (NSString *) stringByAddingPercentEscapes;
143 @implementation UIWebDocumentView (WebCycript)
145 - (void) _setScrollerOffset:(CGPoint)offset {
146 UIScroller *scroller([self _scroller]);
148 CGSize size([scroller contentSize]);
149 CGSize bounds([scroller bounds].size);
152 max.x = size.width - bounds.width;
153 max.y = size.height - bounds.height;
161 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
162 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
164 [scroller setOffset:offset];
170 /* ICU Regular Expression {{{ */
173 URegularExpression *regex_;
176 RegEx(const char *regex) {
178 UErrorCode status(U_ZERO_ERROR);
179 regex_ = uregex_openC(regex, 0, &error, &status);
180 if (U_FAILURE(status))
181 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", error.offset, u_errorName(status)] userInfo:nil];
185 uregex_close(regex_);
188 bool operator ()(NSString *string) {
189 return operator ()(reinterpret_cast<const uint16_t *>([string cStringUsingEncoding:NSUTF16StringEncoding]), [string length]);
192 bool operator ()(const UChar *data, size_t size) {
193 UErrorCode status(U_ZERO_ERROR);
194 uregex_setText(regex_, data, size, &status);
195 _assert(U_SUCCESS(status));
196 bool matches(uregex_matches(regex_, 0, &status));
197 _assert(U_SUCCESS(status));
203 /* Perl-Compatible RegEx {{{ */
213 RegEx(const char *regex) :
218 code_ = pcre_compile(regex, 0, &error, &offset, NULL);
221 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", offset, error] userInfo:nil];
223 pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
224 matches_ = new int[(capture_ + 1) * 3];
232 bool operator ()(NSString *data) {
233 // XXX: length is for characters, not for bytes
234 return operator ()([data UTF8String], [data length]);
237 bool operator ()(const char *data, size_t size) {
239 return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
245 static float CYScrollViewDecelerationRateNormal;
247 @interface NSURL (Apple)
248 - (BOOL) isSpringboardHandledURL;
251 @interface UIScrollView (Apple)
252 - (void) setDecelerationRate:(CGFloat)value;
253 - (void) setScrollingEnabled:(BOOL)enabled;
254 - (void) setShowBackgroundShadow:(BOOL)show;
257 @interface UIWebView (Apple)
258 - (UIWebDocumentView *) _documentView;
259 - (void) setDataDetectorTypes:(NSInteger)types;
260 - (void) _setDrawInWebThread:(BOOL)draw;
261 - (UIScrollView *) _scrollView;
262 - (UIScroller *) _scroller;
263 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
264 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
267 @interface WebView (Apple)
268 - (void) _setLayoutInterval:(float)interval;
269 - (void) _setAllowsMessaging:(BOOL)allows;
270 - (void) setShouldUpdateWhileOffscreen:(BOOL)update;
273 @protocol CydgetWebViewDelegate <UIWebViewDelegate>
274 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
277 @class UIWebViewWebViewDelegate;
279 @interface CydgetWebView : UIWebView {
284 MSClassHook(UIApplication)
286 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
287 [self applicationOpenURL:url];
290 @implementation NSURL (Cydget)
292 - (NSNumber *) cydget$isSpringboardHandledURL {
293 return [NSNumber numberWithBool:[self isSpringboardHandledURL]];
300 MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) {
301 if (![NSThread isMainThread])
304 return [[self cydget$yieldToSelector:@selector(cydget$isSpringboardHandledURL)] boolValue];
307 @implementation CydgetWebView
309 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
310 NSObject<CydgetWebViewDelegate> *delegate((NSObject<CydgetWebViewDelegate> *) [self delegate]);
311 if ([delegate respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
312 [delegate webView:view didClearWindowObject:window forFrame:frame];
313 if ([UIWebView instancesRespondToSelector:@selector(webView:didClearWindowObject:forFrame:)])
314 [super webView:view didClearWindowObject:window forFrame:frame];
317 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message {
318 NSLog(@"addMessageToConsole:%@", message);
320 if ([UIWebView instancesRespondToSelector:@selector(webView:addMessageToConsole:)])
321 [super webView:view addMessageToConsole:message];
326 @interface WebCydgetLockScreenView : UIView <UIWebViewDelegate> {
327 CydgetWebView *webview_;
328 UIScrollView *scroller_;
334 @implementation WebCydgetLockScreenView
336 //#include "UICaboodle/UCInternal.h"
339 [webview_ setDelegate:nil];
344 - (void) loadRequest:(NSURLRequest *)request {
345 [webview_ loadRequest:request];
348 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
349 [self loadRequest:[NSURLRequest
356 - (void) loadURL:(NSURL *)url {
357 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
360 - (id) initWithURL:(NSURL *)url {
361 CGRect frame = [[UIScreen mainScreen] bounds];
362 if (kCFCoreFoundationVersionNumber < 800)
363 frame.size.height -= 20; //[[[$SBStatusBarController sharedStatusBarController] statusBarView] frame].size.height;
365 if ((self = [super initWithFrame:frame]) != nil) {
366 CGRect bounds([self bounds]);
367 if (kCFCoreFoundationVersionNumber < 800)
368 bounds.size.height -= [TPBottomLockBar defaultHeight];
370 webview_ = [[CydgetWebView alloc] initWithFrame:bounds];
371 [webview_ setDelegate:self];
372 [self addSubview:webview_];
374 if ([webview_ respondsToSelector:@selector(setDataDetectorTypes:)])
375 [webview_ setDataDetectorTypes:0x80000000];
377 [webview_ setDetectsPhoneNumbers:NO];
379 [webview_ setScalesPageToFit:YES];
381 if (kCFCoreFoundationVersionNumber < 478.61)
382 if ([webview_ respondsToSelector:@selector(_setDrawInWebThread:)])
383 [webview_ _setDrawInWebThread:NO];
385 UIWebDocumentView *document([webview_ _documentView]);
386 WebView *webview([document webView]);
387 WebPreferences *preferences([webview preferences]);
389 [document setTileSize:CGSizeMake(bounds.size.width, 500)];
391 [document setBackgroundColor:[UIColor clearColor]];
392 [document setDrawsBackground:NO];
394 [webview setPreferencesIdentifier:@"WebCycript"];
396 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
397 [webview _setLayoutInterval:0];
399 [preferences _setLayoutInterval:0];
401 [preferences setCacheModel:WebCacheModelDocumentViewer];
402 [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
403 [preferences setOfflineWebApplicationCacheEnabled:YES];
405 if ([webview respondsToSelector:@selector(setShouldUpdateWhileOffscreen:)])
406 [webview setShouldUpdateWhileOffscreen:NO];
408 if ([document respondsToSelector:@selector(setAllowsMessaging:)])
409 [document setAllowsMessaging:YES];
410 if ([webview respondsToSelector:@selector(_setAllowsMessaging:)])
411 [webview _setAllowsMessaging:YES];
413 if ([webview_ respondsToSelector:@selector(_scrollView)]) {
414 scroller_ = [webview_ _scrollView];
416 [scroller_ setDirectionalLockEnabled:YES];
417 [scroller_ setDecelerationRate:CYScrollViewDecelerationRateNormal];
418 [scroller_ setDelaysContentTouches:NO];
420 [scroller_ setCanCancelContentTouches:YES];
422 [scroller_ setAlwaysBounceVertical:NO];
423 } else if ([webview_ respondsToSelector:@selector(_scroller)]) {
424 UIScroller *scroller([webview_ _scroller]);
425 scroller_ = (UIScrollView *) scroller;
427 [scroller setDirectionalScrolling:YES];
428 [scroller setScrollDecelerationFactor:CYScrollViewDecelerationRateNormal]; /* 0.989324 */
429 [scroller setScrollHysteresis:0]; /* 8 */
431 [scroller setThumbDetectionEnabled:NO];
434 [webview_ setOpaque:NO];
435 [webview_ setBackgroundColor:[UIColor clearColor]];
437 [scroller_ setFixedBackgroundPattern:YES];
438 [scroller_ setBackgroundColor:[UIColor clearColor]];
439 [scroller_ setClipsSubviews:NO];
441 [scroller_ setBounces:YES];
442 [scroller_ setShowBackgroundShadow:NO]; /* YES */
444 [self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
445 [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
447 NSDictionary *configuration([$CydgetController currentConfiguration]);
448 cycript_ = [configuration objectForKey:@"CycriptURLs"];
450 [scroller_ setScrollingEnabled:[[configuration objectForKey:@"Scrollable"] boolValue]];
456 - (void) webView:(WebView *)webview didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
458 if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
459 if (RegEx([cycript_ UTF8String])(href))
460 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
461 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
462 WebFrame *frame([webview mainFrame]);
463 JSGlobalContextRef context([frame globalContext]);
465 CYSetupContext(context);
466 } @catch (NSException *e) {
467 NSLog(@"*** CydgetSetupContext => %@", e);
474 @interface WebCycriptLockScreenController : SBAwayViewPluginController {
475 NSDictionary *configuration_;
476 WebCydgetLockScreenView *background_;
506 union ScriptSourceCode {
508 JSC::SourceCode source_;
512 JSC::SourceCode source_;
516 // String Helpers {{{
517 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
518 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
519 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
521 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
524 if (_ZNK7WebCore6String10charactersEv != NULL) {
525 data = (*_ZNK7WebCore6String10charactersEv)(&string);
527 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
528 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
535 if (_ZNK7WebCore6String6lengthEv != NULL)
536 length = (*_ZNK7WebCore6String6lengthEv)(&string);
538 for (length = 0; data[length] != 0; ++length);
544 static bool StringEquals(const WebCore::String &string, const char *value) {
547 if (!StringGet(string, data, size))
550 size_t length(strlen(value));
554 for (size_t index(0); index != length; ++index)
555 if (data[index] != value[index])
562 static bool cycript_;
564 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
565 if (!StringEquals(mime, "text/cycript")) {
567 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
570 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
578 // Script Compiler {{{
579 static void Log(const WebCore::String &string) {
583 if (!StringGet(string, data, length))
586 UChar terminated[length + 1];
587 terminated[length] = 0;
588 memcpy(terminated, data, length * 2);
589 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
593 static bool Cycriptify(const uint16_t *&data, size_t &size) {
596 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
597 if (void (*CydgetMemoryParse)(const uint16_t **, size_t *) = reinterpret_cast<void (*)(const uint16_t **, size_t *)>(dlsym(handle, "CydgetMemoryParse"))) @try {
598 CydgetMemoryParse(&data, &size);
600 } @catch (NSException *e) {
601 NSLog(@"*** CydgetMemoryParse => %@", e);
606 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
607 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
609 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
616 if (!StringGet(source, data, length))
620 if (!Cycriptify(data, size))
623 WebCore::String &script(const_cast<WebCore::String &>(source));
624 _ZN7WebCore6String8truncateEj(&script, 0);
625 _ZN7WebCore6String6appendEPKtj(&script, data, size);
636 static WebCore::String *string;
639 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
641 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
645 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
647 JSC::SourceCode *source(_this[iOS32 ? 6 : 0]);
648 const uint16_t *data(source->data());
649 size_t size(source->length());
651 if (Cycriptify(data, size)) {
652 source->~SourceCode();
653 // XXX: I actually don't have the original URL here: pants
654 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
659 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
663 MSHook(const WebCore::String &, _ZNK7WebCore4Node11textContentEb, void *_this, bool convert) {
664 const WebCore::String &code(__ZNK7WebCore4Node11textContentEb(_this, convert));
665 string = const_cast<WebCore::String *>(&code);
672 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
674 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
678 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
679 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
680 string = const_cast<WebCore::String *>(&script);
686 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, JSC::ScriptSourceCode &script, State state) {
687 if (string != NULL) {
688 JSC::SourceCode *source(iOS4 ? &script.New.source_ : &script.Old.source_);
689 Cycriptify(*string, &source->end_);
693 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, script, state);
697 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
699 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
703 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
705 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
708 void (*$_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
711 MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, JSC::ScriptSourceCode &script) {
712 if (string != NULL) {
713 JSC::SourceCode *source(&script.New.source_);
714 $_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
715 Cycriptify(*string, &source->end_);
719 return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, script);
723 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
725 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE(_this, source, url, position);
729 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
731 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE(_this, position, legacy);
734 /* Cydget:// Protocol {{{ */
735 @interface CydgetURLProtocol : NSURLProtocol {
740 @implementation CydgetURLProtocol
742 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
743 NSURL *url([request URL]);
746 NSString *scheme([[url scheme] lowercaseString]);
747 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
752 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
756 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
757 id<NSURLProtocolClient> client([self client]);
759 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
761 NSData *data(UIImagePNGRepresentation(icon));
763 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
764 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
765 [client URLProtocol:self didLoadData:data];
766 [client URLProtocolDidFinishLoading:self];
770 - (void) startLoading {
771 id<NSURLProtocolClient> client([self client]);
772 NSURLRequest *request([self request]);
774 NSURL *url([request URL]);
775 NSString *href([url absoluteString]);
777 NSString *path([href substringFromIndex:9]);
778 NSRange slash([path rangeOfString:@"/"]);
781 if (slash.location == NSNotFound) {
785 command = [path substringToIndex:slash.location];
786 path = [path substringFromIndex:(slash.location + 1)];
789 if ([command isEqualToString:@"_UIImageWithName"]) {
792 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
793 UIImage *icon(_UIImageWithName(path));
794 [self _returnPNGWithImage:icon forRequest:request];
796 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
800 - (void) stopLoading {
805 /* Cydget-CGI:// Protocol {{{ */
806 @interface CydgetCGIURLProtocol : NSURLProtocol {
808 CFHTTPMessageRef http_;
809 NSFileHandle *handle_;
814 @implementation CydgetCGIURLProtocol
816 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
817 NSURL *url([request URL]);
820 NSString *scheme([[url scheme] lowercaseString]);
821 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
826 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
830 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
831 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
836 - (void) startLoading {
837 id<NSURLProtocolClient> client([self client]);
838 NSURLRequest *request([self request]);
839 NSURL *url([request URL]);
841 NSString *path([url path]);
843 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
847 NSFileManager *manager([NSFileManager defaultManager]);
848 if (![manager fileExistsAtPath:path]) {
849 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
854 _assert(pipe(fds) != -1);
859 _assert(close(fds[0]) != -1);
860 _assert(close(fds[1]) != -1);
861 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
866 const char *script([path UTF8String]);
868 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
869 setenv("SCRIPT_FILENAME", script, true);
870 NSString *query([url query]);
872 setenv("QUERY_STRING", [query UTF8String], true);
874 _assert(dup2(fds[1], 1) != -1);
875 _assert(close(fds[0]) != -1);
876 _assert(close(fds[1]) != -1);
878 execl(script, script, NULL);
883 _assert(close(fds[1]) != -1);
885 _assert(http_ == NULL);
886 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
887 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
889 _assert(handle_ == nil);
890 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
892 [[NSNotificationCenter defaultCenter]
894 selector:@selector(onRead:)
895 name:@"NSFileHandleReadCompletionNotification"
899 [handle_ readInBackgroundAndNotify];
902 - (void) onRead:(NSNotification *)notification {
903 NSFileHandle *handle([notification object]);
905 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
907 if (size_t length = [data length]) {
908 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
909 [handle readInBackgroundAndNotify];
911 id<NSURLProtocolClient> client([self client]);
913 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
915 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
917 NSURLRequest *request([self request]);
919 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
922 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
924 CFDataRef body(CFHTTPMessageCopyBody(http_));
925 [client URLProtocol:self didLoadData:(NSData *)body];
928 [client URLProtocolDidFinishLoading:self];
936 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
938 - (void) stopLoading_ {
939 [[NSNotificationCenter defaultCenter] removeObserver:self];
941 if (handle_ != nil) {
949 _syscall(waitpid(pid_, &status, 0));
954 - (void) stopLoading {
956 performSelectorOnMainThread:@selector(stopLoading_)
965 template <typename Type_>
966 static void dlset(Type_ &function, const char *name) {
967 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
970 template <typename Type_>
971 static void msset_(Type_ &function, const char *name, MSImageRef handle) {
972 function = reinterpret_cast<Type_>(MSFindSymbol(handle, name));
975 #define msset(function, handle) \
976 msset_(function, "_" #function, handle)
978 @implementation WebCycriptLockScreenController
980 static void $UIWebViewWebViewDelegate$webView$addMessageToConsole$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSDictionary *message) {
981 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
982 if ([uiWebView respondsToSelector:@selector(webView:addMessageToConsole:)])
983 [uiWebView webView:view addMessageToConsole:message];
986 static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, WebScriptObject *window, WebFrame *frame) {
987 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
988 if ([uiWebView respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
989 [uiWebView webView:view didClearWindowObject:window forFrame:frame];
992 + (void) initialize {
993 if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) {
994 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:addMessageToConsole:), (IMP) &$UIWebViewWebViewDelegate$webView$addMessageToConsole$, "v16@0:4@8@12");
995 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didClearWindowObject:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$, "v20@0:4@8@12@16");
998 if (CGFloat *_UIScrollViewDecelerationRateNormal = reinterpret_cast<CGFloat *>(dlsym(RTLD_DEFAULT, "UIScrollViewDecelerationRateNormal")))
999 CYScrollViewDecelerationRateNormal = *_UIScrollViewDecelerationRateNormal;
1000 else // XXX: this actually might be fast on some older systems: we should look into this
1001 CYScrollViewDecelerationRateNormal = 0.998;
1003 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
1004 iOS32 = !iOS4 && kCFCoreFoundationVersionNumber >= 478.61;
1007 size_t size(sizeof(maxproc));
1008 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
1009 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
1010 else if (maxproc < 72) {
1012 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
1013 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
1016 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
1017 [WebView registerURLSchemeAsLocal:@"cydget"];
1019 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
1020 [WebView registerURLSchemeAsLocal:@"cydget-cgi"];
1022 MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"));
1023 MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
1026 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
1027 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
1028 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
1029 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
1032 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &) = NULL;
1033 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1034 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE", WebCore);
1035 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1036 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKN3WTF6StringE", WebCore);
1037 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
1038 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
1040 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int) = NULL;
1041 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi == NULL)
1042 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi", WebCore);
1043 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
1044 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
1047 const WebCore::String &(*_ZNK7WebCore4Node11textContentEb)(void *, bool) = NULL;
1048 if (_ZNK7WebCore4Node11textContentEb == NULL)
1049 MSHookSymbol(_ZNK7WebCore4Node11textContentEb, "__ZNK7WebCore4Node11textContentEb", WebCore);
1050 if (_ZNK7WebCore4Node11textContentEb != NULL)
1051 MSHookFunction(_ZNK7WebCore4Node11textContentEb, MSHake(_ZNK7WebCore4Node11textContentEb));
1054 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *) = NULL;
1055 if (_ZN7WebCore12CachedScript6scriptEv == NULL)
1056 MSHookSymbol(_ZN7WebCore12CachedScript6scriptEv, "__ZN7WebCore12CachedScript6scriptEv", WebCore);
1057 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
1058 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
1060 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int) = NULL;
1061 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i == NULL)
1062 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i", WebCore);
1063 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
1064 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
1066 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, JSC::ScriptSourceCode &, State) = NULL;
1067 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE == NULL)
1068 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE", WebCore);
1069 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
1070 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
1072 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1073 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, WebCore);
1074 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
1075 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
1077 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1078 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, WebCore);
1079 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE != NULL)
1080 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE));
1082 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
1083 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
1084 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
1085 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
1087 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE)(void *, void *, int);
1088 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, WebCore);
1089 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE != NULL)
1090 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE));
1092 MSHookSymbol($_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, "__ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE", WebCore);
1094 void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, JSC::ScriptSourceCode &);
1095 msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
1096 if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
1097 MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
1099 if (_ZN7WebCore6String6appendEPKtj == NULL)
1100 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN7WebCore6String6appendEPKtj", WebCore);
1101 if (_ZN7WebCore6String6appendEPKtj == NULL)
1102 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
1103 if (_ZN7WebCore6String6appendEPKtj == NULL)
1104 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN3WTF6String6appendEPKtj", JavaScriptCore);
1106 if (_ZN7WebCore6String8truncateEj == NULL)
1107 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN7WebCore6String8truncateEj", WebCore);
1108 if (_ZN7WebCore6String8truncateEj == NULL)
1109 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
1110 if (_ZN7WebCore6String8truncateEj == NULL)
1111 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN3WTF6String8truncateEj", JavaScriptCore);
1113 msset(_ZNK7WebCore6String10charactersEv, WebCore);
1115 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
1116 if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL)
1117 MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore);
1119 msset(_ZNK7WebCore6String6lengthEv, WebCore);
1122 + (id) rootViewController {
1123 return [[[self alloc] init] autorelease];
1127 [configuration_ release];
1128 [background_ release];
1133 if ((self = [super init]) != nil) {
1134 configuration_ = [[$CydgetController currentConfiguration] retain];
1139 NSURL *base([NSURL fileURLWithPath:[$CydgetController currentPath]]);
1141 if (NSString *background = [configuration_ objectForKey:@"Background"])
1142 background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background relativeToURL:base]];
1144 if (NSString *homepage = [configuration_ objectForKey:@"Homepage"])
1145 [self setView:[[[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]] autorelease]];
1146 else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) {
1147 [self setView:[background_ autorelease]];
1152 - (void) purgeView {
1153 [background_ removeFromSuperview];
1154 [background_ release];
1159 - (UIView *) backgroundView {
1163 - (BOOL) showAwayItems {
1167 - (BOOL) showDateView {
1168 return [configuration_ objectForKey:@"Homepage"] == nil;
1171 /*- (BOOL) showHeaderView {
1175 - (NSUInteger) presentationStyle {
1179 - (NSUInteger) overlayStyle {
1180 if ([configuration_ objectForKey:@"Background"] == nil)
1185 - (BOOL) viewWantsFullscreenLayout {
1186 return kCFCoreFoundationVersionNumber >= 800;
1189 /*- (BOOL) viewWantsOverlayLayout {
1190 return kCFCoreFoundationVersionNumber >= 800;
1193 - (BOOL) shouldDisableOnUnlock {
1197 - (BOOL) canBeAlwaysFullscreen {
1201 /*- (BOOL) wantsSwipeGestureRecognizer {
1205 - (BOOL) handleGesture:(int)arg1 fingerCount:(NSUInteger)fingers {
1212 MSClassHook(WebView)
1213 MSMetaClassHook(WebView)
1215 MSClassMessageHook0(void, WebView, enableWebThread) {
1216 if (kCFCoreFoundationVersionNumber >= 478.61)
1219 NSLog(@"-[WebView enableWebThread]");