Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: ios/chrome/browser/ui/static_content/static_html_view_controller.mm

Issue 2597133002: Do not navigate on loading iframes in StaticHTMLViewController. (Closed)
Patch Set: typo Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4d869068338753aebada5dcf650774ca6ef3810c 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 the navigation type |type|.
+- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request
+ type:(WKNavigationType)type;
Eugene But (OOO till 7-30) 2016/12/22 16:21:56 nit: s/type/navigationType:
Olivier 2016/12/22 16:42:59 Done.
Eugene But (OOO till 7-30) 2016/12/22 17:37:51 Sorry I meant words before arguments (s/type:/navi
@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
+ type:navigationAction.navigationType]
+ ? WKNavigationActionPolicyAllow
+ : WKNavigationActionPolicyCancel);
}
#pragma mark -
@@ -222,13 +226,16 @@
#pragma mark -
#pragma mark Private
-- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request {
+- (BOOL)shouldStartLoadWithRequest:(NSURLRequest*)request
+ type:(WKNavigationType)type {
// 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 we have one.
Eugene But (OOO till 7-30) 2016/12/22 16:21:56 nit: Please avoid "we" in the comments (go/avoidwe
Olivier 2016/12/22 16:42:59 I did not add the we :) Removed.
+ // If type is |WKNavigationTypeOther|, the URL corresponds to an external
Eugene But (OOO till 7-30) 2016/12/22 16:21:56 What does "external resource mean"? I think WKNavi
Olivier 2016/12/22 16:42:59 Clicking on regular link is WKNavigationTypeLinkAc
+ // resource and should not be loaded at all.
+ if (loader_ && type != WKNavigationTypeOther) {
dispatch_async(dispatch_get_main_queue(), ^{
[loader_ loadURL:net::GURLWithNSURL([request URL])
referrer:referrer_
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698