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 @interface SBLockScreenView : UIView
131 - (BOOL) mediaControlsHidden;
134 @interface SBLockScreenViewController : UIViewController
135 - (SBLockScreenView *) lockScreenView;
136 - (BOOL) isShowingMediaControls;
137 - (void) _setMediaControlsVisible:(BOOL)visible;
140 @interface SBLockScreenManager : NSObject
141 + (SBLockScreenManager *) sharedInstance;
142 - (SBLockScreenViewController *) lockScreenViewController;
145 @protocol CydgetController
146 - (NSDictionary *) currentConfiguration;
147 - (NSString *) currentPath;
150 static Class $CydgetController(objc_getClass("CydgetController"));
152 static bool iOS32, iOS4;
154 @interface NSString (UIKit)
155 - (NSString *) stringByAddingPercentEscapes;
158 @implementation UIWebDocumentView (WebCycript)
160 - (void) _setScrollerOffset:(CGPoint)offset {
161 UIScroller *scroller([self _scroller]);
163 CGSize size([scroller contentSize]);
164 CGSize bounds([scroller bounds].size);
167 max.x = size.width - bounds.width;
168 max.y = size.height - bounds.height;
176 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
177 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
179 [scroller setOffset:offset];
185 /* ICU Regular Expression {{{ */
188 URegularExpression *regex_;
191 RegEx(const char *regex) {
193 UErrorCode status(U_ZERO_ERROR);
194 regex_ = uregex_openC(regex, 0, &error, &status);
195 if (U_FAILURE(status))
196 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", error.offset, u_errorName(status)] userInfo:nil];
200 uregex_close(regex_);
203 bool operator ()(NSString *string) {
204 return operator ()(reinterpret_cast<const uint16_t *>([string cStringUsingEncoding:NSUTF16StringEncoding]), [string length]);
207 bool operator ()(const UChar *data, size_t size) {
208 UErrorCode status(U_ZERO_ERROR);
209 uregex_setText(regex_, data, size, &status);
210 _assert(U_SUCCESS(status));
211 bool matches(uregex_matches(regex_, 0, &status));
212 _assert(U_SUCCESS(status));
218 /* Perl-Compatible RegEx {{{ */
228 RegEx(const char *regex) :
233 code_ = pcre_compile(regex, 0, &error, &offset, NULL);
236 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", offset, error] userInfo:nil];
238 pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
239 matches_ = new int[(capture_ + 1) * 3];
247 bool operator ()(NSString *data) {
248 // XXX: length is for characters, not for bytes
249 return operator ()([data UTF8String], [data length]);
252 bool operator ()(const char *data, size_t size) {
254 return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
260 static float CYScrollViewDecelerationRateNormal;
262 @interface NSURL (Apple)
263 - (BOOL) isSpringboardHandledURL;
266 @interface UIScrollView (Apple)
267 - (void) setDecelerationRate:(CGFloat)value;
268 - (void) setScrollingEnabled:(BOOL)enabled;
269 - (void) setShowBackgroundShadow:(BOOL)show;
272 @interface UIWebView (Apple)
273 - (UIWebDocumentView *) _documentView;
274 - (void) setDataDetectorTypes:(NSInteger)types;
275 - (void) _setDrawInWebThread:(BOOL)draw;
276 - (UIScrollView *) _scrollView;
277 - (UIScroller *) _scroller;
278 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
279 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
282 @interface WebView (Apple)
283 - (void) _setLayoutInterval:(float)interval;
284 - (void) _setAllowsMessaging:(BOOL)allows;
285 - (void) setShouldUpdateWhileOffscreen:(BOOL)update;
288 @protocol CydgetWebViewDelegate <UIWebViewDelegate>
289 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
292 @class UIWebViewWebViewDelegate;
294 @interface CydgetWebView : UIWebView {
299 MSClassHook(UIApplication)
300 MSClassHook(SBLockScreenManager)
302 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
303 [self applicationOpenURL:url];
306 @implementation NSURL (Cydget)
308 - (NSNumber *) cydget$isSpringboardHandledURL {
309 return [NSNumber numberWithBool:[self isSpringboardHandledURL]];
316 MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) {
317 if (![NSThread isMainThread])
320 return [[self cydget$yieldToSelector:@selector(cydget$isSpringboardHandledURL)] boolValue];
323 @implementation CydgetWebView
325 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
326 NSObject<CydgetWebViewDelegate> *delegate((NSObject<CydgetWebViewDelegate> *) [self delegate]);
327 if ([delegate respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
328 [delegate webView:view didClearWindowObject:window forFrame:frame];
329 if ([UIWebView instancesRespondToSelector:@selector(webView:didClearWindowObject:forFrame:)])
330 [super webView:view didClearWindowObject:window forFrame:frame];
333 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message {
334 NSLog(@"addMessageToConsole:%@", message);
336 if ([UIWebView instancesRespondToSelector:@selector(webView:addMessageToConsole:)])
337 [super webView:view addMessageToConsole:message];
342 @interface WebCydgetLockScreenView : UIView <UIWebViewDelegate> {
343 CydgetWebView *webview_;
344 UIScrollView *scroller_;
350 @implementation WebCydgetLockScreenView
352 //#include "UICaboodle/UCInternal.h"
355 [webview_ setDelegate:nil];
360 - (void) loadRequest:(NSURLRequest *)request {
361 [webview_ loadRequest:request];
364 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
365 [self loadRequest:[NSURLRequest
372 - (void) loadURL:(NSURL *)url {
373 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
376 - (id) initWithURL:(NSURL *)url {
377 CGRect frame = [[UIScreen mainScreen] bounds];
378 if (kCFCoreFoundationVersionNumber < 800)
379 frame.size.height -= 20; //[[[$SBStatusBarController sharedStatusBarController] statusBarView] frame].size.height;
381 if ((self = [super initWithFrame:frame]) != nil) {
382 CGRect bounds([self bounds]);
383 if (kCFCoreFoundationVersionNumber < 800)
384 bounds.size.height -= [TPBottomLockBar defaultHeight];
386 webview_ = [[CydgetWebView alloc] initWithFrame:bounds];
387 [webview_ setDelegate:self];
388 [self addSubview:webview_];
390 if ([webview_ respondsToSelector:@selector(setDataDetectorTypes:)])
391 [webview_ setDataDetectorTypes:0x80000000];
393 [webview_ setDetectsPhoneNumbers:NO];
395 [webview_ setScalesPageToFit:YES];
397 if (kCFCoreFoundationVersionNumber < 478.61)
398 if ([webview_ respondsToSelector:@selector(_setDrawInWebThread:)])
399 [webview_ _setDrawInWebThread:NO];
401 UIWebDocumentView *document([webview_ _documentView]);
402 WebView *webview([document webView]);
403 WebPreferences *preferences([webview preferences]);
405 [document setTileSize:CGSizeMake(bounds.size.width, 500)];
407 [document setBackgroundColor:[UIColor clearColor]];
408 [document setDrawsBackground:NO];
410 [webview setPreferencesIdentifier:@"WebCycript"];
412 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
413 [webview _setLayoutInterval:0];
415 [preferences _setLayoutInterval:0];
417 [preferences setCacheModel:WebCacheModelDocumentViewer];
418 [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
419 [preferences setOfflineWebApplicationCacheEnabled:YES];
421 if ([webview respondsToSelector:@selector(setShouldUpdateWhileOffscreen:)])
422 [webview setShouldUpdateWhileOffscreen:NO];
424 if ([document respondsToSelector:@selector(setAllowsMessaging:)])
425 [document setAllowsMessaging:YES];
426 if ([webview respondsToSelector:@selector(_setAllowsMessaging:)])
427 [webview _setAllowsMessaging:YES];
429 if ([webview_ respondsToSelector:@selector(_scrollView)]) {
430 scroller_ = [webview_ _scrollView];
432 [scroller_ setDirectionalLockEnabled:YES];
433 [scroller_ setDecelerationRate:CYScrollViewDecelerationRateNormal];
434 [scroller_ setDelaysContentTouches:NO];
436 [scroller_ setCanCancelContentTouches:YES];
438 [scroller_ setAlwaysBounceVertical:NO];
439 } else if ([webview_ respondsToSelector:@selector(_scroller)]) {
440 UIScroller *scroller([webview_ _scroller]);
441 scroller_ = (UIScrollView *) scroller;
443 [scroller setDirectionalScrolling:YES];
444 [scroller setScrollDecelerationFactor:CYScrollViewDecelerationRateNormal]; /* 0.989324 */
445 [scroller setScrollHysteresis:0]; /* 8 */
447 [scroller setThumbDetectionEnabled:NO];
450 [webview_ setOpaque:NO];
451 [webview_ setBackgroundColor:[UIColor clearColor]];
453 [scroller_ setFixedBackgroundPattern:YES];
454 [scroller_ setBackgroundColor:[UIColor clearColor]];
455 [scroller_ setClipsSubviews:NO];
457 [scroller_ setBounces:YES];
458 [scroller_ setShowBackgroundShadow:NO]; /* YES */
460 [self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
461 [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
463 NSDictionary *configuration([$CydgetController currentConfiguration]);
464 cycript_ = [configuration objectForKey:@"CycriptURLs"];
466 [scroller_ setScrollingEnabled:[[configuration objectForKey:@"Scrollable"] boolValue]];
472 - (void) webView:(WebView *)webview didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
474 if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
475 if (RegEx([cycript_ UTF8String])(href))
476 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
477 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
478 WebFrame *frame([webview mainFrame]);
479 JSGlobalContextRef context([frame globalContext]);
481 CYSetupContext(context);
482 } @catch (NSException *e) {
483 NSLog(@"*** CydgetSetupContext => %@", e);
490 @interface WebCycriptLockScreenController : SBAwayViewPluginController {
491 NSDictionary *configuration_;
492 WebCydgetLockScreenView *background_;
493 WebCydgetLockScreenView *foreground_;
523 union ScriptSourceCode {
525 JSC::SourceCode source_;
529 JSC::SourceCode source_;
533 // String Helpers {{{
534 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
535 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
536 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
538 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
541 if (_ZNK7WebCore6String10charactersEv != NULL) {
542 data = (*_ZNK7WebCore6String10charactersEv)(&string);
544 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
545 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
552 if (_ZNK7WebCore6String6lengthEv != NULL)
553 length = (*_ZNK7WebCore6String6lengthEv)(&string);
555 for (length = 0; data[length] != 0; ++length);
561 static bool StringEquals(const WebCore::String &string, const char *value) {
564 if (!StringGet(string, data, size))
567 size_t length(strlen(value));
571 for (size_t index(0); index != length; ++index)
572 if (data[index] != value[index])
579 static bool cycript_;
581 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
582 if (!StringEquals(mime, "text/cycript")) {
584 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
587 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
595 // Script Compiler {{{
596 static void Log(const WebCore::String &string) {
600 if (!StringGet(string, data, length))
603 UChar terminated[length + 1];
604 terminated[length] = 0;
605 memcpy(terminated, data, length * 2);
606 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
610 static bool Cycriptify(const uint16_t *&data, size_t &size) {
613 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
614 if (void (*CydgetMemoryParse)(const uint16_t **, size_t *) = reinterpret_cast<void (*)(const uint16_t **, size_t *)>(dlsym(handle, "CydgetMemoryParse"))) @try {
615 CydgetMemoryParse(&data, &size);
617 } @catch (NSException *e) {
618 NSLog(@"*** CydgetMemoryParse => %@", e);
623 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
624 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
626 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
633 if (!StringGet(source, data, length))
637 if (!Cycriptify(data, size))
640 WebCore::String &script(const_cast<WebCore::String &>(source));
641 _ZN7WebCore6String8truncateEj(&script, 0);
642 _ZN7WebCore6String6appendEPKtj(&script, data, size);
653 static WebCore::String *string;
656 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
658 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
662 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
664 JSC::SourceCode *source(_this[iOS32 ? 6 : 0]);
665 const uint16_t *data(source->data());
666 size_t size(source->length());
668 if (Cycriptify(data, size)) {
669 source->~SourceCode();
670 // XXX: I actually don't have the original URL here: pants
671 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
676 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
680 MSHook(const WebCore::String &, _ZNK7WebCore4Node11textContentEb, void *_this, bool convert) {
681 const WebCore::String &code(__ZNK7WebCore4Node11textContentEb(_this, convert));
682 string = const_cast<WebCore::String *>(&code);
689 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
691 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
695 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
696 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
697 string = const_cast<WebCore::String *>(&script);
703 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, JSC::ScriptSourceCode &script, State state) {
704 if (string != NULL) {
705 JSC::SourceCode *source(iOS4 ? &script.New.source_ : &script.Old.source_);
706 Cycriptify(*string, &source->end_);
710 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, script, state);
714 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
716 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
720 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
722 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
725 void (*$_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
728 MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, JSC::ScriptSourceCode &script) {
729 if (string != NULL) {
730 JSC::SourceCode *source(&script.New.source_);
731 $_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
732 Cycriptify(*string, &source->end_);
736 return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, script);
740 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
742 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE(_this, source, url, position);
746 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
748 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE(_this, position, legacy);
751 /* Cydget:// Protocol {{{ */
752 @interface CydgetURLProtocol : NSURLProtocol {
757 @implementation CydgetURLProtocol
759 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
760 NSURL *url([request URL]);
763 NSString *scheme([[url scheme] lowercaseString]);
764 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
769 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
773 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
774 id<NSURLProtocolClient> client([self client]);
776 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
778 NSData *data(UIImagePNGRepresentation(icon));
780 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
781 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
782 [client URLProtocol:self didLoadData:data];
783 [client URLProtocolDidFinishLoading:self];
787 - (void) startLoading {
788 id<NSURLProtocolClient> client([self client]);
789 NSURLRequest *request([self request]);
791 NSURL *url([request URL]);
792 NSString *href([url absoluteString]);
794 NSString *path([href substringFromIndex:9]);
795 NSRange slash([path rangeOfString:@"/"]);
798 if (slash.location == NSNotFound) {
802 command = [path substringToIndex:slash.location];
803 path = [path substringFromIndex:(slash.location + 1)];
806 if ([command isEqualToString:@"_UIImageWithName"]) {
809 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
810 UIImage *icon(_UIImageWithName(path));
811 [self _returnPNGWithImage:icon forRequest:request];
813 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
817 - (void) stopLoading {
822 /* Cydget-CGI:// Protocol {{{ */
823 @interface CydgetCGIURLProtocol : NSURLProtocol {
825 CFHTTPMessageRef http_;
826 NSFileHandle *handle_;
831 @implementation CydgetCGIURLProtocol
833 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
834 NSURL *url([request URL]);
837 NSString *scheme([[url scheme] lowercaseString]);
838 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
843 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
847 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
848 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
853 - (void) startLoading {
854 id<NSURLProtocolClient> client([self client]);
855 NSURLRequest *request([self request]);
856 NSURL *url([request URL]);
858 NSString *path([url path]);
860 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
864 NSFileManager *manager([NSFileManager defaultManager]);
865 if (![manager fileExistsAtPath:path]) {
866 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
871 _assert(pipe(fds) != -1);
876 _assert(close(fds[0]) != -1);
877 _assert(close(fds[1]) != -1);
878 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
883 const char *script([path UTF8String]);
885 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
886 setenv("SCRIPT_FILENAME", script, true);
887 NSString *query([url query]);
889 setenv("QUERY_STRING", [query UTF8String], true);
891 _assert(dup2(fds[1], 1) != -1);
892 _assert(close(fds[0]) != -1);
893 _assert(close(fds[1]) != -1);
895 execl(script, script, NULL);
900 _assert(close(fds[1]) != -1);
902 _assert(http_ == NULL);
903 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
904 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
906 _assert(handle_ == nil);
907 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
909 [[NSNotificationCenter defaultCenter]
911 selector:@selector(onRead:)
912 name:@"NSFileHandleReadCompletionNotification"
916 [handle_ readInBackgroundAndNotify];
919 - (void) onRead:(NSNotification *)notification {
920 NSFileHandle *handle([notification object]);
922 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
924 if (size_t length = [data length]) {
925 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
926 [handle readInBackgroundAndNotify];
928 id<NSURLProtocolClient> client([self client]);
930 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
932 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
934 NSURLRequest *request([self request]);
936 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
939 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
941 CFDataRef body(CFHTTPMessageCopyBody(http_));
942 [client URLProtocol:self didLoadData:(NSData *)body];
945 [client URLProtocolDidFinishLoading:self];
953 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
955 - (void) stopLoading_ {
956 [[NSNotificationCenter defaultCenter] removeObserver:self];
958 if (handle_ != nil) {
966 _syscall(waitpid(pid_, &status, 0));
971 - (void) stopLoading {
973 performSelectorOnMainThread:@selector(stopLoading_)
982 template <typename Type_>
983 static void dlset(Type_ &function, const char *name) {
984 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
987 template <typename Type_>
988 static void msset_(Type_ &function, const char *name, MSImageRef handle) {
989 function = reinterpret_cast<Type_>(MSFindSymbol(handle, name));
992 #define msset(function, handle) \
993 msset_(function, "_" #function, handle)
995 @implementation WebCycriptLockScreenController
997 static void $UIWebViewWebViewDelegate$webView$addMessageToConsole$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSDictionary *message) {
998 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
999 if ([uiWebView respondsToSelector:@selector(webView:addMessageToConsole:)])
1000 [uiWebView webView:view addMessageToConsole:message];
1003 static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, WebScriptObject *window, WebFrame *frame) {
1004 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
1005 if ([uiWebView respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
1006 [uiWebView webView:view didClearWindowObject:window forFrame:frame];
1009 + (void) initialize {
1010 if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) {
1011 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:addMessageToConsole:), (IMP) &$UIWebViewWebViewDelegate$webView$addMessageToConsole$, "v16@0:4@8@12");
1012 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didClearWindowObject:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$, "v20@0:4@8@12@16");
1015 if (CGFloat *_UIScrollViewDecelerationRateNormal = reinterpret_cast<CGFloat *>(dlsym(RTLD_DEFAULT, "UIScrollViewDecelerationRateNormal")))
1016 CYScrollViewDecelerationRateNormal = *_UIScrollViewDecelerationRateNormal;
1017 else // XXX: this actually might be fast on some older systems: we should look into this
1018 CYScrollViewDecelerationRateNormal = 0.998;
1020 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
1021 iOS32 = !iOS4 && kCFCoreFoundationVersionNumber >= 478.61;
1024 size_t size(sizeof(maxproc));
1025 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
1026 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
1027 else if (maxproc < 72) {
1029 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
1030 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
1033 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
1034 [WebView registerURLSchemeAsLocal:@"cydget"];
1036 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
1037 [WebView registerURLSchemeAsLocal:@"cydget-cgi"];
1039 MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"));
1040 MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
1043 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
1044 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
1045 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
1046 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
1049 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &) = NULL;
1050 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1051 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE", WebCore);
1052 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1053 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKN3WTF6StringE", WebCore);
1054 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
1055 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
1057 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int) = NULL;
1058 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi == NULL)
1059 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi", WebCore);
1060 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
1061 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
1064 const WebCore::String &(*_ZNK7WebCore4Node11textContentEb)(void *, bool) = NULL;
1065 if (_ZNK7WebCore4Node11textContentEb == NULL)
1066 MSHookSymbol(_ZNK7WebCore4Node11textContentEb, "__ZNK7WebCore4Node11textContentEb", WebCore);
1067 if (_ZNK7WebCore4Node11textContentEb != NULL)
1068 MSHookFunction(_ZNK7WebCore4Node11textContentEb, MSHake(_ZNK7WebCore4Node11textContentEb));
1071 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *) = NULL;
1072 if (_ZN7WebCore12CachedScript6scriptEv == NULL)
1073 MSHookSymbol(_ZN7WebCore12CachedScript6scriptEv, "__ZN7WebCore12CachedScript6scriptEv", WebCore);
1074 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
1075 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
1077 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int) = NULL;
1078 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i == NULL)
1079 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i", WebCore);
1080 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
1081 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
1083 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, JSC::ScriptSourceCode &, State) = NULL;
1084 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE == NULL)
1085 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE", WebCore);
1086 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
1087 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
1089 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1090 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, WebCore);
1091 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
1092 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
1094 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1095 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, WebCore);
1096 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE != NULL)
1097 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE));
1099 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
1100 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
1101 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
1102 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
1104 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE)(void *, void *, int);
1105 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, WebCore);
1106 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE != NULL)
1107 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE));
1109 MSHookSymbol($_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, "__ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE", WebCore);
1111 void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, JSC::ScriptSourceCode &);
1112 msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
1113 if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
1114 MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
1116 if (_ZN7WebCore6String6appendEPKtj == NULL)
1117 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN7WebCore6String6appendEPKtj", WebCore);
1118 if (_ZN7WebCore6String6appendEPKtj == NULL)
1119 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
1120 if (_ZN7WebCore6String6appendEPKtj == NULL)
1121 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN3WTF6String6appendEPKtj", JavaScriptCore);
1123 if (_ZN7WebCore6String8truncateEj == NULL)
1124 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN7WebCore6String8truncateEj", WebCore);
1125 if (_ZN7WebCore6String8truncateEj == NULL)
1126 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
1127 if (_ZN7WebCore6String8truncateEj == NULL)
1128 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN3WTF6String8truncateEj", JavaScriptCore);
1130 msset(_ZNK7WebCore6String10charactersEv, WebCore);
1132 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
1133 if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL)
1134 MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore);
1136 msset(_ZNK7WebCore6String6lengthEv, WebCore);
1139 + (id) rootViewController {
1140 return [[[self alloc] init] autorelease];
1144 [configuration_ release];
1145 [background_ release];
1150 if ((self = [super init]) != nil) {
1151 configuration_ = [[$CydgetController currentConfiguration] retain];
1156 NSURL *base([NSURL fileURLWithPath:[$CydgetController currentPath]]);
1158 if (NSString *background = [configuration_ objectForKey:@"Background"])
1159 background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background relativeToURL:base]];
1161 if (NSString *homepage = [configuration_ objectForKey:@"Homepage"]) {
1162 foreground_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]];
1163 [self setView:foreground_];
1164 } else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) {
1165 [self setView:[background_ autorelease]];
1170 - (void) purgeView {
1171 [background_ removeFromSuperview];
1172 [background_ release];
1174 [foreground_ removeFromSuperview];
1175 [foreground_ release];
1180 - (UIView *) backgroundView {
1184 - (BOOL) showAwayItems {
1188 - (BOOL) updateHidden {
1189 if (foreground_ == nil)
1191 SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]);
1192 SBLockScreenView *view([controller lockScreenView]);
1193 bool media(view != nil && ![view mediaControlsHidden]);
1194 [foreground_ setHidden:media];
1198 - (BOOL) showDateView {
1199 bool homepage([configuration_ objectForKey:@"Homepage"] != nil);
1200 if (kCFCoreFoundationVersionNumber < 800)
1204 return [self updateHidden];
1207 - (BOOL) allowsLockScreenMediaControls {
1208 if (kCFCoreFoundationVersionNumber < 800)
1210 if (background_ == nil)
1212 [self updateHidden];
1216 /*- (BOOL) showHeaderView {
1221 - (NSUInteger) presentationStyle {
1226 - (NSUInteger) overlayStyle {
1227 if ([configuration_ objectForKey:@"Background"] == nil)
1233 - (NSUInteger) notificationBehavior {
1237 - (BOOL) viewWantsFullscreenLayout {
1238 return kCFCoreFoundationVersionNumber >= 800;
1241 /*- (BOOL) viewWantsOverlayLayout {
1242 return kCFCoreFoundationVersionNumber >= 800;
1245 - (BOOL) shouldDisableOnUnlock {
1249 - (BOOL) canBeAlwaysFullscreen {
1253 /*- (BOOL) wantsSwipeGestureRecognizer {
1257 - (BOOL) handleGesture:(int)arg1 fingerCount:(NSUInteger)fingers {
1262 // - (void) lockScreenMediaControlsShown:(BOOL)shown;
1264 - (BOOL) handleMenuButtonDoubleTap {
1265 if (kCFCoreFoundationVersionNumber >= 800) {
1266 SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]);
1267 [controller _setMediaControlsVisible:![controller isShowingMediaControls]];
1268 [self updateHidden];
1271 return [super handleMenuButtonDoubleTap];
1276 MSClassHook(WebView)
1277 MSMetaClassHook(WebView)
1279 MSClassMessageHook0(void, WebView, enableWebThread) {
1280 if (kCFCoreFoundationVersionNumber >= 478.61)
1283 NSLog(@"-[WebView enableWebThread]");