From 92de61aabba908e254b8d4f1498798043fdabbe7 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 24 Jun 2015 10:09:30 -0700 Subject: [PATCH] Now on iOS 8.3, webView: can be webThreadWebView:. --- CyteKit/WebView.h | 1 + CyteKit/WebView.mm | 10 ++++++++++ CyteKit/WebViewController.h | 2 ++ CyteKit/WebViewController.mm | 8 ++++++++ MobileCydia.mm | 4 ++++ iPhonePrivate.h | 1 + 6 files changed, 26 insertions(+) diff --git a/CyteKit/WebView.h b/CyteKit/WebView.h index 804c0372..7314da6a 100644 --- a/CyteKit/WebView.h +++ b/CyteKit/WebView.h @@ -55,6 +55,7 @@ enum CYWebPolicyDecision { - (void) webView:(WebView *)view resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source; - (void) webView:(WebView *)view resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source; - (NSURLRequest *) webView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; - (void) webViewClose:(WebView *)view; - (bool) webView:(WebView *)view shouldRunJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame; - (bool) webView:(WebView *)view shouldRunJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame; diff --git a/CyteKit/WebView.mm b/CyteKit/WebView.mm index 66304630..df377113 100644 --- a/CyteKit/WebView.mm +++ b/CyteKit/WebView.mm @@ -295,6 +295,16 @@ static NSURLRequest *$UIWebViewWebViewDelegate$webView$resource$willSendRequest$ return request; } // }}} +// webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource: {{{ +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { + id delegate([self delegate]); + if ([UIWebView instancesRespondToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)]) + request = [super webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source]; + if ([delegate respondsToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)]) + request = [delegate webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source]; + return request; +} +// }}} // webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame: (2.1+) {{{ - (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { [[self retain] autorelease]; diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index 24832242..84104321 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -107,7 +107,9 @@ - (void) reloadURLWithCache:(BOOL)cache; - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame; + - (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; + (float) defaultWidth; diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 33524f39..a7ff586f 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -711,6 +711,14 @@ float CYScrollViewDecelerationRateNormal; return request; } +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { +#if LogBrowser + NSLog(@"resource:%@ willSendRequest:%@ redirectResponse:%@ fromDataSource:%@", identifier, request, response, source); +#endif + + return request; +} + - (bool) webView:(WebView *)view shouldRunJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { return [self _allowJavaScriptPanel]; } diff --git a/MobileCydia.mm b/MobileCydia.mm index 6dfe632f..72950d3c 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -4956,6 +4956,10 @@ static _H Diversions_; return [CydiaWebViewController requestWithHeaders:[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source]]; } +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { + return [CydiaWebViewController requestWithHeaders:[super webThreadWebView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source]]; +} + + (NSURLRequest *) requestWithHeaders:(NSURLRequest *)request { NSMutableURLRequest *copy([[request mutableCopy] autorelease]); diff --git a/iPhonePrivate.h b/iPhonePrivate.h index 42a700d8..06aff31f 100644 --- a/iPhonePrivate.h +++ b/iPhonePrivate.h @@ -335,6 +335,7 @@ static const UIActivityIndicatorViewStyle UIActivityIndicatorViewStyleWhiteTiny( - (void) webView:(WebView *)view resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source; - (void) webView:(WebView *)view resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source; - (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source; - (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame; - (BOOL) webView:(WebView *)view runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame; - (NSString *) webView:(WebView *)view runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame; -- 2.45.2