From 4f28be249c46e95cf33d7fea1f9db8abbb8e4dbf Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Fri, 24 Sep 2021 16:39:59 -0500 Subject: [PATCH] Fixes custom ad notifications are not shown when system notifications are disabled --- components/brave_ads/common/features.cc | 25 ++++++++++++------------- components/brave_ads/common/features.h | 3 +-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/components/brave_ads/common/features.cc b/components/brave_ads/common/features.cc index de0193b57eaf..69b1feb7701f 100644 --- a/components/brave_ads/common/features.cc +++ b/components/brave_ads/common/features.cc @@ -18,6 +18,12 @@ const base::Feature kCustomAdNotifications{"CustomAdNotifications", namespace { +// Set to true to fallback to custom ad notifications if native notifications +// are disabled or false to never fallback +const char kFieldTrialParameterCanFallbackToCustomAdNotifications[] = + "can_fallback_to_custom_notifications"; +const bool kDefaultCanFallbackToCustomAdNotifications = false; + // Ad notification timeout in seconds. Set to 0 to never time out const char kFieldTrialParameterAdNotificationTimeout[] = "ad_notification_timeout"; @@ -27,12 +33,6 @@ const int kDefaultAdNotificationTimeout = 120; const int kDefaultAdNotificationTimeout = 30; #endif -// Set to true to fallback from native to custom ad notifications or false to -// never fallback -const char kFieldTrialParameterCanFallbackToCustomAdNotifications[] = - "can_fallback_to_custom_notifications"; -const bool kDefaultCanFallbackToCustomAdNotifications = false; - #if !defined(OS_ANDROID) // Ad notification fade animation duration in milliseconds @@ -99,6 +99,12 @@ bool IsAdNotificationsEnabled() { return base::FeatureList::IsEnabled(kAdNotifications); } +bool CanFallbackToCustomAdNotifications() { + return GetFieldTrialParamByFeatureAsBool( + kAdNotifications, kFieldTrialParameterCanFallbackToCustomAdNotifications, + kDefaultCanFallbackToCustomAdNotifications); +} + int AdNotificationTimeout() { return GetFieldTrialParamByFeatureAsInt( kAdNotifications, kFieldTrialParameterAdNotificationTimeout, @@ -109,13 +115,6 @@ bool IsCustomAdNotificationsEnabled() { return base::FeatureList::IsEnabled(kCustomAdNotifications); } -bool CanFallbackToCustomAdNotifications() { - return GetFieldTrialParamByFeatureAsBool( - kCustomAdNotifications, - kFieldTrialParameterCanFallbackToCustomAdNotifications, - kDefaultCanFallbackToCustomAdNotifications); -} - #if !defined(OS_ANDROID) int AdNotificationFadeDuration() { diff --git a/components/brave_ads/common/features.h b/components/brave_ads/common/features.h index 207c95b19d2a..986ad16bf6b2 100644 --- a/components/brave_ads/common/features.h +++ b/components/brave_ads/common/features.h @@ -18,13 +18,12 @@ namespace features { extern const base::Feature kAdNotifications; bool IsAdNotificationsEnabled(); +bool CanFallbackToCustomAdNotifications(); int AdNotificationTimeout(); extern const base::Feature kCustomAdNotifications; bool IsCustomAdNotificationsEnabled(); - -bool CanFallbackToCustomAdNotifications(); #if !defined(OS_ANDROID) int AdNotificationFadeDuration(); double AdNotificationNormalizedDisplayCoordinateX();