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

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

Issue 2881933003: Store NavigationItem's unique ID in navigation context. (Closed)
Patch Set: Created 3 years, 7 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_context_impl.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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 } else { 1525 } else {
1526 // A new session history entry needs to be created. 1526 // A new session history entry needs to be created.
1527 self.navigationManagerImpl->AddPendingItem( 1527 self.navigationManagerImpl->AddPendingItem(
1528 requestURL, referrer, transition, 1528 requestURL, referrer, transition,
1529 web::NavigationInitiationType::RENDERER_INITIATED, 1529 web::NavigationInitiationType::RENDERER_INITIATED,
1530 web::NavigationManager::UserAgentOverrideOption::INHERIT); 1530 web::NavigationManager::UserAgentOverrideOption::INHERIT);
1531 } 1531 }
1532 std::unique_ptr<web::NavigationContextImpl> context = 1532 std::unique_ptr<web::NavigationContextImpl> context =
1533 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, 1533 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl,
1534 requestURL); 1534 requestURL);
1535
1536 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem();
1537 // TODO(crbug.com/676129): AddPendingItem does not always create a pending
1538 // item. Remove this workaround once the bug is fixed.
1539 if (!item) {
1540 item = self.navigationManagerImpl->GetLastCommittedItem();
1541 }
1542 context->SetNavigationItemUniqueID(item->GetUniqueID());
1535 _webStateImpl->SetIsLoading(true); 1543 _webStateImpl->SetIsLoading(true);
1536 // TODO(crbug.com/713836): pass context to |OnProvisionalNavigationStarted|. 1544 // TODO(crbug.com/713836): pass context to |OnProvisionalNavigationStarted|.
1537 _webStateImpl->OnProvisionalNavigationStarted(requestURL); 1545 _webStateImpl->OnProvisionalNavigationStarted(requestURL);
1538 return context; 1546 return context;
1539 } 1547 }
1540 1548
1541 - (void)updateHTML5HistoryState { 1549 - (void)updateHTML5HistoryState {
1542 web::NavigationItemImpl* currentItem = self.currentNavItem; 1550 web::NavigationItemImpl* currentItem = self.currentNavItem;
1543 if (!currentItem) 1551 if (!currentItem)
1544 return; 1552 return;
(...skipping 3000 matching lines...) Expand 10 before | Expand all | Expand 10 after
4545 // In unit tests MIME type will be empty, because loadHTML:forURL: does not 4553 // In unit tests MIME type will be empty, because loadHTML:forURL: does not
4546 // notify web view delegate about received response, so web controller does 4554 // notify web view delegate about received response, so web controller does
4547 // not get a chance to properly update MIME type. 4555 // not get a chance to properly update MIME type.
4548 [_windowIDJSManager inject]; 4556 [_windowIDJSManager inject];
4549 } 4557 }
4550 4558
4551 if (isLastNavigation) { 4559 if (isLastNavigation) {
4552 [self webPageChanged]; 4560 [self webPageChanged];
4553 } else { 4561 } else {
4554 // WKWebView has more than one in progress navigation, and committed 4562 // WKWebView has more than one in progress navigation, and committed
4555 // navigation was not the latest. It is critical to keep last committed 4563 // navigation was not the latest. Change last committed item to one that
4556 // URL the same as actual document URL, so try guessing which navigation 4564 // corresponds to committed navigation.
4557 // item should be set to current. 4565 web::NavigationContextImpl* context =
4558 // TODO(crbug.com/712269): 4566 [_navigationStates contextForNavigation:navigation];
4559 for (int i = 0; i < self.navigationManagerImpl->GetItemCount(); i++) { 4567 for (int i = 0; i < self.navigationManagerImpl->GetItemCount(); i++) {
4560 web::NavigationItem* item = self.navigationManagerImpl->GetItemAtIndex(i); 4568 if (self.navigationManagerImpl->GetItemAtIndex(i)->GetUniqueID() ==
4561 if (item->GetURL() == _documentURL) { 4569 context->GetNavigationItemUniqueID()) {
4562 // Do not discard pending entry, because another pending navigation is 4570 // Do not discard pending entry, because another pending navigation is
4563 // still in progress and will commit or fail soon. 4571 // still in progress and will commit or fail soon.
4564 [self.sessionController goToItemAtIndex:i discardNonCommittedItems:NO]; 4572 [self.sessionController goToItemAtIndex:i discardNonCommittedItems:NO];
4573 break;
4565 } 4574 }
4566 } 4575 }
4567 } 4576 }
4568 4577
4569 web::NavigationContextImpl* context = 4578 web::NavigationContextImpl* context =
4570 [_navigationStates contextForNavigation:navigation]; 4579 [_navigationStates contextForNavigation:navigation];
4571 context->SetResponseHeaders(_webStateImpl->GetHttpResponseHeaders()); 4580 context->SetResponseHeaders(_webStateImpl->GetHttpResponseHeaders());
4572 self.webStateImpl->OnNavigationFinished(context); 4581 self.webStateImpl->OnNavigationFinished(context);
4573 4582
4574 [self updateSSLStatusForCurrentNavigationItem]; 4583 [self updateSSLStatusForCurrentNavigationItem];
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
5161 - (NSUInteger)observerCount { 5170 - (NSUInteger)observerCount {
5162 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5171 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5163 return [_observers count]; 5172 return [_observers count];
5164 } 5173 }
5165 5174
5166 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5175 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5167 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5176 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5168 } 5177 }
5169 5178
5170 @end 5179 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/navigation_context_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698