From: Jay Freeman (saurik) Date: Mon, 14 Feb 2011 09:10:41 +0000 (-0800) Subject: Implement chpwn's lazy-loading API for BrowserController. X-Git-Tag: v1.1.0%b1~341 X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/eb09425a76cb1fdd9f09a00e43e760f952800cc6?hp=7b3f9d6e5f4471e8e56120e7b7b5132dfd88063f Implement chpwn's lazy-loading API for BrowserController. --- diff --git a/MobileCydia.mm b/MobileCydia.mm index aae8dd53..5f6fb36f 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -8894,8 +8894,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ([base isEqualToString:@"url"]) { // This kind of URL can contain slashes in the argument, so we can't parse them below. NSString *destination = [[url absoluteString] substringFromIndex:([scheme length] + [@"://" length] + [base length] + [@"/" length])]; - controller = [[[CYBrowserController alloc] init] autorelease]; - [(CYBrowserController *)controller loadURL:[NSURL URLWithString:destination]]; + controller = [[[CYBrowserController alloc] initWithURL:[NSURL URLWithString:destination]] autorelease]; } else if ([components count] == 1) { if ([base isEqualToString:@"manage"]) { controller = [[[ManageController alloc] init] autorelease]; diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index efc1e6ca..79652f38 100644 --- a/UICaboodle/BrowserView.h +++ b/UICaboodle/BrowserView.h @@ -91,6 +91,8 @@ + (void) _initialize; +- (void) setURL:(NSURL *)url; + - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy; - (void) loadURL:(NSURL *)url; @@ -99,6 +101,7 @@ - (bool) isLoading; - (id) init; +- (id) initWithURL:(NSURL *)url; - (id) initWithWidth:(float)width; - (id) initWithWidth:(float)width ofClass:(Class)_class; diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm index 2abc02ec..c4e4b365 100644 --- a/UICaboodle/BrowserView.mm +++ b/UICaboodle/BrowserView.mm @@ -27,6 +27,7 @@ extern NSString * const kCAFilterNearest; #include "substrate.h" #define ForSaurik 0 +#define DefaultTimeout_ 120.0 template static inline void CYRelease(Type_ &value) { @@ -463,11 +464,21 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se [super dealloc]; } +- (void) setURL:(NSURL *)url { + _assert(request_ == nil); + + request_ = [[NSURLRequest + requestWithURL:url + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:DefaultTimeout_ + ] retain]; +} + - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy { [self loadRequest:[NSURLRequest requestWithURL:url cachePolicy:policy - timeoutInterval:120.0 + timeoutInterval:DefaultTimeout_ ]]; } @@ -507,6 +518,11 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se } } +- (void) reloadData { + [super reloadData]; + [self reloadURL]; +} + - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function { if (custom_ != nil) [custom_ autorelease]; @@ -1035,6 +1051,12 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se return [self initWithWidth:0]; } +- (id) initWithURL:(NSURL *)url { + if ((self = [self init]) != nil) { + [self setURL:url]; + } return self; +} + - (void) didDismissModalViewController { if (closer_ != nil) [self callFunction:closer_];