Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes custom ad notifications are not shown when system notifications are disabled - 1.30.x #10273

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -99,6 +99,12 @@ bool IsAdNotificationsEnabled() {
return base::FeatureList::IsEnabled(kAdNotifications);
}

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

int AdNotificationTimeout() {
return GetFieldTrialParamByFeatureAsInt(
kAdNotifications, kFieldTrialParameterAdNotificationTimeout,
Expand All @@ -109,13 +115,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 @@ -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();
Expand Down