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

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

Issue 2950853002: Gracefully handle didCommitNavigation: call after didFinishNavigation: (Closed)
Patch Set: Created 3 years, 6 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 49e05b2de8f502e2749c905d6061bec48b62bf71..f0cd6cea6d037fdbbe61c7ceba402c4dabaa84fa 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -4538,6 +4538,9 @@ registerLoadRequestForURL:(const GURL&)requestURL
didCommitNavigation:(WKNavigation*)navigation {
[self displayWebView];
+ bool navigationFinished = [_navigationStates stateForNavigation:navigation] ==
+ web::WKNavigationState::FINISHED;
+
// Record the navigation state.
[_navigationStates setState:web::WKNavigationState::COMMITTED
forNavigation:navigation];
@@ -4629,10 +4632,21 @@ registerLoadRequestForURL:(const GURL&)requestURL
UMA_HISTOGRAM_BOOLEAN("WebController.WKWebViewHasCertForSecureConnection",
static_cast<bool>(cert));
}
+
+ if (navigationFinished) {
+ // webView:didFinishNavigation: was called before
+ // webView:didCommitNavigation:, so remove the navigation now and signal
+ // that navigation was finished.
+ [_navigationStates removeNavigation:navigation];
+ [self didFinishNavigation:navigation];
+ }
}
- (void)webView:(WKWebView*)webView
didFinishNavigation:(WKNavigation*)navigation {
+ bool navigationCommitted =
kkhorimoto 2017/06/22 00:49:01 Should we just early return if the navigation isn'
Eugene But (OOO till 7-30) 2017/06/22 01:58:06 There is no change in NavigationItemCommitted/DidF
kkhorimoto 2017/06/22 02:09:48 whoops, I thought that the WSO didFinishNavigation
+ [_navigationStates stateForNavigation:navigation] ==
+ web::WKNavigationState::COMMITTED;
[_navigationStates setState:web::WKNavigationState::FINISHED
forNavigation:navigation];
@@ -4643,7 +4657,12 @@ registerLoadRequestForURL:(const GURL&)requestURL
// appropriate time rather than invoking here.
web::ExecuteJavaScript(webView, @"__gCrWeb.didFinishNavigation()", nil);
kkhorimoto 2017/06/22 00:49:02 What does it mean to execute JS on a page when the
Eugene But (OOO till 7-30) 2017/06/22 01:58:06 This fetches favicons, which still should work and
[self didFinishNavigation:navigation];
- [_navigationStates removeNavigation:navigation];
+
+ // Remove navigation only if it has been committed. Otherwise it will be
+ // removed in webView:didCommitNavigation: callback.
+ if (navigationCommitted) {
+ [_navigationStates removeNavigation:navigation];
+ }
}
- (void)webView:(WKWebView*)webView
« no previous file with comments | « no previous file | ios/web/web_state/ui/crw_wk_navigation_states.h » ('j') | ios/web/web_state/ui/crw_wk_navigation_states.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698