| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 4756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4767 decisionHandler(WKNavigationActionPolicyCancel); | 4767 decisionHandler(WKNavigationActionPolicyCancel); |
| 4768 return; | 4768 return; |
| 4769 } | 4769 } |
| 4770 | 4770 |
| 4771 // The page will not be changed until this navigation is commited, so the | 4771 // The page will not be changed until this navigation is commited, so the |
| 4772 // retrieved state will be pending until |didCommitNavigation| callback. | 4772 // retrieved state will be pending until |didCommitNavigation| callback. |
| 4773 [self updatePendingNavigationInfoFromNavigationAction:action]; | 4773 [self updatePendingNavigationInfoFromNavigationAction:action]; |
| 4774 | 4774 |
| 4775 // Invalid URLs should not be loaded. However, simply doing nothing upon | 4775 // Invalid URLs should not be loaded. However, simply doing nothing upon |
| 4776 // tapping a link or button is a jarring user experience. Instead, cancel | 4776 // tapping a link or button is a jarring user experience. Instead, cancel |
| 4777 // the invalid navigation and load about:blank. | 4777 // the invalid navigation and load about:blank if navigation was requested for |
| 4778 // the main frame. |
| 4778 GURL requestURL = net::GURLWithNSURL(action.request.URL); | 4779 GURL requestURL = net::GURLWithNSURL(action.request.URL); |
| 4779 if (!requestURL.is_valid()) { | 4780 if (!requestURL.is_valid()) { |
| 4780 decisionHandler(WKNavigationActionPolicyCancel); | 4781 decisionHandler(WKNavigationActionPolicyCancel); |
| 4781 GURL aboutBlankURL(url::kAboutBlankURL); | 4782 if (action.targetFrame.mainFrame) { |
| 4782 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); | 4783 GURL aboutBlankURL(url::kAboutBlankURL); |
| 4783 loadParams.referrer = [self currentReferrer]; | 4784 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); |
| 4784 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); | 4785 loadParams.referrer = [self currentReferrer]; |
| 4786 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); |
| 4787 } |
| 4785 return; | 4788 return; |
| 4786 } | 4789 } |
| 4787 | 4790 |
| 4788 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; | 4791 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; |
| 4789 | 4792 |
| 4790 if (allowLoad) { | 4793 if (allowLoad) { |
| 4791 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); | 4794 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); |
| 4792 if (!allowLoad && action.targetFrame.mainFrame) { | 4795 if (!allowLoad && action.targetFrame.mainFrame) { |
| 4793 [_pendingNavigationInfo setCancelled:YES]; | 4796 [_pendingNavigationInfo setCancelled:YES]; |
| 4794 } | 4797 } |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5557 } | 5560 } |
| 5558 | 5561 |
| 5559 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5562 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5560 } | 5563 } |
| 5561 | 5564 |
| 5562 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5565 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5563 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5566 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5564 } | 5567 } |
| 5565 | 5568 |
| 5566 @end | 5569 @end |
| OLD | NEW |