[Android] Fixes a crash inside ReturnToChromeUtil.showHomeSurfaceUiOnNtp when HomeSurfaceTracker object is null. (#33408)

[Android] Fixes a crash inside ReturnToChromeUtil.showHomeSurfaceUiOnNtp
when HomeSurfaceTracker object is null.

Resolves: https://github.com/brave/brave-browser/issues/52283
This commit is contained in:
Serg
2026-01-26 19:13:05 +00:00
committed by GitHub
parent 7f7cc97c09
commit 49c34d0a46
4 changed files with 28 additions and 0 deletions
@@ -143,4 +143,17 @@ public final class BraveReturnToChromeUtil {
return ReturnToChromeUtil.createNewTabAndShowHomeSurfaceUi(
tabCreator, homeSurfaceTracker, tabModelSelector, lastActiveTabUrl, lastActiveTab);
}
/**
* Shows the home surface UI on the given NTP. This is a wrapper around the upstream method that
* adds a null check for homeSurfaceTracker to prevent crashes when the tracker is not
* initialized.
*/
static void showHomeSurfaceUiOnNtp(
Tab ntpTab, Tab lastActiveTab, @Nullable HomeSurfaceTracker homeSurfaceTracker) {
if (homeSurfaceTracker == null) {
return;
}
ReturnToChromeUtil.showHomeSurfaceUiOnNtp(ntpTab, lastActiveTab, homeSurfaceTracker);
}
}