Commit 7b69eacc authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Allow WebViewController to open webpage with target="_blank"

Previously tapping a link on the help page has no effect because the
links have target="_blank" attribute and we haven't properly set up the
WebViewController to handle that.

This CL makes the app open a target="_blank" link using the default
browser, aka Safari.

Bug: 821955
Change-Id: I1557a37d9b1a341186ee1b59fec1de77f075da1a
Reviewed-on: https://chromium-review.googlesource.com/963690Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543245}
parent 1ae2a0ff
......@@ -13,7 +13,7 @@
#import "remoting/ios/app/remoting_theme.h"
#import "remoting/ios/app/view_utils.h"
@interface WebViewController () {
@interface WebViewController ()<WKUIDelegate> {
NSString* _urlString;
}
@end
......@@ -37,6 +37,7 @@
NSURLRequest* request =
[NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]];
[webView loadRequest:request];
webView.UIDelegate = self;
self.view = webView;
}
......@@ -60,6 +61,21 @@
}
}
#pragma mark - WKUIDelegate
- (WKWebView*)webView:(WKWebView*)webView
createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
forNavigationAction:(WKNavigationAction*)navigationAction
windowFeatures:(WKWindowFeatures*)windowFeatures {
// This is called when the web view needs to open a webpage in new window,
// i.e. target="_blank".
[UIApplication.sharedApplication openURL:navigationAction.request.URL
options:@{}
completionHandler:nil];
return nil;
}
#pragma mark - Private
- (void)didTapClose:(id)button {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment