Commit c2678879 authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[ios] Finally remove _lastRegisteredRequestURL.

This is part 5 and final part for removing _lastRegisteredRequestURL
from CRWWebController.

Bug: 789993,792515
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I5707ff5ddbe61b3a2cfec76d667297753ef0c86f
Reviewed-on: https://chromium-review.googlesource.com/812489
Commit-Queue: Danyao Wang <danyao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522487}
parent d107dce6
...@@ -289,9 +289,6 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { ...@@ -289,9 +289,6 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) {
// TODO(crbug.com/549616): Remove this in favor of just updating the // TODO(crbug.com/549616): Remove this in favor of just updating the
// navigation manager and treating that as authoritative. // navigation manager and treating that as authoritative.
GURL _documentURL; GURL _documentURL;
// Last URL change reported to webWill/DidStartLoadingURL. Used to detect page
// location changes (client redirects) in practice.
GURL _lastRegisteredRequestURL;
// Page loading phase. // Page loading phase.
web::LoadPhase _loadPhase; web::LoadPhase _loadPhase;
// The web::PageDisplayState recorded when the page starts loading. // The web::PageDisplayState recorded when the page starts loading.
...@@ -1391,7 +1388,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1391,7 +1388,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
} }
_loadPhase = web::LOAD_REQUESTED; _loadPhase = web::LOAD_REQUESTED;
_lastRegisteredRequestURL = requestURL;
if (!redirect) { if (!redirect) {
if (!self.nativeController) { if (!self.nativeController) {
...@@ -1554,21 +1550,7 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1554,21 +1550,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
[script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL [script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL
newURL:URL]]; newURL:URL]];
} }
__weak CRWWebController* weakSelf = self; [self executeJavaScript:script completionHandler:nil];
[self executeJavaScript:script
completionHandler:^(id, NSError*) {
CRWWebController* strongSelf = weakSelf;
if (strongSelf &&
!strongSelf->_isBeingDestroyed
// Make sure that no new navigation has started since URL value
// was captured to avoid clobbering _lastRegisteredRequestURL.
// See crbug.com/788231.
// TODO(crbug.com/788465): simplify history state handling to
// avoid this hack.
&& currentItem == self.currentNavItem) {
strongSelf->_lastRegisteredRequestURL = URL;
}
}];
} }
// Load the current URL in a web view, first ensuring the web view is visible. // Load the current URL in a web view, first ensuring the web view is visible.
...@@ -2587,7 +2569,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -2587,7 +2569,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
return NO; return NO;
} }
NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON);
_lastRegisteredRequestURL = pushURL;
// If the user interacted with the page, categorize it as a link navigation. // If the user interacted with the page, categorize it as a link navigation.
// If not, categorize it is a client redirect as it occurred without user // If not, categorize it is a client redirect as it occurred without user
...@@ -2654,7 +2635,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -2654,7 +2635,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
return NO; return NO;
} }
NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON);
_lastRegisteredRequestURL = replaceURL;
[self replaceStateWithPageURL:replaceURL stateObject:stateObject]; [self replaceStateWithPageURL:replaceURL stateObject:stateObject];
NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL
stateObjectJSON:stateObject]; stateObjectJSON:stateObject];
...@@ -4373,8 +4353,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -4373,8 +4353,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
item->SetVirtualURL(webViewURL); item->SetVirtualURL(webViewURL);
item->SetURL(webViewURL); item->SetURL(webViewURL);
} }
_lastRegisteredRequestURL = webViewURL;
} }
_webStateImpl->OnNavigationStarted(context); _webStateImpl->OnNavigationStarted(context);
return; return;
...@@ -5264,7 +5242,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -5264,7 +5242,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
- (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView {
[self removeWebView]; [self removeWebView];
_lastRegisteredRequestURL = _defaultURL;
[_containerView displayWebViewContentView:webViewContentView]; [_containerView displayWebViewContentView:webViewContentView];
[self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment