]> git.saurik.com Git - cydia.git/commitdiff
Improve state machine that protects against automatic fail-directs.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 26 Mar 2011 14:37:25 +0000 (07:37 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 26 Mar 2011 14:40:42 +0000 (07:40 -0700)
CyteKit/WebViewController.mm

index 580a9ca17cad1b934e79c8479a6fcd51810c4f23..2d489b3507360ca9a5765e3019b4b7e9ecb50b97 100644 (file)
@@ -453,10 +453,26 @@ float CYScrollViewDecelerationRateNormal;
 }
 
 - (void) webView:(WebView *)view didDecidePolicy:(CYWebPolicyDecision)decision forNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame {
-    if ([frame parentFrame] == nil)
-        if (decision == CYWebPolicyDecisionUse)
-            if (!error_)
-                request_ = request;
+#if LogBrowser
+    NSLog(@"didDecidePolicy:%u forNavigationAction:%@ request:%@ frame:%@", decision, action, request, [request allHTTPHeaderFields], frame);
+#endif
+
+    if ([frame parentFrame] == nil) {
+        switch (decision) {
+            case CYWebPolicyDecisionIgnore:
+                if ([[request_ URL] isEqual:[request URL]])
+                    request_ = nil;
+            break;
+
+            case CYWebPolicyDecisionUse:
+                if (!error_)
+                    request_ = request;
+            break;
+
+            default:
+            break;
+        }
+    }
 }
 
 - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {