Commit 8915d507 authored by stuartmorgan's avatar stuartmorgan Committed by Commit bot

Ignore title changes from WKWebView when the web process dies

WKWebView sets the title to blank when the web process dies; ignore that
update so that the navigation item won't end up with a blank title.

BUG=558178

Review URL: https://codereview.chromium.org/1461413004

Cr-Commit-Position: refs/heads/master@{#361214}
parent 708e3609
...@@ -212,6 +212,9 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { ...@@ -212,6 +212,9 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
// YES if the user has interacted with the content area since the last URL // YES if the user has interacted with the content area since the last URL
// change. // change.
BOOL _interactionRegisteredSinceLastURLChange; BOOL _interactionRegisteredSinceLastURLChange;
// YES if the web process backing _wkWebView is believed to currently be dead.
BOOL _webProcessIsDead;
} }
// Dictionary where keys are the names of WKWebView properties and values are // Dictionary where keys are the names of WKWebView properties and values are
...@@ -878,6 +881,7 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { ...@@ -878,6 +881,7 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
} }
- (void)webViewWebProcessDidCrash { - (void)webViewWebProcessDidCrash {
_webProcessIsDead = YES;
if ([self.delegate respondsToSelector: if ([self.delegate respondsToSelector:
@selector(webControllerWebProcessDidCrash:)]) { @selector(webControllerWebProcessDidCrash:)]) {
[self.delegate webControllerWebProcessDidCrash:self]; [self.delegate webControllerWebProcessDidCrash:self];
...@@ -1469,6 +1473,13 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { ...@@ -1469,6 +1473,13 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
} }
- (void)webViewTitleDidChange { - (void)webViewTitleDidChange {
// WKWebView's title becomes empty when the web process dies; ignore that
// update.
if (_webProcessIsDead) {
DCHECK_EQ(self.title.length, 0U);
return;
}
if ([self.delegate respondsToSelector: if ([self.delegate respondsToSelector:
@selector(webController:titleDidChange:)]) { @selector(webController:titleDidChange:)]) {
DCHECK(self.title); DCHECK(self.title);
...@@ -1541,6 +1552,7 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { ...@@ -1541,6 +1552,7 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler: decisionHandler:
(void (^)(WKNavigationActionPolicy))decisionHandler { (void (^)(WKNavigationActionPolicy))decisionHandler {
_webProcessIsDead = NO;
if (self.isBeingDestroyed) { if (self.isBeingDestroyed) {
decisionHandler(WKNavigationActionPolicyCancel); decisionHandler(WKNavigationActionPolicyCancel);
return; return;
......
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