Skip to content

Commit

Permalink
Merge pull request #10272 from /issues/18351-1.31.x
Browse files Browse the repository at this point in the history
Fixes custom ad notifications are not shown when system notification are disabled - 1.31.x
  • Loading branch information
kjozwiak authored Oct 8, 2021
2 parents 51306f4 + 9e3989c commit eba21c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
25 changes: 12 additions & 13 deletions components/brave_ads/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -105,6 +105,12 @@ bool IsAdNotificationsEnabled() {
return base::FeatureList::IsEnabled(kAdNotifications);
}

bool CanFallbackToCustomAdNotifications() {
return GetFieldTrialParamByFeatureAsBool(
kAdNotifications, kFieldTrialParameterCanFallbackToCustomAdNotifications,
kDefaultCanFallbackToCustomAdNotifications);
}

int AdNotificationTimeout() {
return GetFieldTrialParamByFeatureAsInt(
kAdNotifications, kFieldTrialParameterAdNotificationTimeout,
Expand All @@ -115,13 +121,6 @@ bool IsCustomAdNotificationsEnabled() {
return base::FeatureList::IsEnabled(kCustomAdNotifications);
}

bool CanFallbackToCustomAdNotifications() {
return GetFieldTrialParamByFeatureAsBool(
kCustomAdNotifications,
kFieldTrialParameterCanFallbackToCustomAdNotifications,
kDefaultCanFallbackToCustomAdNotifications);
}

#if !defined(OS_ANDROID)

int AdNotificationFadeDuration() {
Expand Down
3 changes: 1 addition & 2 deletions components/brave_ads/common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,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();
std::string AdNotificationDarkModeBackgroundColor();
Expand Down

0 comments on commit eba21c5

Please sign in to comment.