| 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 4924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4935 ProceduralBlock defaultNavigationBlock = ^{ | 4935 ProceduralBlock defaultNavigationBlock = ^{ |
| 4936 web::NavigationItem* item = self.currentNavItem; | 4936 web::NavigationItem* item = self.currentNavItem; |
| 4937 GURL navigationURL = item ? item->GetURL() : GURL::EmptyGURL(); | 4937 GURL navigationURL = item ? item->GetURL() : GURL::EmptyGURL(); |
| 4938 [self registerLoadRequest:navigationURL | 4938 [self registerLoadRequest:navigationURL |
| 4939 referrer:self.currentNavItemReferrer | 4939 referrer:self.currentNavItemReferrer |
| 4940 transition:self.currentTransition]; | 4940 transition:self.currentTransition]; |
| 4941 [self loadRequest:request]; | 4941 [self loadRequest:request]; |
| 4942 }; | 4942 }; |
| 4943 | 4943 |
| 4944 // When navigating via WKBackForwardListItem to pages created or updated by | 4944 // When navigating via WKBackForwardListItem to pages created or updated by |
| 4945 // calls to pushState() and replaceState(), sometimes core.js is not injected | 4945 // calls to pushState() and replaceState(), sometimes web_bundle.js is not |
| 4946 // correctly. This means that calling window.history navigation functions | 4946 // injected correctly. This means that calling window.history navigation |
| 4947 // will invoke WKWebView's non-overridden implementations, causing a mismatch | 4947 // functions will invoke WKWebView's non-overridden implementations, causing a |
| 4948 // between the WKBackForwardList and NavigationManager. | 4948 // mismatch between the WKBackForwardList and NavigationManager. |
| 4949 // TODO(crbug.com/659816): Figure out how to prevent core.js injection flake. | 4949 // TODO(crbug.com/659816): Figure out how to prevent web_bundle.js injection |
| 4950 // flake. |
| 4950 if (currentItem->HasStateBeenReplaced() || | 4951 if (currentItem->HasStateBeenReplaced() || |
| 4951 currentItem->IsCreatedFromPushState()) { | 4952 currentItem->IsCreatedFromPushState()) { |
| 4952 defaultNavigationBlock(); | 4953 defaultNavigationBlock(); |
| 4953 return; | 4954 return; |
| 4954 } | 4955 } |
| 4955 | 4956 |
| 4956 // If there is no corresponding WKBackForwardListItem, or the item is not in | 4957 // If there is no corresponding WKBackForwardListItem, or the item is not in |
| 4957 // the current WKWebView's back-forward list, navigating using WKWebView API | 4958 // the current WKWebView's back-forward list, navigating using WKWebView API |
| 4958 // is not possible. In this case, fall back to the default navigation | 4959 // is not possible. In this case, fall back to the default navigation |
| 4959 // mechanism. | 4960 // mechanism. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5065 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5066 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5066 _lastRegisteredRequestURL = URL; | 5067 _lastRegisteredRequestURL = URL; |
| 5067 _loadPhase = web::LOAD_REQUESTED; | 5068 _loadPhase = web::LOAD_REQUESTED; |
| 5068 } | 5069 } |
| 5069 | 5070 |
| 5070 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5071 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5071 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5072 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5072 } | 5073 } |
| 5073 | 5074 |
| 5074 @end | 5075 @end |
| OLD | NEW |