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

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

Issue 2728723002: Cleaned up code duplication in -[CRWWebController goToItemAtIndex:]. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | 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 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 } 2126 }
2127 2127
2128 if (!_webStateImpl->IsShowingWebInterstitial()) 2128 if (!_webStateImpl->IsShowingWebInterstitial())
2129 [self recordStateInHistory]; 2129 [self recordStateInHistory];
2130 CRWSessionEntry* fromEntry = sessionController.currentEntry; 2130 CRWSessionEntry* fromEntry = sessionController.currentEntry;
2131 CRWSessionEntry* toEntry = entries[index]; 2131 CRWSessionEntry* toEntry = entries[index];
2132 2132
2133 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; 2133 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
2134 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { 2134 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) {
2135 [self clearTransientContentView]; 2135 [self clearTransientContentView];
2136 [self updateDesktopUserAgentForEntry:toEntry fromEntry:fromEntry];
2136 2137
2137 BOOL sameDocumentNavigation = [sessionController 2138 BOOL sameDocumentNavigation = [sessionController
2138 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem 2139 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem
2139 andItem:toEntry.navigationItem]; 2140 andItem:toEntry.navigationItem];
2140 if (sameDocumentNavigation) { 2141 if (sameDocumentNavigation) {
2141 [self.sessionController goToItemAtIndex:index]; 2142 [sessionController goToItemAtIndex:index];
2142 // TODO(crbug.com/684098): move this call out this block to avoid code
2143 // duplication.
2144 [self webWillFinishHistoryNavigationFromEntry:fromEntry];
2145 [self updateHTML5HistoryState]; 2143 [self updateHTML5HistoryState];
2146 } else { 2144 } else {
2147 [sessionController discardNonCommittedItems]; 2145 [sessionController discardNonCommittedItems];
2148 [sessionController setPendingItemIndex:index]; 2146 [sessionController setPendingItemIndex:index];
2149 2147
2150 // TODO(crbug.com/684098): move this call out this block to avoid code
2151 // duplication.
2152 [self webWillFinishHistoryNavigationFromEntry:fromEntry];
2153
2154 web::NavigationItemImpl* pendingItem = 2148 web::NavigationItemImpl* pendingItem =
2155 sessionController.pendingEntry.navigationItemImpl; 2149 sessionController.pendingEntry.navigationItemImpl;
2156 pendingItem->SetTransitionType(ui::PageTransitionFromInt( 2150 pendingItem->SetTransitionType(ui::PageTransitionFromInt(
2157 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK)); 2151 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK));
2158 2152
2159 [self loadCurrentURL]; 2153 [self loadCurrentURL];
2160 } 2154 }
2161 } else { 2155 } else {
2162 [self.sessionController goToItemAtIndex:index]; 2156 [sessionController goToItemAtIndex:index];
2163 if (fromEntry) 2157 if (fromEntry)
2164 [self finishHistoryNavigationFromEntry:fromEntry]; 2158 [self finishHistoryNavigationFromEntry:fromEntry];
2165 } 2159 }
2166 } 2160 }
2167 2161
2168 - (BOOL)isLoaded { 2162 - (BOOL)isLoaded {
2169 return _loadPhase == web::PAGE_LOADED; 2163 return _loadPhase == web::PAGE_LOADED;
2170 } 2164 }
2171 2165
2172 - (void)didFinishNavigation { 2166 - (void)didFinishNavigation {
(...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5220 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5227 _lastRegisteredRequestURL = URL; 5221 _lastRegisteredRequestURL = URL;
5228 _loadPhase = web::LOAD_REQUESTED; 5222 _loadPhase = web::LOAD_REQUESTED;
5229 } 5223 }
5230 5224
5231 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5225 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5232 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5226 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5233 } 5227 }
5234 5228
5235 @end 5229 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698