Skip to content

Commit

Permalink
Add Brave Ads features to brave://flags (disabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Jun 6, 2023
1 parent ee647fb commit b0654eb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
41 changes: 40 additions & 1 deletion browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "brave/browser/ethereum_remote_client/buildflags/buildflags.h"
#include "brave/browser/ethereum_remote_client/features.h"
#include "brave/browser/ui/tabs/features.h"
#include "brave/components/brave_ads/common/brave_ads_feature.h"
#include "brave/components/brave_ads/common/custom_notification_ad_feature.h"
#include "brave/components/brave_ads/common/notification_ad_feature.h"
#include "brave/components/brave_component_updater/browser/features.h"
Expand Down Expand Up @@ -682,6 +683,45 @@
FEATURE_VALUE_TYPE(brave_rewards::features:: \
kAllowUnsupportedWalletProvidersFeature), \
}, \
{ \
"brave-ads-should-launch-brave-ads-as-an-in-process-service", \
"Launch Brave Ads as an in-process service", \
"Launch Brave Ads as an in-process service removing the utility " \
"process.", \
kOsAll, \
FEATURE_VALUE_TYPE( \
brave_ads::kShouldLaunchBraveAdsAsAnInProcessServiceFeature), \
}, \
{ \
"brave-ads-should-always-run-brave-ads-service", \
"Should always run Brave Ads service", \
"Always run Brave Ads service to support triggering ad events when " \
"Brave Private Ads are disabled.", \
kOsAll, \
FEATURE_VALUE_TYPE( \
brave_ads::kShouldAlwaysRunBraveAdsServiceFeature), \
}, \
{ \
"brave-ads-should-always-trigger-new-tab-page-ad-events", \
"Should always trigger new tab page ad events", \
"Support triggering new tab page ad events if Brave Private Ads " \
"are disabled. Requires " \
"#brave-ads-should-always-run-brave-ads-service to be enabled.", \
kOsAll, \
FEATURE_VALUE_TYPE( \
brave_ads::kShouldAlwaysTriggerBraveNewTabPageAdEventsFeature), \
}, \
{ \
"brave-ads-should-always-trigger-search-result-ad-events", \
"Should always trigger search result ad events", \
"Support triggering search result ad events if Brave Private Ads " \
"are disabled. Requires " \
"#brave-ads-should-always-run-brave-ads-service to be enabled.", \
kOsAll, \
FEATURE_VALUE_TYPE( \
brave_ads:: \
kShouldAlwaysTriggerBraveSearchResultAdEventsFeature), \
}, \
{ \
"brave-ads-custom-push-notifications-ads", \
"Enable Brave Ads custom push notifications", \
Expand Down Expand Up @@ -839,7 +879,6 @@
BRAVE_SHARED_PINNED_TABS \
BRAVE_AI_CHAT \
LAST_BRAVE_FEATURE_ENTRIES_ITEM // Keep it as the last item.

namespace flags_ui {
namespace {

Expand Down
4 changes: 2 additions & 2 deletions components/brave_ads/common/brave_ads_feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace brave_ads {

BASE_FEATURE(kShouldLaunchBraveAdsAsInProcessServiceFeature,
BASE_FEATURE(kShouldLaunchBraveAdsAsAnInProcessServiceFeature,
"ShouldLaunchBraveAdsAsInProcessService",
base::FEATURE_DISABLED_BY_DEFAULT);

bool ShouldLaunchAsInProcessService() {
return base::FeatureList::IsEnabled(
kShouldLaunchBraveAdsAsInProcessServiceFeature);
kShouldLaunchBraveAdsAsAnInProcessServiceFeature);
}

BASE_FEATURE(kShouldAlwaysRunBraveAdsServiceFeature,
Expand Down
2 changes: 1 addition & 1 deletion components/brave_ads/common/brave_ads_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace brave_ads {

// Set to |true| to launch as an in process service.
BASE_DECLARE_FEATURE(kShouldLaunchBraveAdsAsInProcessServiceFeature);
BASE_DECLARE_FEATURE(kShouldLaunchBraveAdsAsAnInProcessServiceFeature);

bool ShouldLaunchAsInProcessService();

Expand Down
4 changes: 2 additions & 2 deletions components/brave_ads/common/brave_ads_feature_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ TEST(BraveAdsBraveAdsFeatureTest, ShouldLaunchAsInProcessService) {
// Arrange
std::vector<base::test::FeatureRefAndParams> enabled_features;
base::FieldTrialParams params;
enabled_features.emplace_back(kShouldLaunchBraveAdsAsInProcessServiceFeature,
params);
enabled_features.emplace_back(
kShouldLaunchBraveAdsAsAnInProcessServiceFeature, params);

const std::vector<base::test::FeatureRef> disabled_features;

Expand Down

0 comments on commit b0654eb

Please sign in to comment.