Commit e5cb8497 authored by Filip Gorski's avatar Filip Gorski Committed by Commit Bot

[Zine] Fixing crash when SnippetsBridge is accessed after being destroyed

Replacing suggestion source with an empty suggestions source, once
SuggestionsUiDelegateImpl is destroyed.

Bug: 898078
Change-Id: Ic6f05da92e0c90f566275d4b9f0e1fb12afeb2a6
Reviewed-on: https://chromium-review.googlesource.com/c/1324611Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Filip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606264}
parent 920475bf
......@@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
import org.chromium.base.DiscardableReferencePool;
import org.chromium.chrome.browser.native_page.NativePageHost;
import org.chromium.chrome.browser.ntp.snippets.EmptySuggestionsSource;
import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.snackbar.SnackbarManager;
......@@ -20,7 +21,7 @@ import java.util.List;
*/
public class SuggestionsUiDelegateImpl implements SuggestionsUiDelegate {
private final List<DestructionObserver> mDestructionObservers = new ArrayList<>();
private final SuggestionsSource mSuggestionsSource;
private SuggestionsSource mSuggestionsSource;
private final SuggestionsRanker mSuggestionsRanker;
private final SuggestionsEventReporter mSuggestionsEventReporter;
private final SuggestionsNavigationDelegate mSuggestionsNavigationDelegate;
......@@ -107,6 +108,10 @@ public class SuggestionsUiDelegateImpl implements SuggestionsUiDelegate {
// while they are called.
mSuggestionsSource.destroy();
// Now replacing suggestions source with an empty one, which serves as a sentinel here.
// This prevents crashes when SnippetsBridge being access after being destroyed.
mSuggestionsSource = new EmptySuggestionsSource();
mIsDestroyed = true;
}
}
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