Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions KINWebBrowser/KINWebBrowserViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

@protocol KINWebBrowserDelegate <NSObject>
@optional
- (BOOL)webBrowser:(KINWebBrowserViewController *)webBrowser shouldStartLoadingURL:(NSURL *)URL;
- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didStartLoadingURL:(NSURL *)URL;
- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFinishLoadingURL:(NSURL *)URL;
- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFailToLoadURL:(NSURL *)URL error:(NSError *)error;
Expand Down
14 changes: 14 additions & 0 deletions KINWebBrowser/KINWebBrowserViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ - (void)setActionButtonHidden:(BOOL)actionButtonHidden {
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(webView == self.uiWebView) {

if([self.delegate respondsToSelector:@selector(webBrowser:shouldStartLoadingURL:)]) {
if(![self.delegate webBrowser:self shouldStartLoadingURL:request.URL]) {
return NO;
}
}

if(![self externalAppRequiredToOpenURL:request.URL]) {
self.uiWebViewCurrentURL = request.URL;
self.uiWebViewIsLoading = YES;
Expand Down Expand Up @@ -319,6 +325,14 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
if(webView == self.wkWebView) {

NSURL *URL = navigationAction.request.URL;

if([self.delegate respondsToSelector:@selector(webBrowser:shouldStartLoadingURL:)]) {
if(![self.delegate webBrowser:self shouldStartLoadingURL:URL]) {
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}

if(![self externalAppRequiredToOpenURL:URL]) {
if(!navigationAction.targetFrame) {
[self loadURL:URL];
Expand Down