Commit 1148eb01 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[IOS] Fixes the translate infobar crash

The reason for the crash was that BeforeTranslateInfoBarController calls
TranslateInfoBarDelegate::ShowNeverTranslateInfobar() in order to show the
"never translate infobar which expects the existing translate infobar to be
owned by an instance of InfoBarManager. However InfoBarManagerImpl's lifetime
is tied to the WebState and it may be destroyed due to navigation.

Bug: 867097
Change-Id: Ibf4f6ad15971897a2ac844fa602f961748ec848e
Reviewed-on: https://chromium-review.googlesource.com/1151618Reviewed-by: default avatarRachel Blum <groby@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578414}
parent 556bdc54
...@@ -275,6 +275,10 @@ bool TranslateInfoBarDelegate::ShouldShowNeverTranslateShortcut() { ...@@ -275,6 +275,10 @@ bool TranslateInfoBarDelegate::ShouldShowNeverTranslateShortcut() {
#if defined(OS_IOS) #if defined(OS_IOS)
void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() { void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() {
// Return if the infobar is not owned.
if (!infobar()->owner())
return;
Create(true, translate_manager_, infobar()->owner(), is_off_the_record_, Create(true, translate_manager_, infobar()->owner(), is_off_the_record_,
translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(), translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(),
target_language_code(), TranslateErrors::NONE, false); target_language_code(), TranslateErrors::NONE, false);
......
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