Commit 098a07e4 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Defend against nil WebState instead of DCHECKing.

If a Tab is leaked, it's possible for BVC's URLLoadingObserver callbacks
to be triggered after the Tab's corresponding WebState has been
destroyed.  This CL updates that implementation to prevent crashes if
this occurs.

Bug: 925757
Change-Id: Id47321d2555605e1c1634080c7601b4d0f0b969d
Reviewed-on: https://chromium-review.googlesource.com/c/1448686
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628449}
parent 8bce54f1
...@@ -3395,8 +3395,8 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -3395,8 +3395,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
WebStateList* webStateList = self.tabModel.webStateList; WebStateList* webStateList = self.tabModel.webStateList;
web::WebState* current_web_state = webStateList->GetActiveWebState(); web::WebState* current_web_state = webStateList->GetActiveWebState();
DCHECK(current_web_state); if (current_web_state &&
if (transitionType & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) { (transitionType & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)) {
bool isExpectingVoiceSearch = bool isExpectingVoiceSearch =
VoiceSearchNavigationTabHelper::FromWebState(current_web_state) VoiceSearchNavigationTabHelper::FromWebState(current_web_state)
->IsExpectingVoiceSearch(); ->IsExpectingVoiceSearch();
......
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