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

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 1353503003: Always set the serialized state object for history navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 2bdc779a02dbebffe5213ae641014c96133b87ea..620d34c013fbcb81ebd526b843ed1cf361387b8c 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1266,8 +1266,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
base::SysUTF8ToNSString(outURL), stateObject];
}
-- (void)finishPushStateNavigationToURL:(const GURL&)url
- withStateObject:(NSString*)stateObject {
+- (void)setPushedOrReplacedURL:(const GURL&)url
+ stateObject:(NSString*)stateObject {
// TODO(stuartmorgan): Make CRWSessionController manage this internally (or
// remove it; it's not clear this matches other platforms' behavior).
_webStateImpl->GetNavigationManagerImpl().OnNavigationItemCommitted();
@@ -1763,17 +1763,18 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
- (void)finishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
[_delegate webWillFinishHistoryNavigationFromEntry:fromEntry];
- // Check if toEntry was created by a JavaScript window.history.pushState()
- // call from fromEntry. If it was, don't load the URL. Instead update
- // UIWebView's URL and dispatch a popstate event.
- if ([_webStateImpl->GetNavigationManagerImpl().GetSessionController()
+ // If the current entry has a serialized state object, inject its state into
+ // the web view.
+ web::NavigationItemImpl* currentItem =
+ self.currentSessionEntry.navigationItemImpl;
+ NSString* state = currentItem->GetSerializedStateObject();
+ if (state.length)
+ [self setPushedOrReplacedURL:currentItem->GetURL() stateObject:state];
+ // Only load the new URL if the current entry was not created by a JavaScript
+ // window.history.pushState() call from |fromEntry|.
+ if (![_webStateImpl->GetNavigationManagerImpl().GetSessionController()
isPushStateNavigationBetweenEntry:fromEntry
andEntry:self.currentSessionEntry]) {
- NSString* state = [self currentSessionEntry]
- .navigationItemImpl->GetSerializedStateObject();
- [self finishPushStateNavigationToURL:[self currentNavigationURL]
- withStateObject:state];
- } else {
web::NavigationItem* currentItem =
_webStateImpl->GetNavigationManagerImpl().GetVisibleItem();
GURL endURL = [self URLForHistoryNavigationFromItem:fromEntry.navigationItem
« ios/web/web_state/ui/crw_web_controller.h ('K') | « ios/web/web_state/ui/crw_web_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698