Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2998463002: Revert of Always set the navigation pending item for page reload. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/web_state/navigation_callbacks_inttest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 [self recordStateInHistory]; 1513 [self recordStateInHistory];
1514 } 1514 }
1515 1515
1516 [_delegate webWillAddPendingURL:requestURL transition:transition]; 1516 [_delegate webWillAddPendingURL:requestURL transition:transition];
1517 // Add or update pending url. 1517 // Add or update pending url.
1518 if (self.navigationManagerImpl->GetPendingItem()) { 1518 if (self.navigationManagerImpl->GetPendingItem()) {
1519 // Update the existing pending entry. 1519 // Update the existing pending entry.
1520 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. 1520 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT.
1521 [[self sessionController] updatePendingItem:requestURL]; 1521 [[self sessionController] updatePendingItem:requestURL];
1522 } else { 1522 } else {
1523 // If this is a reload then there no need to create a new pending item, 1523 // A new session history entry needs to be created.
1524 // instead update the pending item to the last committed item. 1524 self.navigationManagerImpl->AddPendingItem(
1525 if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD)) { 1525 requestURL, referrer, transition,
1526 self.sessionController.pendingItemIndex = 1526 web::NavigationInitiationType::RENDERER_INITIATED,
1527 self.sessionController.lastCommittedItemIndex; 1527 web::NavigationManager::UserAgentOverrideOption::INHERIT);
1528 } else {
1529 // A new session history entry needs to be created.
1530 self.navigationManagerImpl->AddPendingItem(
1531 requestURL, referrer, transition,
1532 web::NavigationInitiationType::RENDERER_INITIATED,
1533 web::NavigationManager::UserAgentOverrideOption::INHERIT);
1534 }
1535 } 1528 }
1536 std::unique_ptr<web::NavigationContextImpl> context = 1529 std::unique_ptr<web::NavigationContextImpl> context =
1537 web::NavigationContextImpl::CreateNavigationContext( 1530 web::NavigationContextImpl::CreateNavigationContext(
1538 _webStateImpl, requestURL, transition); 1531 _webStateImpl, requestURL, transition);
1539 1532
1540 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); 1533 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem();
1541 // TODO(crbug.com/676129): AddPendingItem does not always create a pending 1534 // TODO(crbug.com/676129): AddPendingItem does not always create a pending
1542 // item. Remove this workaround once the bug is fixed. 1535 // item. Remove this workaround once the bug is fixed.
1543 if (!item) { 1536 if (!item) {
1544 item = self.navigationManagerImpl->GetLastCommittedItem(); 1537 item = self.navigationManagerImpl->GetLastCommittedItem();
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 [_containerView setAccessibilityIdentifier:@"Container View"]; 1972 [_containerView setAccessibilityIdentifier:@"Container View"];
1980 1973
1981 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; 1974 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]];
1982 // Is |currentUrl| a web scheme or native chrome scheme. 1975 // Is |currentUrl| a web scheme or native chrome scheme.
1983 web::NavigationItem* item = self.currentNavItem; 1976 web::NavigationItem* item = self.currentNavItem;
1984 const GURL currentNavigationURL = 1977 const GURL currentNavigationURL =
1985 item ? item->GetVirtualURL() : GURL::EmptyGURL(); 1978 item ? item->GetVirtualURL() : GURL::EmptyGURL();
1986 BOOL isChromeScheme = 1979 BOOL isChromeScheme =
1987 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); 1980 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL);
1988 1981
1989 // Since this is implicit reload, no new pending item should be created, set
1990 // the pending item index to the last committed item.
1991 self.sessionController.pendingItemIndex =
1992 self.sessionController.lastCommittedItemIndex;
1993
1994 // Don't immediately load the web page if in overlay mode. Always load if 1982 // Don't immediately load the web page if in overlay mode. Always load if
1995 // native. 1983 // native.
1996 if (isChromeScheme || !_overlayPreviewMode) { 1984 if (isChromeScheme || !_overlayPreviewMode) {
1997 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it 1985 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it
1998 // is possible there is no current URL. If the call performs necessary 1986 // is possible there is no current URL. If the call performs necessary
1999 // initialization, break that out. 1987 // initialization, break that out.
2000 [self loadCurrentURL]; 1988 [self loadCurrentURL];
2001 } 1989 }
2002 1990
2003 // Display overlay view until current url has finished loading or delay and 1991 // Display overlay view until current url has finished loading or delay and
(...skipping 21 matching lines...) Expand all
2025 } 2013 }
2026 2014
2027 - (void)reload { 2015 - (void)reload {
2028 // Clear last user interaction. 2016 // Clear last user interaction.
2029 // TODO(crbug.com/546337): Move to after the load commits, in the subclass 2017 // TODO(crbug.com/546337): Move to after the load commits, in the subclass
2030 // implementation. This will be inaccurate if the reload fails or is 2018 // implementation. This will be inaccurate if the reload fails or is
2031 // cancelled. 2019 // cancelled.
2032 _lastUserInteraction.reset(); 2020 _lastUserInteraction.reset();
2033 base::RecordAction(UserMetricsAction("Reload")); 2021 base::RecordAction(UserMetricsAction("Reload"));
2034 GURL url = self.currentNavItem->GetURL(); 2022 GURL url = self.currentNavItem->GetURL();
2035 // Reloading shouldn't create create a new pending item, instead set the
2036 // pending item index to the last committed item.
2037 self.sessionController.pendingItemIndex =
2038 self.sessionController.lastCommittedItemIndex;
2039 if ([self shouldLoadURLInNativeView:url]) { 2023 if ([self shouldLoadURLInNativeView:url]) {
2040 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self 2024 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self
2041 registerLoadRequestForURL:url 2025 registerLoadRequestForURL:url
2042 referrer:self.currentNavItemReferrer 2026 referrer:self.currentNavItemReferrer
2043 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; 2027 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD];
2044 [self didStartLoadingURL:url]; 2028 [self didStartLoadingURL:url];
2045 [self.nativeController reload]; 2029 [self.nativeController reload];
2046 _webStateImpl->OnNavigationFinished(navigationContext.get()); 2030 _webStateImpl->OnNavigationFinished(navigationContext.get());
2047 [self loadCompleteWithSuccess:YES forNavigation:nil]; 2031 [self loadCompleteWithSuccess:YES forNavigation:nil];
2048 } else { 2032 } else {
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5273 - (NSUInteger)observerCount { 5257 - (NSUInteger)observerCount {
5274 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5258 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5275 return [_observers count]; 5259 return [_observers count];
5276 } 5260 }
5277 5261
5278 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5262 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5279 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5263 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5280 } 5264 }
5281 5265
5282 @end 5266 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/navigation_callbacks_inttest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698