Commit 99d86ffd authored by olivierrobin's avatar olivierrobin Committed by Commit bot

Do not navigate on loading iframes in StaticHTMLViewController.

If the static HTML contains iframes, a call to
decidePolicyForNavigationAction is done with a navigationType other.
This should not trigger a navigation to URLLoader.

BUG=676575

Review-Url: https://codereview.chromium.org/2597133002
Cr-Commit-Position: refs/heads/master@{#440859}
parent 074906f9
......@@ -84,8 +84,10 @@
- (NSURL*)resourceURL;
// Ensures that webView_ has been created, creating it if necessary.
- (void)ensureWebViewCreated;
// Determines if the page load should begin based on the current |resourceURL|.
- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request;
// Determines if the page load should begin based on the current |resourceURL|
// and if the request is issued by the main frame (|fromMainFrame|).
- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request
fromMainFrame:(BOOL)fromMainFrame;
@end
@implementation StaticHtmlViewController
......@@ -199,9 +201,12 @@
decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction
decisionHandler:
(void (^)(WKNavigationActionPolicy))decisionHandler {
decisionHandler([self shouldStartLoadWithRequest:navigationAction.request]
? WKNavigationActionPolicyAllow
: WKNavigationActionPolicyCancel);
decisionHandler(
[self
shouldStartLoadWithRequest:navigationAction.request
fromMainFrame:[navigationAction.sourceFrame isMainFrame]]
? WKNavigationActionPolicyAllow
: WKNavigationActionPolicyCancel);
}
#pragma mark -
......@@ -222,13 +227,15 @@
#pragma mark -
#pragma mark Private
- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request {
- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request
fromMainFrame:(BOOL)fromMainFrame {
// Only allow displaying the URL which correspond to the authorized resource.
if ([[request URL] isEqual:[self resourceURL]])
return YES;
// All other URLs will be loaded by our UrlLoader if we have one.
if (loader_) {
// All other navigation URLs will be loaded by our UrlLoader if one exists and
// if they are issued by the main frame.
if (loader_ && fromMainFrame) {
dispatch_async(dispatch_get_main_queue(), ^{
[loader_ loadURL:net::GURLWithNSURL([request URL])
referrer:referrer_
......
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