From 4f060a420004bfe078199ba5bdc92d88a107adf5 Mon Sep 17 00:00:00 2001 From: bridiver Date: Mon, 4 Feb 2019 10:12:44 -0700 Subject: [PATCH] ensure that `browser` is never null fix https://github.com/brave/brave-browser/issues/2970 --- components/brave_ads/browser/ads_service_impl.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/brave_ads/browser/ads_service_impl.cc b/components/brave_ads/browser/ads_service_impl.cc index d57436487d56..4660055f5d99 100644 --- a/components/brave_ads/browser/ads_service_impl.cc +++ b/components/brave_ads/browser/ads_service_impl.cc @@ -788,7 +788,10 @@ void AdsServiceImpl::OpenSettings(Profile* profile, #if defined(OS_ANDROID) NavigateParams nav_params(profile, url, ui::PAGE_TRANSITION_LINK); #else - Browser* browser = chrome::FindLastActiveWithProfile(profile); + Browser* browser = chrome::FindTabbedBrowser(profile, false); + if (!browser) + browser = new Browser(Browser::CreateParams(profile, true)); + NavigateParams nav_params(browser, url, ui::PAGE_TRANSITION_LINK); #endif nav_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;