diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-14 01:10:41 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-14 01:10:41 -0800 |
commit | eb09425a76cb1fdd9f09a00e43e760f952800cc6 (patch) | |
tree | 5374ceaae443c20623da0582f8b91a18dbf654e7 /UICaboodle | |
parent | 7b3f9d6e5f4471e8e56120e7b7b5132dfd88063f (diff) |
Implement chpwn's lazy-loading API for BrowserController.
Diffstat (limited to 'UICaboodle')
-rw-r--r-- | UICaboodle/BrowserView.h | 3 | ||||
-rw-r--r-- | UICaboodle/BrowserView.mm | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index efc1e6c..79652f3 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 2abc02e..c4e4b36 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 <typename Type_> 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_]; |