Streamline checking for Rewards being supported.
* Creates an RewardsService::IsSuppoted check for Rewards on the //components level and checks policy and feature flag. * Creates an IsSupportedForProfile check for Rewards on the //brave/browser level and calls the RewardsService::IsSupported check and also verifies the profile type. * Switches all places needing to check for Rewards support to the appropriate method/funcion.
This commit is contained in:
@@ -11,13 +11,13 @@
|
||||
#include "brave/browser/brave_ads/device_id/device_id_impl.h"
|
||||
#include "brave/browser/brave_federated/brave_federated_service_factory.h"
|
||||
#include "brave/browser/brave_rewards/rewards_service_factory.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/components/brave_adaptive_captcha/buildflags/buildflags.h"
|
||||
#include "brave/components/brave_ads/browser/ads_service_impl.h"
|
||||
#include "brave/components/brave_federated/brave_federated_service.h"
|
||||
#include "brave/components/brave_federated/data_store_service.h"
|
||||
#include "brave/components/brave_federated/notification_ad_task_constants.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
|
||||
#include "chrome/browser/history/history_service_factory.h"
|
||||
#include "chrome/browser/notifications/notification_display_service_factory.h"
|
||||
@@ -35,8 +35,7 @@ namespace brave_ads {
|
||||
|
||||
// static
|
||||
AdsService* AdsServiceFactory::GetForProfile(Profile* profile) {
|
||||
if (brave_rewards::IsDisabledByPolicy(profile->GetPrefs()) ||
|
||||
!brave::IsRegularProfile(profile)) {
|
||||
if (!brave_rewards::IsSupportedForProfile(profile)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ brave_browser_brave_ads_sources = [
|
||||
brave_browser_brave_ads_deps = [
|
||||
"//base",
|
||||
"//brave/browser/brave_ads/device_id",
|
||||
"//brave/browser/brave_rewards:util",
|
||||
"//brave/browser/profiles:util",
|
||||
"//brave/browser/ui/brave_ads",
|
||||
"//brave/components/brave_adaptive_captcha/buildflags",
|
||||
@@ -38,7 +39,6 @@ brave_browser_brave_ads_deps = [
|
||||
"//brave/components/brave_federated",
|
||||
"//brave/components/brave_federated/public/interfaces",
|
||||
"//brave/components/brave_rewards/browser",
|
||||
"//brave/components/brave_rewards/common",
|
||||
"//chrome/browser/notifications",
|
||||
"//chrome/browser/profiles",
|
||||
"//chrome/browser/profiles:profile",
|
||||
|
||||
@@ -5,6 +5,19 @@
|
||||
|
||||
import("//testing/test.gni")
|
||||
|
||||
source_set("util") {
|
||||
sources = [
|
||||
"rewards_util.cc",
|
||||
"rewards_util.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//brave/browser/profiles:util",
|
||||
"//brave/components/brave_rewards/common",
|
||||
"//components/prefs",
|
||||
]
|
||||
}
|
||||
|
||||
source_set("browser_tests") {
|
||||
testonly = true
|
||||
if (!is_android) {
|
||||
@@ -14,7 +27,9 @@ source_set("browser_tests") {
|
||||
"//base/test:test_support",
|
||||
"//brave/app:command_ids",
|
||||
"//brave/browser",
|
||||
"//brave/browser/brave_rewards:util",
|
||||
"//brave/browser/ui",
|
||||
"//brave/components/brave_rewards/browser",
|
||||
"//brave/components/brave_rewards/common",
|
||||
"//chrome/test:test_support",
|
||||
"//chrome/test:test_support_ui",
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
#include "brave/app/brave_command_ids.h"
|
||||
#include "brave/browser/brave_ads/ads_service_factory.h"
|
||||
#include "brave/browser/brave_rewards/rewards_service_factory.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/ui/views/brave_actions/brave_actions_container.h"
|
||||
#include "brave/browser/ui/views/brave_actions/brave_rewards_action_view.h"
|
||||
#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_service.h"
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#include "brave/components/brave_rewards/common/rewards_util.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_command_controller.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
@@ -75,10 +77,12 @@ IN_PROC_BROWSER_TEST_P(BraveRewardsPolicyTest, IsBraveRewardsDisabled) {
|
||||
EXPECT_TRUE(prefs()->FindPreference(brave_rewards::prefs::kDisabledByPolicy));
|
||||
if (IsBraveRewardsDisabledTest()) {
|
||||
EXPECT_TRUE(prefs()->GetBoolean(brave_rewards::prefs::kDisabledByPolicy));
|
||||
EXPECT_TRUE(brave_rewards::IsDisabledByPolicy(prefs()));
|
||||
EXPECT_FALSE(brave_rewards::IsSupported(prefs()));
|
||||
EXPECT_FALSE(brave_rewards::IsSupportedForProfile(profile()));
|
||||
} else {
|
||||
EXPECT_FALSE(prefs()->GetBoolean(brave_rewards::prefs::kDisabledByPolicy));
|
||||
EXPECT_FALSE(brave_rewards::IsDisabledByPolicy(prefs()));
|
||||
EXPECT_TRUE(brave_rewards::IsSupported(prefs()));
|
||||
EXPECT_TRUE(brave_rewards::IsSupportedForProfile(profile()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "brave/browser/brave_rewards/rewards_service_factory.h"
|
||||
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/profiles/brave_profile_manager.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h"
|
||||
@@ -15,8 +16,6 @@
|
||||
#include "brave/components/brave_rewards/browser/rewards_service_impl.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_service_observer.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_service_private_observer.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#include "brave/components/greaselion/browser/buildflags/buildflags.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
@@ -51,8 +50,7 @@ RewardsService* RewardsServiceFactory::GetForProfile(
|
||||
return testing_service_;
|
||||
}
|
||||
|
||||
if (IsDisabledByPolicy(profile->GetPrefs()) ||
|
||||
!brave::IsRegularProfile(profile)) {
|
||||
if (!IsSupportedForProfile(profile)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/components/brave_rewards/common/rewards_util.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
|
||||
namespace brave_rewards {
|
||||
|
||||
bool IsSupportedForProfile(Profile* profile) {
|
||||
DCHECK(profile);
|
||||
return brave::IsRegularProfile(profile) && IsSupported(profile->GetPrefs());
|
||||
}
|
||||
|
||||
} // namespace brave_rewards
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_BROWSER_BRAVE_REWARDS_REWARDS_UTIL_H_
|
||||
#define BRAVE_BROWSER_BRAVE_REWARDS_REWARDS_UTIL_H_
|
||||
|
||||
class Profile;
|
||||
|
||||
namespace brave_rewards {
|
||||
|
||||
bool IsSupportedForProfile(Profile* profile);
|
||||
|
||||
} // namespace brave_rewards
|
||||
|
||||
#endif // BRAVE_BROWSER_BRAVE_REWARDS_REWARDS_UTIL_H_
|
||||
@@ -18,6 +18,7 @@ brave_browser_brave_rewards_sources = [
|
||||
|
||||
brave_browser_brave_rewards_deps = [
|
||||
"//base",
|
||||
"//brave/browser/brave_rewards:util",
|
||||
"//brave/browser/brave_rewards/rewards_panel",
|
||||
"//brave/browser/profiles",
|
||||
"//brave/browser/profiles:util",
|
||||
|
||||
@@ -57,6 +57,7 @@ source_set("extensions") {
|
||||
":resources",
|
||||
"//base",
|
||||
"//brave/app:brave_generated_resources_grit",
|
||||
"//brave/browser/brave_rewards:util",
|
||||
"//brave/browser/component_updater",
|
||||
"//brave/browser/profiles",
|
||||
"//brave/browser/webcompat_reporter",
|
||||
@@ -65,6 +66,7 @@ source_set("extensions") {
|
||||
"//brave/components/brave_ads/browser",
|
||||
"//brave/components/brave_component_updater/browser",
|
||||
"//brave/components/brave_rewards/browser",
|
||||
"//brave/components/brave_rewards/common",
|
||||
"//brave/components/brave_shields/browser",
|
||||
"//brave/components/brave_shields/common",
|
||||
"//brave/components/brave_vpn/buildflags",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "brave/browser/brave_rewards/rewards_panel/rewards_panel_coordinator.h"
|
||||
#include "brave/browser/brave_rewards/rewards_service_factory.h"
|
||||
#include "brave/browser/brave_rewards/rewards_tab_helper.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/brave_rewards/tip_dialog.h"
|
||||
#include "brave/browser/extensions/api/brave_action_api.h"
|
||||
#include "brave/browser/extensions/brave_component_loader.h"
|
||||
@@ -24,7 +25,6 @@
|
||||
#include "brave/components/brave_adaptive_captcha/buildflags/buildflags.h"
|
||||
#include "brave/components/brave_ads/browser/ads_service.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_service.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#include "brave/components/l10n/browser/locale_helper.h"
|
||||
#include "brave/components/l10n/common/locale_util.h"
|
||||
@@ -90,7 +90,7 @@ BraveRewardsIsSupportedFunction::~BraveRewardsIsSupportedFunction() = default;
|
||||
|
||||
ExtensionFunction::ResponseAction BraveRewardsIsSupportedFunction::Run() {
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context());
|
||||
bool is_supported = !::brave_rewards::IsDisabledByPolicy(profile->GetPrefs());
|
||||
bool is_supported = ::brave_rewards::IsSupportedForProfile(profile);
|
||||
return RespondNow(OneArgument(base::Value(is_supported)));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "bat/ads/pref_names.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/component_updater/brave_component_installer.h"
|
||||
#include "brave/components/brave_ads/common/pref_names.h"
|
||||
#include "brave/components/brave_component_updater/browser/brave_on_demand_updater.h"
|
||||
#include "brave/components/brave_extension/grit/brave_extension.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_service.h"
|
||||
#include "brave/components/brave_rewards/common/features.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_extension_resources.h"
|
||||
#include "brave/components/brave_webtorrent/grit/brave_webtorrent_resources.h"
|
||||
@@ -141,16 +142,18 @@ void BraveComponentLoader::AddDefaultComponentExtensions(
|
||||
void BraveComponentLoader::AddRewardsExtension() {
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line.HasSwitch(switches::kDisableBraveRewardsExtension) &&
|
||||
!brave_rewards::IsDisabledByPolicy(profile_prefs_) &&
|
||||
!Exists(brave_rewards_extension_id) &&
|
||||
!base::FeatureList::IsEnabled(
|
||||
if (command_line.HasSwitch(switches::kDisableBraveRewardsExtension) ||
|
||||
!brave_rewards::IsSupportedForProfile(profile_) ||
|
||||
Exists(brave_rewards_extension_id) ||
|
||||
base::FeatureList::IsEnabled(
|
||||
brave_rewards::features::kWebUIPanelFeature)) {
|
||||
base::FilePath brave_rewards_path(FILE_PATH_LITERAL(""));
|
||||
brave_rewards_path =
|
||||
brave_rewards_path.Append(FILE_PATH_LITERAL("brave_rewards"));
|
||||
Add(IDR_BRAVE_REWARDS, brave_rewards_path);
|
||||
return;
|
||||
}
|
||||
|
||||
base::FilePath brave_rewards_path(FILE_PATH_LITERAL(""));
|
||||
brave_rewards_path =
|
||||
brave_rewards_path.Append(FILE_PATH_LITERAL("brave_rewards"));
|
||||
Add(IDR_BRAVE_REWARDS, brave_rewards_path);
|
||||
}
|
||||
|
||||
void BraveComponentLoader::CheckRewardsStatus() {
|
||||
|
||||
+3
-2
@@ -380,8 +380,6 @@ source_set("ui") {
|
||||
# need it
|
||||
if (is_android) {
|
||||
deps += [ ":favicon_source" ]
|
||||
} else {
|
||||
deps += [ "//brave/components/brave_rewards/common" ]
|
||||
}
|
||||
|
||||
if (enable_brave_wayback_machine) {
|
||||
@@ -465,6 +463,7 @@ source_set("ui") {
|
||||
if (!is_android) {
|
||||
deps += [
|
||||
"//brave/app:brave_generated_resources_grit",
|
||||
"//brave/browser/brave_rewards:util",
|
||||
"//brave/browser/resources/bookmarks:resources",
|
||||
"//brave/browser/resources/history:resources",
|
||||
"//brave/browser/resources/settings:resources",
|
||||
@@ -475,6 +474,8 @@ source_set("ui") {
|
||||
"//brave/components/brave_private_new_tab_ui/common",
|
||||
"//brave/components/brave_private_new_tab_ui/common:mojom",
|
||||
"//brave/components/brave_private_new_tab_ui/resources/page:generated_resources",
|
||||
"//brave/components/brave_rewards/browser",
|
||||
"//brave/components/brave_rewards/common",
|
||||
"//brave/components/brave_rewards/common:mojom",
|
||||
"//brave/components/brave_rewards/resources:tip_generated_resources",
|
||||
"//brave/components/brave_rewards/resources/rewards_panel:brave_rewards_panel_generated",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/ui/brave_pages.h"
|
||||
#include "brave/browser/ui/browser_commands.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/rewards_util.h"
|
||||
#include "brave/components/brave_vpn/buildflags/buildflags.h"
|
||||
#include "brave/components/constants/pref_names.h"
|
||||
#include "brave/components/ipfs/buildflags/buildflags.h"
|
||||
@@ -127,12 +127,12 @@ bool BraveBrowserCommandController::UpdateCommandEnabled(int id, bool state) {
|
||||
}
|
||||
|
||||
void BraveBrowserCommandController::InitBraveCommandState() {
|
||||
// Sync & Rewards pages doesn't work on tor(guest) session.
|
||||
// They also doesn't work on private window but they are redirected
|
||||
// to normal window in this case.
|
||||
// Sync, Rewards, and Wallet pages don't work in tor(guest) sessions.
|
||||
// They also don't work in private windows but they are redirected
|
||||
// to a normal window in this case.
|
||||
const bool is_guest_session = browser_->profile()->IsGuestSession();
|
||||
if (!is_guest_session) {
|
||||
if (!brave_rewards::IsDisabledByPolicy(browser_->profile()->GetPrefs())) {
|
||||
if (brave_rewards::IsSupported(browser_->profile()->GetPrefs())) {
|
||||
UpdateCommandForBraveRewards();
|
||||
}
|
||||
UpdateCommandForBraveWallet();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/ntp_background/view_counter_service_factory.h"
|
||||
#include "brave/browser/resources/settings/grit/brave_settings_resources.h"
|
||||
#include "brave/browser/resources/settings/grit/brave_settings_resources_map.h"
|
||||
@@ -20,7 +21,6 @@
|
||||
#include "brave/browser/ui/webui/settings/brave_sync_handler.h"
|
||||
#include "brave/browser/ui/webui/settings/brave_wallet_handler.h"
|
||||
#include "brave/browser/ui/webui/settings/default_brave_shields_handler.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_vpn/buildflags/buildflags.h"
|
||||
#include "brave/components/brave_wallet/common/features.h"
|
||||
#include "brave/components/de_amp/common/features.h"
|
||||
@@ -102,9 +102,8 @@ void BraveSettingsUI::AddResources(content::WebUIDataSource* html_source,
|
||||
html_source->AddBoolean(
|
||||
"isDeAmpFeatureEnabled",
|
||||
base::FeatureList::IsEnabled(de_amp::features::kBraveDeAMP));
|
||||
html_source->AddBoolean(
|
||||
"isBraveRewardsSupported",
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs()));
|
||||
html_source->AddBoolean("isBraveRewardsSupported",
|
||||
brave_rewards::IsSupportedForProfile(profile));
|
||||
|
||||
if (ShouldDisableCSPForTesting()) {
|
||||
html_source->DisableContentSecurityPolicy();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "brave/browser/ethereum_remote_client/buildflags/buildflags.h"
|
||||
#include "brave/browser/ui/webui/brave_adblock_ui.h"
|
||||
#include "brave/browser/ui/webui/brave_federated/federated_internals_ui.h"
|
||||
@@ -17,8 +18,7 @@
|
||||
#include "brave/browser/ui/webui/brave_tip_ui.h"
|
||||
#include "brave/browser/ui/webui/webcompat_reporter_ui.h"
|
||||
#include "brave/components/brave_federated/features.h"
|
||||
#include "brave/components/brave_rewards/common/features.h"
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/rewards_util.h"
|
||||
#include "brave/components/brave_shields/common/features.h"
|
||||
#include "brave/components/constants/pref_names.h"
|
||||
#include "brave/components/constants/webui_url_constants.h"
|
||||
@@ -106,17 +106,20 @@ WebUIController* NewWebUI(WebUI* web_ui, const GURL& url) {
|
||||
return new WalletPanelUI(web_ui);
|
||||
#endif // BUILDFLAG(OS_ANDROID)
|
||||
} else if (host == kRewardsPageHost &&
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs())) {
|
||||
// We don't want to check for supported profile type here because
|
||||
// we want private windows to redirect to the regular profile.
|
||||
// Guest session will just show an error page.
|
||||
brave_rewards::IsSupported(profile->GetPrefs())) {
|
||||
return new BraveRewardsPageUI(web_ui, url.host());
|
||||
} else if (host == kRewardsInternalsHost &&
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs())) {
|
||||
brave_rewards::IsSupportedForProfile(profile)) {
|
||||
return new BraveRewardsInternalsUI(web_ui, url.host());
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
} else if (host == kTipHost &&
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs())) {
|
||||
brave_rewards::IsSupportedForProfile(profile)) {
|
||||
return new BraveTipUI(web_ui, url.host());
|
||||
} else if (host == kBraveRewardsPanelHost &&
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs())) {
|
||||
brave_rewards::IsSupportedForProfile(profile)) {
|
||||
return new RewardsPanelUI(web_ui);
|
||||
#endif // !BUILDFLAG(IS_ANDROID)
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
@@ -206,26 +209,18 @@ bool ShouldBlockRewardsWebUI(content::BrowserContext* browser_context,
|
||||
url.host_piece() != kRewardsInternalsHost) {
|
||||
return false;
|
||||
}
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
if (!base::FeatureList::IsEnabled(brave_rewards::features::kBraveRewards)) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
if (profile) {
|
||||
auto* prefs = profile->GetPrefs();
|
||||
if (prefs) {
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
if (prefs->GetBoolean(kSafetynetCheckFailed)) {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (brave_rewards::IsDisabledByPolicy(prefs)) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
if (!brave_rewards::IsSupportedForProfile(profile)) {
|
||||
return true;
|
||||
}
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
auto* prefs = profile->GetPrefs();
|
||||
if (prefs && prefs->GetBoolean(kSafetynetCheckFailed)) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "brave/browser/ui/webui/navigation_bar_data_provider.h"
|
||||
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/browser/brave_rewards/rewards_util.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
@@ -16,18 +16,15 @@
|
||||
// static
|
||||
void NavigationBarDataProvider::Initialize(content::WebUIDataSource* source,
|
||||
Profile* profile) {
|
||||
source->AddLocalizedString(
|
||||
"brToolbarSettingsTitle", IDS_SETTINGS_SETTINGS);
|
||||
source->AddLocalizedString(
|
||||
"brToolbarBookmarksTitle", IDS_BOOKMARK_MANAGER_TITLE);
|
||||
source->AddLocalizedString(
|
||||
"brToolbarDownloadsTitle", IDS_DOWNLOAD_TITLE);
|
||||
source->AddLocalizedString(
|
||||
"brToolbarHistoryTitle", IDS_HISTORY_TITLE);
|
||||
source->AddLocalizedString(
|
||||
"brToolbarRewardsTitle", IDS_BRAVE_UI_BRAVE_REWARDS);
|
||||
source->AddLocalizedString("brToolbarSettingsTitle", IDS_SETTINGS_SETTINGS);
|
||||
source->AddLocalizedString("brToolbarBookmarksTitle",
|
||||
IDS_BOOKMARK_MANAGER_TITLE);
|
||||
source->AddLocalizedString("brToolbarDownloadsTitle", IDS_DOWNLOAD_TITLE);
|
||||
source->AddLocalizedString("brToolbarHistoryTitle", IDS_HISTORY_TITLE);
|
||||
source->AddLocalizedString("brToolbarRewardsTitle",
|
||||
IDS_BRAVE_UI_BRAVE_REWARDS);
|
||||
source->AddLocalizedString("brToolbarWalletsTitle", IDS_WALLETS_TITLE);
|
||||
|
||||
source->AddBoolean("isBraveRewardsSupported",
|
||||
!brave_rewards::IsDisabledByPolicy(profile->GetPrefs()));
|
||||
brave_rewards::IsSupportedForProfile(profile));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "brave/components/brave_rewards/browser/rewards_service.h"
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/time/time.h"
|
||||
#include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "url/gurl.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
class Profile;
|
||||
class PrefService;
|
||||
|
||||
namespace content {
|
||||
class NavigationHandle;
|
||||
|
||||
@@ -14,12 +14,12 @@ source_set("features") {
|
||||
|
||||
static_library("common") {
|
||||
sources = [
|
||||
"policy_util.cc",
|
||||
"policy_util.h",
|
||||
"pref_names.cc",
|
||||
"pref_names.h",
|
||||
"rewards_flags.cc",
|
||||
"rewards_flags.h",
|
||||
"rewards_util.cc",
|
||||
"rewards_util.h",
|
||||
"url_constants.cc",
|
||||
"url_constants.h",
|
||||
]
|
||||
|
||||
+27
-2
@@ -3,14 +3,24 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/components/brave_rewards/common/policy_util.h"
|
||||
#include "brave/components/brave_rewards/common/rewards_util.h"
|
||||
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#include "base/feature_list.h"
|
||||
#include "brave/components/brave_rewards/common/features.h"
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||
#include "brave/components/brave_rewards/common/pref_names.h"
|
||||
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||
|
||||
namespace brave_rewards {
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsDisabledByPolicy(PrefService* prefs) {
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||
DCHECK(prefs);
|
||||
@@ -21,4 +31,19 @@ bool IsDisabledByPolicy(PrefService* prefs) {
|
||||
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||
}
|
||||
|
||||
bool IsDisabledByFeature() {
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
if (!base::FeatureList::IsEnabled(features::kBraveRewards)) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool IsSupported(PrefService* prefs) {
|
||||
return !IsDisabledByPolicy(prefs) && !IsDisabledByFeature();
|
||||
}
|
||||
|
||||
} // namespace brave_rewards
|
||||
+4
-4
@@ -3,15 +3,15 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_POLICY_UTIL_H_
|
||||
#define BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_POLICY_UTIL_H_
|
||||
#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_REWARDS_UTIL_H_
|
||||
#define BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_REWARDS_UTIL_H_
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace brave_rewards {
|
||||
|
||||
bool IsDisabledByPolicy(PrefService* prefs);
|
||||
bool IsSupported(PrefService* prefs);
|
||||
|
||||
} // namespace brave_rewards
|
||||
|
||||
#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_POLICY_UTIL_H_
|
||||
#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_COMMON_REWARDS_UTIL_H_
|
||||
Reference in New Issue
Block a user