Chromium Code Reviews| Index: ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
| diff --git a/ios/chrome/browser/ui/static_content/static_html_view_controller.mm b/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
| index e22d51be30dfc15ce6ccfdcb8eba00aa3f3cc1c9..d5b8d5ed29073f10a2a70ee9eb810792ccebf5c4 100644 |
| --- a/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
| +++ b/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
| @@ -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,11 @@ |
| decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction |
| decisionHandler: |
| (void (^)(WKNavigationActionPolicy))decisionHandler { |
| - decisionHandler([self shouldStartLoadWithRequest:navigationAction.request] |
| - ? WKNavigationActionPolicyAllow |
| - : WKNavigationActionPolicyCancel); |
| + decisionHandler( |
| + [self shouldStartLoadWithRequest:navigationAction.request |
| + fromMainFrame:navigationAction.sourceFrame.isMainFrame] |
|
Eugene But (OOO till 7-30)
2016/12/28 16:41:05
navigationAction.sourceFrame.mainFrame or [navigat
|
| + ? WKNavigationActionPolicyAllow |
| + : WKNavigationActionPolicyCancel); |
| } |
| #pragma mark - |
| @@ -222,13 +226,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. |
| + // If type is |WKNavigationTypeOther|, the URL corresponds to an iframe. |
|
Eugene But (OOO till 7-30)
2016/12/28 16:41:05
This comment looks obsoleted.
|
| + if (loader_ && fromMainFrame) { |
| dispatch_async(dispatch_get_main_queue(), ^{ |
| [loader_ loadURL:net::GURLWithNSURL([request URL]) |
| referrer:referrer_ |