| 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 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 _webStateImpl->OnTitleChanged(); | 1389 _webStateImpl->OnTitleChanged(); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 - (BOOL)isCurrentNavigationItemPOST { | 1392 - (BOOL)isCurrentNavigationItemPOST { |
| 1393 // |_pendingNavigationInfo| will be nil if the decidePolicy* delegate methods | 1393 // |_pendingNavigationInfo| will be nil if the decidePolicy* delegate methods |
| 1394 // were not called. | 1394 // were not called. |
| 1395 NSString* HTTPMethod = | 1395 NSString* HTTPMethod = |
| 1396 _pendingNavigationInfo | 1396 _pendingNavigationInfo |
| 1397 ? [_pendingNavigationInfo HTTPMethod] | 1397 ? [_pendingNavigationInfo HTTPMethod] |
| 1398 : [self currentBackForwardListItemHolder]->http_method(); | 1398 : [self currentBackForwardListItemHolder]->http_method(); |
| 1399 return [HTTPMethod isEqual:@"POST"]; | 1399 return [HTTPMethod isEqual:@"POST"] || self.currentNavItem->HasPostData(); |
| 1400 } | 1400 } |
| 1401 | 1401 |
| 1402 - (BOOL)isCurrentNavigationBackForward { | 1402 - (BOOL)isCurrentNavigationBackForward { |
| 1403 if (!self.currentNavItem) | 1403 if (!self.currentNavItem) |
| 1404 return NO; | 1404 return NO; |
| 1405 WKNavigationType currentNavigationType = | 1405 WKNavigationType currentNavigationType = |
| 1406 [self currentBackForwardListItemHolder]->navigation_type(); | 1406 [self currentBackForwardListItemHolder]->navigation_type(); |
| 1407 return currentNavigationType == WKNavigationTypeBackForward; | 1407 return currentNavigationType == WKNavigationTypeBackForward; |
| 1408 } | 1408 } |
| 1409 | 1409 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 web::NavigationContextImpl::CreateNavigationContext( | 1533 web::NavigationContextImpl::CreateNavigationContext( |
| 1534 _webStateImpl, requestURL, transition); | 1534 _webStateImpl, requestURL, transition); |
| 1535 | 1535 |
| 1536 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); | 1536 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); |
| 1537 // TODO(crbug.com/676129): AddPendingItem does not always create a pending | 1537 // TODO(crbug.com/676129): AddPendingItem does not always create a pending |
| 1538 // item. Remove this workaround once the bug is fixed. | 1538 // item. Remove this workaround once the bug is fixed. |
| 1539 if (!item) { | 1539 if (!item) { |
| 1540 item = self.navigationManagerImpl->GetLastCommittedItem(); | 1540 item = self.navigationManagerImpl->GetLastCommittedItem(); |
| 1541 } | 1541 } |
| 1542 context->SetNavigationItemUniqueID(item->GetUniqueID()); | 1542 context->SetNavigationItemUniqueID(item->GetUniqueID()); |
| 1543 context->SetIsPost([self isCurrentNavigationItemPOST]); |
| 1543 _webStateImpl->SetIsLoading(true); | 1544 _webStateImpl->SetIsLoading(true); |
| 1544 _webStateImpl->OnNavigationStarted(context.get()); | 1545 _webStateImpl->OnNavigationStarted(context.get()); |
| 1545 return context; | 1546 return context; |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 - (void)updateHTML5HistoryState { | 1549 - (void)updateHTML5HistoryState { |
| 1549 web::NavigationItemImpl* currentItem = self.currentNavItem; | 1550 web::NavigationItemImpl* currentItem = self.currentNavItem; |
| 1550 if (!currentItem) | 1551 if (!currentItem) |
| 1551 return; | 1552 return; |
| 1552 | 1553 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); | 2043 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); |
| 2043 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD; | 2044 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD; |
| 2044 reloadParams.extra_headers.reset( | 2045 reloadParams.extra_headers.reset( |
| 2045 [transientItem->GetHttpRequestHeaders() copy]); | 2046 [transientItem->GetHttpRequestHeaders() copy]); |
| 2046 [self loadWithParams:reloadParams]; | 2047 [self loadWithParams:reloadParams]; |
| 2047 } else { | 2048 } else { |
| 2048 // As with back and forward navigation, load the URL manually instead of | 2049 // As with back and forward navigation, load the URL manually instead of |
| 2049 // using the web view's reload. This ensures state processing and delegate | 2050 // using the web view's reload. This ensures state processing and delegate |
| 2050 // calls are consistent. | 2051 // calls are consistent. |
| 2051 // TODO(eugenebut): revisit this for WKWebView. | 2052 // TODO(eugenebut): revisit this for WKWebView. |
| 2053 self.navigationManagerImpl->GetLastCommittedItem()->SetTransitionType( |
| 2054 ui::PAGE_TRANSITION_RELOAD); |
| 2052 [self loadCurrentURL]; | 2055 [self loadCurrentURL]; |
| 2053 } | 2056 } |
| 2054 } | 2057 } |
| 2055 } | 2058 } |
| 2056 | 2059 |
| 2057 - (void)reload { | 2060 - (void)reload { |
| 2058 [_delegate webWillReload]; | 2061 [_delegate webWillReload]; |
| 2059 [self reloadInternal]; | 2062 [self reloadInternal]; |
| 2060 } | 2063 } |
| 2061 | 2064 |
| (...skipping 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5234 - (NSUInteger)observerCount { | 5237 - (NSUInteger)observerCount { |
| 5235 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5238 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
| 5236 return [_observers count]; | 5239 return [_observers count]; |
| 5237 } | 5240 } |
| 5238 | 5241 |
| 5239 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5242 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5240 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5243 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5241 } | 5244 } |
| 5242 | 5245 |
| 5243 @end | 5246 @end |
| OLD | NEW |