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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1514 [self recordStateInHistory]; | 1514 [self recordStateInHistory]; |
1515 } | 1515 } |
1516 | 1516 |
1517 [_delegate webWillAddPendingURL:requestURL transition:transition]; | 1517 [_delegate webWillAddPendingURL:requestURL transition:transition]; |
1518 // Add or update pending url. | 1518 // Add or update pending url. |
1519 if (self.navigationManagerImpl->GetPendingItem()) { | 1519 if (self.navigationManagerImpl->GetPendingItem()) { |
1520 // Update the existing pending entry. | 1520 // Update the existing pending entry. |
1521 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. | 1521 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. |
1522 [[self sessionController] updatePendingItem:requestURL]; | 1522 [[self sessionController] updatePendingItem:requestURL]; |
1523 } else { | 1523 } else { |
1524 // A new session history entry needs to be created. | 1524 // If this is a reload then there no need to create a new pending item, |
1525 self.navigationManagerImpl->AddPendingItem( | 1525 // instead update the pending item to the last committed item. |
1526 requestURL, referrer, transition, | 1526 if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD)) { |
1527 web::NavigationInitiationType::RENDERER_INITIATED, | 1527 self.sessionController.pendingItemIndex = |
1528 web::NavigationManager::UserAgentOverrideOption::INHERIT); | 1528 self.sessionController.lastCommittedItemIndex; |
1529 } else { | |
1530 // A new session history entry needs to be created. | |
1531 self.navigationManagerImpl->AddPendingItem( | |
1532 requestURL, referrer, transition, | |
1533 web::NavigationInitiationType::RENDERER_INITIATED, | |
1534 web::NavigationManager::UserAgentOverrideOption::INHERIT); | |
1535 } | |
1529 } | 1536 } |
1530 std::unique_ptr<web::NavigationContextImpl> context = | 1537 std::unique_ptr<web::NavigationContextImpl> context = |
1531 web::NavigationContextImpl::CreateNavigationContext( | 1538 web::NavigationContextImpl::CreateNavigationContext( |
1532 _webStateImpl, requestURL, transition); | 1539 _webStateImpl, requestURL, transition); |
1533 | 1540 |
1534 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); | 1541 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); |
1535 // TODO(crbug.com/676129): AddPendingItem does not always create a pending | 1542 // TODO(crbug.com/676129): AddPendingItem does not always create a pending |
1536 // item. Remove this workaround once the bug is fixed. | 1543 // item. Remove this workaround once the bug is fixed. |
1537 if (!item) { | 1544 if (!item) { |
1538 item = self.navigationManagerImpl->GetLastCommittedItem(); | 1545 item = self.navigationManagerImpl->GetLastCommittedItem(); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1981 [_containerView setAccessibilityIdentifier:@"Container View"]; | 1988 [_containerView setAccessibilityIdentifier:@"Container View"]; |
1982 | 1989 |
1983 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; | 1990 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; |
1984 // Is |currentUrl| a web scheme or native chrome scheme. | 1991 // Is |currentUrl| a web scheme or native chrome scheme. |
1985 web::NavigationItem* item = self.currentNavItem; | 1992 web::NavigationItem* item = self.currentNavItem; |
1986 const GURL currentNavigationURL = | 1993 const GURL currentNavigationURL = |
1987 item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1994 item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
1988 BOOL isChromeScheme = | 1995 BOOL isChromeScheme = |
1989 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); | 1996 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); |
1990 | 1997 |
1998 // Since this is implicit reload, no new pending item should be created, set | |
1999 // the pending item index to the last committed item. | |
2000 self.sessionController.pendingItemIndex = | |
2001 self.sessionController.lastCommittedItemIndex; | |
2002 | |
1991 // Don't immediately load the web page if in overlay mode. Always load if | 2003 // Don't immediately load the web page if in overlay mode. Always load if |
1992 // native. | 2004 // native. |
1993 if (isChromeScheme || !_overlayPreviewMode) { | 2005 if (isChromeScheme || !_overlayPreviewMode) { |
1994 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it | 2006 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it |
1995 // is possible there is no current URL. If the call performs necessary | 2007 // is possible there is no current URL. If the call performs necessary |
1996 // initialization, break that out. | 2008 // initialization, break that out. |
1997 [self loadCurrentURL]; | 2009 [self loadCurrentURL]; |
1998 } | 2010 } |
1999 | 2011 |
2000 // Display overlay view until current url has finished loading or delay and | 2012 // Display overlay view until current url has finished loading or delay and |
(...skipping 21 matching lines...) Expand all Loading... | |
2022 } | 2034 } |
2023 | 2035 |
2024 - (void)reload { | 2036 - (void)reload { |
2025 // Clear last user interaction. | 2037 // Clear last user interaction. |
2026 // TODO(crbug.com/546337): Move to after the load commits, in the subclass | 2038 // TODO(crbug.com/546337): Move to after the load commits, in the subclass |
2027 // implementation. This will be inaccurate if the reload fails or is | 2039 // implementation. This will be inaccurate if the reload fails or is |
2028 // cancelled. | 2040 // cancelled. |
2029 _lastUserInteraction.reset(); | 2041 _lastUserInteraction.reset(); |
2030 base::RecordAction(UserMetricsAction("Reload")); | 2042 base::RecordAction(UserMetricsAction("Reload")); |
2031 GURL url = self.currentNavItem->GetURL(); | 2043 GURL url = self.currentNavItem->GetURL(); |
2044 // Reloading shouldn't create create a new pending item, instead set the | |
2045 // pending item index to the last committed item. | |
2046 self.sessionController.pendingItemIndex = | |
Eugene But (OOO till 7-30)
2017/06/15 00:08:11
Wouldn't |reload| eventually call |registerLoadReq
mrefaat
2017/06/15 18:35:35
This will not happen in every case, only when the
Eugene But (OOO till 7-30)
2017/06/16 03:25:46
Thanks. So this code is needed to cover NativeCont
mrefaat
2017/06/16 19:28:04
This will happen in case the reload is triggered b
Eugene But (OOO till 7-30)
2017/06/17 02:57:14
But reload triggered by renderer calls |reload| as
mrefaat
2017/06/17 11:33:08
I'm not sure, from what i see it seems that goDelt
| |
2047 self.sessionController.lastCommittedItemIndex; | |
2032 if ([self shouldLoadURLInNativeView:url]) { | 2048 if ([self shouldLoadURLInNativeView:url]) { |
2033 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self | 2049 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self |
2034 registerLoadRequestForURL:url | 2050 registerLoadRequestForURL:url |
2035 referrer:self.currentNavItemReferrer | 2051 referrer:self.currentNavItemReferrer |
2036 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; | 2052 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; |
2037 [self didStartLoadingURL:url]; | 2053 [self didStartLoadingURL:url]; |
2038 [self.nativeController reload]; | 2054 [self.nativeController reload]; |
2039 _webStateImpl->OnNavigationFinished(navigationContext.get()); | 2055 _webStateImpl->OnNavigationFinished(navigationContext.get()); |
2040 [self loadCompleteWithSuccess:YES forNavigation:nil]; | 2056 [self loadCompleteWithSuccess:YES forNavigation:nil]; |
2041 } else { | 2057 } else { |
(...skipping 3190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5232 - (NSUInteger)observerCount { | 5248 - (NSUInteger)observerCount { |
5233 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5249 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
5234 return [_observers count]; | 5250 return [_observers count]; |
5235 } | 5251 } |
5236 | 5252 |
5237 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5253 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5238 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5254 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5239 } | 5255 } |
5240 | 5256 |
5241 @end | 5257 @end |
OLD | NEW |