diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-05 03:54:19 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-07 02:41:37 -0800 |
commit | d323285e7d6f4836a189d9419b716b7dbc8c2da6 (patch) | |
tree | 4f51eaf53ddb0bfc4c744d101c275c414f0e0285 /CyteKit | |
parent | 9dbfe708245db7d2dd2c8e779efb413ef0c3f8d3 (diff) |
Disallow serializing ignored URLs to the state.
Diffstat (limited to 'CyteKit')
-rw-r--r-- | CyteKit/WebView.h | 8 | ||||
-rw-r--r-- | CyteKit/WebView.mm | 8 | ||||
-rw-r--r-- | CyteKit/WebViewController.mm | 9 |
3 files changed, 15 insertions, 10 deletions
diff --git a/CyteKit/WebView.h b/CyteKit/WebView.h index 91878b7..0c96f6f 100644 --- a/CyteKit/WebView.h +++ b/CyteKit/WebView.h @@ -50,11 +50,19 @@ #include <JavaScriptCore/JavaScriptCore.h> +enum CYWebPolicyDecision { + CYWebPolicyDecisionUnknown, + CYWebPolicyDecisionDownload, + CYWebPolicyDecisionIgnore, + CYWebPolicyDecisionUse, +}; + @protocol CyteWebViewDelegate <UIWebViewDelegate> - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message; - (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener; - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener; - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame; +- (void) webView:(WebView *)view didDecidePolicy:(CYWebPolicyDecision)decision forNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame; - (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; - (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; - (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame; diff --git a/CyteKit/WebView.mm b/CyteKit/WebView.mm index 8fd362f..dd72f5a 100644 --- a/CyteKit/WebView.mm +++ b/CyteKit/WebView.mm @@ -45,13 +45,6 @@ #include "iPhonePrivate.h" // CYWebPolicyDecision* {{{ -enum CYWebPolicyDecision { - CYWebPolicyDecisionUnknown, - CYWebPolicyDecisionDownload, - CYWebPolicyDecisionIgnore, - CYWebPolicyDecisionUse, -}; - @interface CYWebPolicyDecisionMediator : NSObject < WebPolicyDecisionListener > { @@ -165,6 +158,7 @@ static void $UIWebViewWebViewDelegate$webView$addMessageToConsole$(UIWebViewWebV [delegate webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator]; if (![mediator decided] && [UIWebView instancesRespondToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)]) [super webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator]; + [delegate webView:view didDecidePolicy:[mediator decision] forNavigationAction:action request:request frame:frame]; [mediator decide]; } // }}} diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 39103fb..e67e6bc 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -411,9 +411,7 @@ float CYScrollViewDecelerationRateNormal; if (!error_) { NSURL *url(request == nil ? nil : [request URL]); - if (request_ == nil || [self allowsNavigationAction] || [[request_ URL] isEqual:url]) - request_ = request; - else { + if (request_ != nil && ![[request_ URL] isEqual:url] && ![self allowsNavigationAction]) { if (url != nil) [self pushRequest:request asPop:NO]; [listener ignore]; @@ -422,6 +420,11 @@ float CYScrollViewDecelerationRateNormal; } } +- (void) webView:(WebView *)view didDecidePolicy:(CYWebPolicyDecision)decision forNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame { + if (decision == CYWebPolicyDecisionUse) + request_ = request; +} + - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener { #if LogBrowser NSLog(@"decidePolicyForNewWindowAction:%@ request:%@ newFrameName:%@", action, request, frame); |