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

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

Issue 2931833004: Always set the navigation pending item for page reload. (Closed)
Patch Set: move transietItem to different CL Created 3 years, 5 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 // A new session history entry needs to be created. 1523 // If this is a reload then there no need to create a new pending item,
1524 self.navigationManagerImpl->AddPendingItem( 1524 // instead update the pending item to the last committed item.
1525 requestURL, referrer, transition, 1525 if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD)) {
1526 web::NavigationInitiationType::RENDERER_INITIATED, 1526 self.sessionController.pendingItemIndex =
1527 web::NavigationManager::UserAgentOverrideOption::INHERIT); 1527 self.sessionController.lastCommittedItemIndex;
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 }
1528 } 1535 }
1529 std::unique_ptr<web::NavigationContextImpl> context = 1536 std::unique_ptr<web::NavigationContextImpl> context =
1530 web::NavigationContextImpl::CreateNavigationContext( 1537 web::NavigationContextImpl::CreateNavigationContext(
1531 _webStateImpl, requestURL, transition); 1538 _webStateImpl, requestURL, transition);
1532 1539
1533 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); 1540 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem();
1534 // TODO(crbug.com/676129): AddPendingItem does not always create a pending 1541 // TODO(crbug.com/676129): AddPendingItem does not always create a pending
1535 // item. Remove this workaround once the bug is fixed. 1542 // item. Remove this workaround once the bug is fixed.
1536 if (!item) { 1543 if (!item) {
1537 item = self.navigationManagerImpl->GetLastCommittedItem(); 1544 item = self.navigationManagerImpl->GetLastCommittedItem();
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 [_containerView setAccessibilityIdentifier:@"Container View"]; 1979 [_containerView setAccessibilityIdentifier:@"Container View"];
1973 1980
1974 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; 1981 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]];
1975 // Is |currentUrl| a web scheme or native chrome scheme. 1982 // Is |currentUrl| a web scheme or native chrome scheme.
1976 web::NavigationItem* item = self.currentNavItem; 1983 web::NavigationItem* item = self.currentNavItem;
1977 const GURL currentNavigationURL = 1984 const GURL currentNavigationURL =
1978 item ? item->GetVirtualURL() : GURL::EmptyGURL(); 1985 item ? item->GetVirtualURL() : GURL::EmptyGURL();
1979 BOOL isChromeScheme = 1986 BOOL isChromeScheme =
1980 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); 1987 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL);
1981 1988
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
1982 // Don't immediately load the web page if in overlay mode. Always load if 1994 // Don't immediately load the web page if in overlay mode. Always load if
1983 // native. 1995 // native.
1984 if (isChromeScheme || !_overlayPreviewMode) { 1996 if (isChromeScheme || !_overlayPreviewMode) {
1985 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it 1997 // TODO(jimblackler): end the practice of calling |loadCurrentURL| when it
1986 // is possible there is no current URL. If the call performs necessary 1998 // is possible there is no current URL. If the call performs necessary
1987 // initialization, break that out. 1999 // initialization, break that out.
1988 [self loadCurrentURL]; 2000 [self loadCurrentURL];
1989 } 2001 }
1990 2002
1991 // Display overlay view until current url has finished loading or delay and 2003 // Display overlay view until current url has finished loading or delay and
(...skipping 21 matching lines...) Expand all
2013 } 2025 }
2014 2026
2015 - (void)reload { 2027 - (void)reload {
2016 // Clear last user interaction. 2028 // Clear last user interaction.
2017 // TODO(crbug.com/546337): Move to after the load commits, in the subclass 2029 // TODO(crbug.com/546337): Move to after the load commits, in the subclass
2018 // implementation. This will be inaccurate if the reload fails or is 2030 // implementation. This will be inaccurate if the reload fails or is
2019 // cancelled. 2031 // cancelled.
2020 _lastUserInteraction.reset(); 2032 _lastUserInteraction.reset();
2021 base::RecordAction(UserMetricsAction("Reload")); 2033 base::RecordAction(UserMetricsAction("Reload"));
2022 GURL url = self.currentNavItem->GetURL(); 2034 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;
2023 if ([self shouldLoadURLInNativeView:url]) { 2039 if ([self shouldLoadURLInNativeView:url]) {
2024 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self 2040 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self
2025 registerLoadRequestForURL:url 2041 registerLoadRequestForURL:url
2026 referrer:self.currentNavItemReferrer 2042 referrer:self.currentNavItemReferrer
2027 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; 2043 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD];
2028 [self didStartLoadingURL:url]; 2044 [self didStartLoadingURL:url];
2029 [self.nativeController reload]; 2045 [self.nativeController reload];
2030 _webStateImpl->OnNavigationFinished(navigationContext.get()); 2046 _webStateImpl->OnNavigationFinished(navigationContext.get());
2031 [self loadCompleteWithSuccess:YES forNavigation:nil]; 2047 [self loadCompleteWithSuccess:YES forNavigation:nil];
2032 } else { 2048 } else {
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5257 - (NSUInteger)observerCount { 5273 - (NSUInteger)observerCount {
5258 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5274 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5259 return [_observers count]; 5275 return [_observers count];
5260 } 5276 }
5261 5277
5262 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5278 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5263 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5279 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5264 } 5280 }
5265 5281
5266 @end 5282 @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