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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 DCHECK(holder); | 1846 DCHECK(holder); |
1847 return holder; | 1847 return holder; |
1848 } | 1848 } |
1849 | 1849 |
1850 - (void)updateCurrentBackForwardListItemHolder { | 1850 - (void)updateCurrentBackForwardListItemHolder { |
1851 // WebUI pages (which are loaded via loadHTMLString:baseURL:) have no entry | 1851 // WebUI pages (which are loaded via loadHTMLString:baseURL:) have no entry |
1852 // in the back/forward list, so the current item will still be the previous | 1852 // in the back/forward list, so the current item will still be the previous |
1853 // page, and should not be associated. | 1853 // page, and should not be associated. |
1854 if (_webUIManager) | 1854 if (_webUIManager) |
1855 return; | 1855 return; |
| 1856 // The WKWebViewConfiguration's |userScripts| are not injected when navigating |
| 1857 // via BFLI to a page created using window.history.pushState. This means that |
| 1858 // calling window.history navigation functions will invoke WKWebView's |
| 1859 // non-overridden implementations, causing a mismatch between the |
| 1860 // WKBackForwardList and NavigationManager. |
| 1861 web::NavigationItemImpl* currentItem = |
| 1862 [self currentSessionEntry].navigationItemImpl; |
| 1863 if (currentItem->IsCreatedFromPushState()) |
| 1864 return; |
1856 | 1865 |
1857 web::WKBackForwardListItemHolder* holder = | 1866 web::WKBackForwardListItemHolder* holder = |
1858 [self currentBackForwardListItemHolder]; | 1867 [self currentBackForwardListItemHolder]; |
1859 | 1868 |
1860 WKNavigationType navigationType = | 1869 WKNavigationType navigationType = |
1861 _pendingNavigationInfo ? [_pendingNavigationInfo navigationType] | 1870 _pendingNavigationInfo ? [_pendingNavigationInfo navigationType] |
1862 : WKNavigationTypeOther; | 1871 : WKNavigationTypeOther; |
1863 holder->set_back_forward_list_item([_webView backForwardList].currentItem); | 1872 holder->set_back_forward_list_item([_webView backForwardList].currentItem); |
1864 holder->set_navigation_type(navigationType); | 1873 holder->set_navigation_type(navigationType); |
1865 holder->set_http_method([_pendingNavigationInfo HTTPMethod]); | 1874 holder->set_http_method([_pendingNavigationInfo HTTPMethod]); |
(...skipping 3764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5630 } | 5639 } |
5631 | 5640 |
5632 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5641 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5633 } | 5642 } |
5634 | 5643 |
5635 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5644 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5636 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5645 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5637 } | 5646 } |
5638 | 5647 |
5639 @end | 5648 @end |
OLD | NEW |