| 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 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 BOOL sameDocumentNavigation = [sessionController | 2157 BOOL sameDocumentNavigation = [sessionController |
| 2158 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem | 2158 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem |
| 2159 andItem:toEntry.navigationItem]; | 2159 andItem:toEntry.navigationItem]; |
| 2160 if (sameDocumentNavigation) { | 2160 if (sameDocumentNavigation) { |
| 2161 [self.sessionController goToItemAtIndex:index]; | 2161 [self.sessionController goToItemAtIndex:index]; |
| 2162 // TODO(crbug.com/684098): move this call out this block to avoid code | 2162 // TODO(crbug.com/684098): move this call out this block to avoid code |
| 2163 // duplication. | 2163 // duplication. |
| 2164 [self webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2164 [self webWillFinishHistoryNavigationFromEntry:fromEntry]; |
| 2165 [self updateHTML5HistoryState]; | 2165 [self updateHTML5HistoryState]; |
| 2166 } else { | 2166 } else { |
| 2167 // TODO(crbug.com/691492): After discardNonCommittedItems, the item |
| 2168 // pointed by |fromEntry| may not be valid anymore. |
| 2169 // Set |fromEntry| to nil to avoid crash whan using the item. |
| 2170 // Remove when the fix is not needed anymore. |
| 2171 if ([fromEntry isEqual:sessionController.transientEntry] || |
| 2172 [fromEntry isEqual:sessionController.pendingEntry]) { |
| 2173 fromEntry = nil; |
| 2174 } |
| 2167 [sessionController discardNonCommittedItems]; | 2175 [sessionController discardNonCommittedItems]; |
| 2168 [sessionController setPendingItemIndex:index]; | 2176 [sessionController setPendingItemIndex:index]; |
| 2169 | 2177 |
| 2170 // TODO(crbug.com/684098): move this call out this block to avoid code | 2178 // TODO(crbug.com/684098): move this call out this block to avoid code |
| 2171 // duplication. | 2179 // duplication. |
| 2172 [self webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2180 [self webWillFinishHistoryNavigationFromEntry:fromEntry]; |
| 2173 | 2181 |
| 2174 web::NavigationItemImpl* pendingItem = | 2182 web::NavigationItemImpl* pendingItem = |
| 2175 sessionController.pendingEntry.navigationItemImpl; | 2183 sessionController.pendingEntry.navigationItemImpl; |
| 2176 pendingItem->SetTransitionType(ui::PageTransitionFromInt( | 2184 pendingItem->SetTransitionType(ui::PageTransitionFromInt( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 } | 2402 } |
| 2395 }; | 2403 }; |
| 2396 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 2404 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
| 2397 _passKitDownloader.reset([[CRWPassKitDownloader alloc] | 2405 _passKitDownloader.reset([[CRWPassKitDownloader alloc] |
| 2398 initWithContextGetter:browserState->GetRequestContext() | 2406 initWithContextGetter:browserState->GetRequestContext() |
| 2399 completionHandler:passKitCompletion]); | 2407 completionHandler:passKitCompletion]); |
| 2400 return _passKitDownloader.get(); | 2408 return _passKitDownloader.get(); |
| 2401 } | 2409 } |
| 2402 | 2410 |
| 2403 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 2411 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 2404 DCHECK(fromEntry); | 2412 // TODO(crbug.com/691492): Removing the DCHECK as |fromEntry| may be nil if |
| 2413 // the pending entry was discarded. |
| 2414 // Remove when the fix is not needed anymore. |
| 2415 // DCHECK(fromEntry); |
| 2405 [self updateDesktopUserAgentForEntry:self.currentSessionEntry | 2416 [self updateDesktopUserAgentForEntry:self.currentSessionEntry |
| 2406 fromEntry:fromEntry]; | 2417 fromEntry:fromEntry]; |
| 2407 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2418 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; |
| 2408 } | 2419 } |
| 2409 | 2420 |
| 2410 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry | 2421 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry |
| 2411 fromEntry:(CRWSessionEntry*)fromEntry { | 2422 fromEntry:(CRWSessionEntry*)fromEntry { |
| 2412 web::NavigationItemImpl* item = entry.navigationItemImpl; | 2423 web::NavigationItemImpl* item = entry.navigationItemImpl; |
| 2413 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; | 2424 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; |
| 2414 if (!item || !fromItem) | 2425 if (!item || !fromItem) |
| (...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5314 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5325 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5315 _lastRegisteredRequestURL = URL; | 5326 _lastRegisteredRequestURL = URL; |
| 5316 _loadPhase = web::LOAD_REQUESTED; | 5327 _loadPhase = web::LOAD_REQUESTED; |
| 5317 } | 5328 } |
| 5318 | 5329 |
| 5319 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5330 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5320 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5331 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5321 } | 5332 } |
| 5322 | 5333 |
| 5323 @end | 5334 @end |
| OLD | NEW |