Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to whitelist iFrame requests #585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 21 additions & 2 deletions src/ios/CDVWKWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,12 @@ - (void) webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigat
{
NSURL* url = [navigationAction.request URL];
CDVViewController* vc = (CDVViewController*)self.viewController;
BOOL anyPluginsResponded = NO;
BOOL shouldAllowRequest = NO;

/*
* Give plugins the chance to handle the url
*/
BOOL anyPluginsResponded = NO;
BOOL shouldAllowRequest = NO;

for (NSString* pluginName in vc.pluginObjects) {
CDVPlugin* plugin = [vc.pluginObjects objectForKey:pluginName];
Expand All @@ -753,6 +753,25 @@ - (void) webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigat
}
}

/*
* Give plugins the chance to handle iframe request
*/
if(!navigationAction.targetFrame.isMainFrame){
for (NSString* pluginName in vc.pluginObjects) {
CDVPlugin* plugin = [vc.pluginObjects objectForKey:pluginName];

SEL selector = NSSelectorFromString(@"shouldAllowSubframeRequest:");

if ([plugin respondsToSelector:selector]) {
anyPluginsResponded = YES;
shouldAllowRequest = (((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, navigationAction.request));
if (!shouldAllowRequest) {
break;
}
}
}
}

if (!anyPluginsResponded) {
/*
* Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
Expand Down