]> git.saurik.com Git - cydia.git/commitdiff
Fixed browser links and modify delegates.
authorJay Freeman (saurik) <saurik@saurk.com>
Sat, 19 Jul 2008 23:28:55 +0000 (23:28 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:07 +0000 (07:08 +0000)
Cydia.mm
UICaboodle/BrowserView.h

index 27113ffcc8e3e66a58a84ac4c43f2297c45f6781..26a92759c9539124c8514e1c78a6ee5c778bb0d0 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -3517,6 +3517,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 }
 
 - (void) loadRequest:(NSURLRequest *)request {
+    pushed_ = true;
     [webview_ loadRequest:request];
 }
 
@@ -3538,27 +3539,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     [self view:sender didSetFrame:frame];
 }
 
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
-    return [self _addHeadersToRequest:request];
-}
-
-- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
-    if ([[[request URL] scheme] isEqualToString:@"apptapp"])
-        return nil;
-    [self setBackButtonTitle:title_];
-    BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
-    [browser setDelegate:delegate_];
-    [book_ pushPage:browser];
-    [browser loadRequest:[self _addHeadersToRequest:request]];
-    return [browser webView];
-}
-
-- (void) webView:(WebView *)sender willClickElement:(id)element {
-    if (![element respondsToSelector:@selector(href)])
-        return;
-    NSString *href = [element href];
-    if (href == nil)
-        return;
+- (void) getAppTapp:(NSString *)href {
     if ([href hasPrefix:@"apptapp://package/"]) {
         NSString *name = [href substringFromIndex:18];
         Package *package = [database_ packageWithName:name];
@@ -3586,6 +3567,48 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     }
 }
 
+- (void) webView:(WebView *)sender willClickElement:(id)element {
+    if (![element respondsToSelector:@selector(href)])
+        return;
+    NSString *href = [element href];
+    if (href == nil)
+        return;
+    if ([href hasPrefix:@"apptapp://package/"])
+        [self getAppTapp:href];
+}
+
+- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
+    if ([[[request URL] scheme] isEqualToString:@"apptapp"]) {
+        [self getAppTapp:[[request URL] absoluteString]];
+        return nil;
+    }
+
+    if (!pushed_) {
+        pushed_ = true;
+        [book_ pushPage:self];
+    }
+
+    return [self _addHeadersToRequest:request];
+}
+
+- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
+    if (request != nil && [[[request URL] scheme] isEqualToString:@"apptapp"])
+        return nil;
+    else {
+        [self setBackButtonTitle:title_];
+
+        BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
+        [browser setDelegate:delegate_];
+
+        if (request != nil) {
+            [browser loadRequest:[self _addHeadersToRequest:request]];
+            [book_ pushPage:browser];
+        }
+
+        return [browser webView];
+    }
+}
+
 - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
     title_ = [title retain];
     [self setTitle:title];
@@ -3752,6 +3775,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 - (void) resetViewAnimated:(BOOL)animated {
 }
 
+- (void) setPushed:(bool)pushed {
+    pushed_ = pushed;
+}
+
 @end
 /* }}} */
 
@@ -4408,6 +4435,12 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     return @"Packages";
 }
 
+- (void) setDelegate:(id)delegate {
+    [super setDelegate:delegate];
+    [packages_ setDelegate:delegate];
+    [sources_ setDelegate:delegate];
+}
+
 @end
 /* }}} */
 /* Search View {{{ */
index a58a5b7b67e5a90b36eb890afcdad795feae32d8..c9a1f7d7e6f91a06bfe6392958ba3e05681fdc8a 100644 (file)
@@ -21,6 +21,8 @@
     NSString *title_;
     bool loading_;
     bool reloading_;
+
+    bool pushed_;
 }
 
 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy;