Skip to content

Commit

Permalink
Merge pull request #2462 from brave/no-rewards-build
Browse files Browse the repository at this point in the history
Brave now builds if brave_rewards_enabled is false
  • Loading branch information
Jason Sadler authored May 20, 2019
2 parents 1c69c72 + a5b0fae commit 42bc703
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
12 changes: 8 additions & 4 deletions browser/extensions/brave_component_extension_resource_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

#include "brave/components/brave_extension/grit/brave_extension_generated_map.h"
#include "brave/components/brave_extension/grit/brave_extension_resources_map.h"
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_extension_resources_map.h"
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_panel_generated_map.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "brave/components/brave_sync/grit/brave_sync_generated_map.h"
#include "brave/components/brave_sync/grit/brave_sync_resources_map.h"
#include "brave/components/brave_webtorrent/grit/brave_webtorrent_resources_map.h"
#include "brave/components/brave_webtorrent/grit/brave_webtorrent_generated_map.h"

#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_extension_resources_map.h"
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_panel_generated_map.h"
#endif

namespace extensions {

BraveComponentExtensionResourceManager::
Expand All @@ -25,15 +29,15 @@ BraveComponentExtensionResourceManager() {
AddComponentResourceEntries(
kBraveExtensionGenerated,
kBraveExtensionGeneratedSize);

#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
AddComponentResourceEntries(
kBraveRewardsExtensionResources,
kBraveRewardsExtensionResourcesSize);

AddComponentResourceEntries(
kBraveRewardsPanelGenerated,
kBraveRewardsPanelGeneratedSize);

#endif
AddComponentResourceEntries(
kBraveSyncResources,
kBraveSyncResourcesSize);
Expand Down
9 changes: 9 additions & 0 deletions browser/ui/toolbar/brave_app_menu_model_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"

using BraveAppMenuBrowserTest = InProcessBrowserTest;

Expand All @@ -32,7 +33,11 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuBrowserTest, BasicTest) {
EXPECT_NE(-1, normal_model.GetIndexOfCommandId(IDC_SHOW_BRAVE_SYNC));

auto* command_controller = browser()->command_controller();
#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_REWARDS));
#else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_REWARDS));
#endif
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));

// Create proviate browser.
Expand All @@ -49,7 +54,11 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuBrowserTest, BasicTest) {
EXPECT_NE(-1, private_model.GetIndexOfCommandId(IDC_SHOW_BRAVE_SYNC));

command_controller = private_browser->command_controller();
#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_REWARDS));
#else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_REWARDS));
#endif
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));

content::WindowedNotificationObserver browser_creation_observer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h"
#include "brave/common/extensions/extension_constants.h"
#include "brave/common/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
Expand All @@ -24,6 +24,10 @@
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"

#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
#include "brave/components/brave_rewards/common/pref_names.h"
#endif

class BraveActionsContainerTest : public InProcessBrowserTest {
public:
BraveActionsContainerTest() = default;
Expand Down Expand Up @@ -57,6 +61,7 @@ class BraveActionsContainerTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(BraveActionsContainerTest);
};

#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
IN_PROC_BROWSER_TEST_F(BraveActionsContainerTest, HideBraveRewardsAction) {
// By default the action should be shown.
EXPECT_FALSE(prefs_->GetBoolean(brave_rewards::prefs::kBraveRewardsEnabled));
Expand Down Expand Up @@ -90,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(BraveActionsContainerTest, HideBraveRewardsAction) {
}

IN_PROC_BROWSER_TEST_F(BraveActionsContainerTest,
BraveRewadsActionHiddenInGuestSession) {
BraveRewardsActionHiddenInGuestSession) {
// By default the action should be shown.
EXPECT_FALSE(prefs_->GetBoolean(brave_rewards::prefs::kBraveRewardsEnabled));
EXPECT_FALSE(prefs_->GetBoolean(kHideBraveRewardsButton));
Expand Down Expand Up @@ -120,3 +125,4 @@ IN_PROC_BROWSER_TEST_F(BraveActionsContainerTest,
Init(browser);
CheckBraveRewardsActionShown(false);
}
#endif
3 changes: 2 additions & 1 deletion components/brave_ads/browser/buildflags/buildflags.gni
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import("//brave/components/brave_rewards/browser/buildflags/buildflags.gni")
import("//build/config/features.gni")

declare_args() {
brave_ads_enabled = !is_android
brave_ads_enabled = !is_android && brave_rewards_enabled
}
18 changes: 9 additions & 9 deletions components/brave_rewards/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ source_set("browser") {
"rewards_internals_info.h",
]

if (enable_extensions) {
sources += [
"extension_rewards_notification_service_observer.cc",
"extension_rewards_notification_service_observer.h",
"extension_rewards_service_observer.cc",
"extension_rewards_service_observer.h",
]
}

deps = [
"//base",
"//brave/components/brave_rewards/common",
Expand Down Expand Up @@ -86,6 +77,15 @@ source_set("browser") {
"rewards_notification_service_impl.h",
]

if (enable_extensions) {
sources += [
"extension_rewards_notification_service_observer.cc",
"extension_rewards_notification_service_observer.h",
"extension_rewards_service_observer.cc",
"extension_rewards_service_observer.h",
]
}

if (!is_android) {
sources += [
"rewards_helper.cc",
Expand Down

0 comments on commit 42bc703

Please sign in to comment.