Completely remove kNativeBraveWalletFeature (#35261)

This commit is contained in:
Anton Paymyshev
2026-04-08 22:09:45 +07:00
committed by GitHub
parent 00a3322bfd
commit ae9c1a1949
40 changed files with 94 additions and 176 deletions
@@ -10,7 +10,6 @@ import org.chromium.build.annotations.NullMarked;
/** A list of feature flags exposed to Java. */
@NullMarked
public abstract class BraveFeatureList {
public static final String NATIVE_BRAVE_WALLET = "NativeBraveWallet";
public static final String USE_DEV_UPDATER_URL = "UseDevUpdaterUrl";
public static final String FORCE_WEB_CONTENTS_DARK_MODE = "WebContentsForceDark";
public static final String ENABLE_FORCE_DARK = "enable-force-dark";
@@ -334,11 +334,7 @@ public abstract class BraveMainPreferencesBase extends BravePreferenceFragment
setPreferenceOrder(PREF_SHIELDS_AND_PRIVACY, ++featuresSectionOrder);
setPreferenceOrder(PREF_BRAVE_NEWS_V2, ++featuresSectionOrder);
if (ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET)) {
setPreferenceOrder(PREF_BRAVE_WALLET, ++featuresSectionOrder);
} else {
removePreferenceIfPresent(PREF_BRAVE_WALLET);
}
setPreferenceOrder(PREF_BRAVE_WALLET, ++featuresSectionOrder);
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_PLAYLIST)) {
setPreferenceOrder(PREF_BRAVE_PLAYLIST, ++featuresSectionOrder);
@@ -141,7 +141,7 @@ public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertie
new PolicyControlledMenuItem(
R.id.brave_wallet_id,
this::buildBraveWalletItem,
() -> ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET),
() -> true,
() -> {
Tab tab = mActivityTabProvider.get();
return tab != null
@@ -10,14 +10,13 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.View;
import org.chromium.base.BraveFeatureList;
import org.chromium.base.supplier.MonotonicObservableSupplier;
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.crypto_wallet.BraveWalletPolicy;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.optional_button.BaseButtonDataProvider;
@@ -62,7 +61,9 @@ public class BraveWalletButtonController extends BaseButtonDataProvider {
protected boolean shouldShowButton(@Nullable Tab tab) {
if (!super.shouldShowButton(tab)) return false;
// Show the Brave Wallet button only if the feature is enabled
return ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET);
Profile profile = tab != null ? tab.getProfile() : null;
// Show the Brave Wallet button only not disabled by policy.
return profile != null && !BraveWalletPolicy.isDisabledByPolicy(profile);
}
}
@@ -129,7 +129,6 @@ import java.util.List;
})
@EnableFeatures({
BraveFeatureList.AI_CHAT,
BraveFeatureList.NATIVE_BRAVE_WALLET,
})
public class BraveTabbedAppMenuPropertiesDelegateUnitTest {
@Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+2 -1
View File
@@ -930,7 +930,8 @@ void BraveContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
map->Add<brave_wallet::mojom::BraveWalletP3A>(
base::BindRepeating(&MaybeBindWalletP3A));
if (brave_wallet::IsNativeWalletEnabled()) {
if (brave_wallet::IsAllowedForContext(
render_frame_host->GetBrowserContext())) {
map->Add<brave_wallet::mojom::EthereumProvider>(base::BindRepeating(
&brave_wallet::BraveWalletTabHelper::BindEthereumProvider));
map->Add<brave_wallet::mojom::SolanaProvider>(base::BindRepeating(
+6 -1
View File
@@ -130,10 +130,15 @@ void BraveRendererUpdater::InitializeRenderer(
auto renderer_configuration = GetRendererConfiguration(render_process_host);
Profile* profile =
Profile::FromBrowserContext(render_process_host->GetBrowserContext());
bool is_brave_wallet_available = false;
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
is_wallet_allowed_for_context_ = brave_wallet::IsAllowedForContext(profile);
is_brave_wallet_available = is_wallet_allowed_for_context_;
#endif
renderer_configuration->SetInitialConfiguration(profile->IsTor());
renderer_configuration->SetInitialConfiguration(profile->IsTor(),
is_brave_wallet_available);
UpdateRenderer(&renderer_configuration);
}
@@ -143,8 +143,7 @@ RegisterPolymerTemplateModifications({
// </if>
// <if expr="enable_brave_wallet">
if (loadTimeData.getBoolean('isBraveWalletAllowed') &&
loadTimeData.getBoolean('isNativeBraveWalletFeatureEnabled')) {
if (loadTimeData.getBoolean('isBraveWalletAllowed')) {
viewManager.appendChild(html`
<site-settings-ethereum-page
id="${ContentSettingsTypes.ETHEREUM}"
@@ -103,13 +103,11 @@ RegisterPolymerTemplateModifications({
// </if>
// <if expr="enable_brave_wallet">
const isNativeBraveWalletEnabled =
loadTimeData.getBoolean('isNativeBraveWalletFeatureEnabled')
const isCardanoDappSupportFeatureEnabled =
loadTimeData.getBoolean('isCardanoDappSupportFeatureEnabled')
const isBraveWalletAllowed =
loadTimeData.getBoolean('isBraveWalletAllowed')
if (isNativeBraveWalletEnabled && isBraveWalletAllowed) {
if (isBraveWalletAllowed) {
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.ETHEREUM]]"
icon="ethereum-on">
@@ -144,13 +144,11 @@ RegisterPolymerComponentReplacement(
}
// </if>
// <if expr="enable_brave_wallet">
const isNativeBraveWalletEnabled =
loadTimeData.getBoolean('isNativeBraveWalletFeatureEnabled')
const isCardanoDappSupportFeatureEnabled =
loadTimeData.getBoolean('isCardanoDappSupportFeatureEnabled')
const isBraveWalletAllowed =
loadTimeData.getBoolean('isBraveWalletAllowed')
if (isNativeBraveWalletEnabled && isBraveWalletAllowed) {
if (isBraveWalletAllowed) {
currentIndex++
const ethereumItem = {
route: routes.SITE_SETTINGS_ETHEREUM,
@@ -39,12 +39,6 @@ class SettingsBraveAppearanceToolbarElement extends SettingsBraveAppearanceToolb
static get properties() {
return {
// <if expr="enable_brave_wallet">
isNativeWalletEnabled_: {
type: Boolean,
value: false,
},
// </if>
isShowBraveShieldsInPageInfoEnabled_: {
type: Boolean,
value: loadTimeData.getBoolean('isShowBraveShieldsInPageInfoEnabled'),
@@ -52,22 +46,8 @@ class SettingsBraveAppearanceToolbarElement extends SettingsBraveAppearanceToolb
}
}
// <if expr="enable_brave_wallet">
private declare isNativeWalletEnabled_: boolean
private walletBrowserProxy_: BraveWalletBrowserProxy = BraveWalletBrowserProxyImpl.getInstance()
// </if>
private declare isShowBraveShieldsInPageInfoEnabled_: boolean
override ready() {
super.ready()
// <if expr="enable_brave_wallet">
this.walletBrowserProxy_.isNativeWalletEnabled().then(val => {
this.isNativeWalletEnabled_ = val
});
// </if>
}
/**
* RouteObserverMixin
*/
+1 -3
View File
@@ -100,12 +100,10 @@ export default function addBraveRoutes(r: Partial<SettingsRoutes>) {
}
// </if>
// <if expr="enable_brave_wallet">
const isNativeBraveWalletFeatureEnabled =
loadTimeData.getBoolean('isNativeBraveWalletFeatureEnabled')
const isCardanoDappSupportFeatureEnabled =
loadTimeData.getBoolean('isCardanoDappSupportFeatureEnabled')
const isBraveWalletAllowed = loadTimeData.getBoolean('isBraveWalletAllowed')
if (isNativeBraveWalletFeatureEnabled && isBraveWalletAllowed) {
if (isBraveWalletAllowed) {
r.SITE_SETTINGS_ETHEREUM = r.SITE_SETTINGS.createChild('ethereum')
r.SITE_SETTINGS_SOLANA = r.SITE_SETTINGS.createChild('solana')
if (isCardanoDappSupportFeatureEnabled) {
@@ -46,7 +46,6 @@ export interface BraveWalletBrowserProxy {
getSolanaProviderOptions: () => Promise<SolanaProvider[]>
getCardanoProviderOptions: () => Promise<CardanoProvider[]>
getTransactionSimulationOptInStatusOptions: () => Promise<Option[]>
isNativeWalletEnabled: () => Promise<boolean>
isBitcoinEnabled: () => Promise<boolean>
isZCashEnabled: () => Promise<boolean>
isZCashShieldedTxEnabled: () => Promise<boolean>
@@ -117,10 +116,6 @@ export class BraveWalletBrowserProxyImpl implements BraveWalletBrowserProxy {
return sendWithPromise('getWeb3ProviderList')
}
isNativeWalletEnabled() {
return sendWithPromise('isNativeWalletEnabled')
}
getAutoLockMinutes () {
return sendWithPromise('getAutoLockMinutes')
}
@@ -118,23 +118,21 @@
menu-options="[[transaction_simulation_opt_in_options_]]">
</settings-dropdown-menu>
</div>
<template is="dom-if" if="[[isNativeWalletEnabled_]]" restamp>
<settings-toggle-button id="enableNftDiscovery"
class="cr-row"
pref="{{prefs.brave.wallet.nft_discovery_enabled}}"
label="$i18n{enableNftDiscoveryLabel}"
sub-label="$i18n{enableNftDiscoveryDesc}"
learn-more-url="$i18n{enableNftDiscoveryLearnMoreURL}">
</settings-toggle-button>
<settings-toggle-button id="enablePrivateWindows"
class="cr-row"
pref="[[isPrivateWindowsEnabled_]]"
on-settings-boolean-control-change="onPrivateWindowsEnabled_"
label="$i18n{enablePrivateWindowsLabel}"
sub-label="$i18n{enablePrivateWindowsDesc}">
</settings-toggle-button>
</template>
<div class="settings-box" hidden="[[!isNativeWalletEnabled_]]">
<settings-toggle-button id="enableNftDiscovery"
class="cr-row"
pref="{{prefs.brave.wallet.nft_discovery_enabled}}"
label="$i18n{enableNftDiscoveryLabel}"
sub-label="$i18n{enableNftDiscoveryDesc}"
learn-more-url="$i18n{enableNftDiscoveryLearnMoreURL}">
</settings-toggle-button>
<settings-toggle-button id="enablePrivateWindows"
class="cr-row"
pref="[[isPrivateWindowsEnabled_]]"
on-settings-boolean-control-change="onPrivateWindowsEnabled_"
label="$i18n{enablePrivateWindowsLabel}"
sub-label="$i18n{enablePrivateWindowsDesc}">
</settings-toggle-button>
<div class="settings-box">
<div class="flex cr-padded-text">
<div>$i18n{autoLockMinutes}</div>
<div class="secondary">$i18n{autoLockMinutesDesc}</div>
@@ -94,10 +94,6 @@ class SettingsBraveWalletPage extends SettingsBraveWalletPageBase {
}
},
isNativeWalletEnabled_: {
type: Boolean
},
isCardanoDAppSupportEnabled_: {
type: Boolean
},
@@ -131,7 +127,6 @@ class SettingsBraveWalletPage extends SettingsBraveWalletPageBase {
private declare transaction_simulation_opt_in_options_: Option[]
private declare cryptocurrency_list_: CurrencyType[]
private declare currency_list_: CurrencyType[]
private declare isNativeWalletEnabled_: boolean
private declare isTransactionSimulationsFeatureEnabled: boolean
private declare isPrivateWindowsEnabled_: chrome.settingsPrivate.PrefObject<boolean>
private declare showRestartToast_: boolean
@@ -154,9 +149,6 @@ class SettingsBraveWalletPage extends SettingsBraveWalletPageBase {
this.browserProxy_.getCardanoProviderOptions().then(list => {
this.cardano_provider_options_ = list
})
this.browserProxy_.isNativeWalletEnabled().then(val => {
this.isNativeWalletEnabled_ = val
})
this.browserProxy_.getAutoLockMinutes().then(val => {
this.$.walletAutoLockMinutes.value = String(val)
})
@@ -48,7 +48,7 @@ public class BraveAdaptiveToolbarStatePredictor
case AdaptiveToolbarButtonVariant.LEO:
return ChromeFeatureList.isEnabled(BraveFeatureList.AI_CHAT);
case AdaptiveToolbarButtonVariant.WALLET:
return ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET);
return true;
}
return BraveAdaptiveToolbarStatePredictorDummySuper.isValidSegment(variant);
@@ -79,11 +79,6 @@ public class BraveRadioButtonGroupAdaptiveToolbarPreference
}
mBraveWalletButton =
(RadioButtonWithDescription) holder.findViewById(R.id.adaptive_option_brave_wallet);
if (!sIsJunitTesting
&& mBraveWalletButton != null
&& !ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET)) {
mBraveWalletButton.setVisibility(View.GONE);
}
super.onBindViewHolder(holder);
@@ -185,8 +185,7 @@ class BraveToolbarView::LayoutGuard {
};
BraveToolbarView::BraveToolbarView(Browser* browser, BrowserView* browser_view)
: ToolbarView(browser, browser_view) {
}
: ToolbarView(browser, browser_view) {}
BraveToolbarView::~BraveToolbarView() = default;
@@ -624,8 +623,7 @@ void BraveToolbarView::UpdateAIChatButtonVisibility() {
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
void BraveToolbarView::UpdateWalletButtonVisibility() {
Profile* profile = browser()->profile();
if (brave_wallet::IsNativeWalletEnabled() &&
brave_wallet::IsAllowedForContext(profile)) {
if (brave_wallet::IsAllowedForContext(profile)) {
// Hide all if user wants to hide.
if (!show_wallet_button_.GetValue()) {
wallet_->SetVisible(false);
-4
View File
@@ -216,10 +216,6 @@ void BraveSettingsUI::AddResources(content::WebUIDataSource* html_source,
speedreader::kSpeedreaderEnabled)));
#endif
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
html_source->AddBoolean(
"isNativeBraveWalletFeatureEnabled",
base::FeatureList::IsEnabled(
brave_wallet::features::kNativeBraveWalletFeature));
html_source->AddBoolean("isCardanoDappSupportFeatureEnabled",
brave_wallet::IsCardanoDAppSupportEnabled());
html_source->AddBoolean("isBraveWalletAllowed",
@@ -221,6 +221,5 @@ WalletPageUIConfig::WalletPageUIConfig()
bool WalletPageUIConfig::IsWebUIEnabled(
content::BrowserContext* browser_context) {
return brave_wallet::IsNativeWalletEnabled() &&
brave_wallet::IsAllowedForContext(browser_context);
return brave_wallet::IsAllowedForContext(browser_context);
}
@@ -238,8 +238,7 @@ WalletPanelUIConfig::WalletPanelUIConfig()
bool WalletPanelUIConfig::IsWebUIEnabled(
content::BrowserContext* browser_context) {
return brave_wallet::IsNativeWalletEnabled() &&
brave_wallet::IsAllowedForContext(browser_context);
return brave_wallet::IsAllowedForContext(browser_context);
}
bool WalletPanelUIConfig::ShouldAutoResizeHost() {
@@ -152,10 +152,6 @@ void BraveWalletHandler::RegisterMessages() {
"getWeb3ProviderList",
base::BindRepeating(&BraveWalletHandler::GetWeb3ProviderList,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"isNativeWalletEnabled",
base::BindRepeating(&BraveWalletHandler::IsNativeWalletEnabled,
base::Unretained(this)));
}
void BraveWalletHandler::GetAutoLockMinutes(const base::ListValue& args) {
@@ -496,10 +492,3 @@ void BraveWalletHandler::GetWeb3ProviderList(const base::ListValue& args) {
AllowJavascript();
ResolveJavascriptCallback(args[0], base::Value(json_string));
}
void BraveWalletHandler::IsNativeWalletEnabled(const base::ListValue& args) {
CHECK_EQ(args.size(), 1U);
AllowJavascript();
ResolveJavascriptCallback(
args[0], base::Value(::brave_wallet::IsNativeWalletEnabled()));
}
@@ -59,7 +59,6 @@ class BraveWalletHandler : public settings::SettingsPageUIHandler {
void SetWalletInPrivateWindowsEnabled(const base::ListValue& args);
void GetWalletInPrivateWindowsEnabled(const base::ListValue& args);
void GetWeb3ProviderList(const base::ListValue& args);
void IsNativeWalletEnabled(const base::ListValue& args);
PrefService* GetPrefs();
brave_wallet::NetworkManager* GetNetworkManager();
@@ -149,9 +149,6 @@ class TestBraveWalletHandler : public BraveWalletHandler {
void GetWeb3ProviderList(const base::ListValue& args) {
BraveWalletHandler::GetWeb3ProviderList(args);
}
void IsNativeWalletEnabled(const base::ListValue& args) {
BraveWalletHandler::IsNativeWalletEnabled(args);
}
content::TestWebUI* web_ui() { return &test_web_ui_; }
PrefService* prefs() { return profile_->GetPrefs(); }
@@ -440,17 +437,3 @@ TEST(TestBraveWalletHandler, GetWeb3ProviderList) {
EXPECT_EQ(provider_list[2].GetDict().FindInt("value"),
static_cast<int>(brave_wallet::mojom::DefaultWallet::None));
}
TEST(TestBraveWalletHandler, IsNativeWalletEnabled) {
TestBraveWalletHandler handler;
base::ListValue args;
args.Append(base::Value("test-callback-id"));
handler.IsNativeWalletEnabled(args);
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg1()->is_string());
EXPECT_EQ(data.arg1()->GetString(), "test-callback-id");
ASSERT_TRUE(data.arg3()->is_bool());
}
@@ -49,8 +49,8 @@ source_set("customize_chrome") {
if (enable_brave_wallet) {
deps += [
"//brave/browser/brave_wallet",
"//brave/components/brave_wallet/browser:pref_names",
"//brave/components/brave_wallet/common",
]
}
@@ -124,7 +124,10 @@ source_set("unit_tests") {
}
if (enable_brave_wallet) {
deps += [ "//brave/components/brave_wallet/common" ]
deps += [
"//brave/browser/brave_wallet",
"//brave/components/brave_wallet/browser:pref_names",
]
}
if (enable_ai_chat) {
@@ -48,7 +48,7 @@
#endif // BUILDFLAG(ENABLE_BRAVE_VPN)
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
#include "brave/components/brave_wallet/common/common_utils.h"
#include "brave/browser/brave_wallet/brave_wallet_context_utils.h"
#endif // BUILDFLAG(ENABLE_BRAVE_WALLET)
namespace customize_chrome {
@@ -222,7 +222,7 @@ std::vector<ActionPtr> ApplyBraveSpecificModifications(
#endif // BUILDFLAG(ENABLE_AI_CHAT)
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
if (brave_wallet::IsNativeWalletEnabled()) {
if (brave_wallet::IsAllowedForContext(web_contents->GetBrowserContext())) {
brave_actions.push_back(kShowWalletAction);
}
#endif // BUILDFLAG(ENABLE_BRAVE_WALLET)
@@ -34,8 +34,8 @@
#include "ui/gfx/image/image_skia.h"
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
#include "brave/components/brave_wallet/common/common_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/browser/brave_wallet/brave_wallet_context_utils.h"
#include "brave/components/brave_wallet/browser/pref_names.h"
#endif
#if BUILDFLAG(ENABLE_AI_CHAT)
@@ -314,8 +314,9 @@ TEST_F(ListActionModifiersUnitTest,
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
TEST_F(ListActionModifiersUnitTest,
ApplyBraveSpecificModifications_WalletShouldNotBeAddedWhenDisabled) {
// Wallet should be added by default(Wallet enabled by default)
ASSERT_TRUE(brave_wallet::IsNativeWalletEnabled());
// Wallet should be available by default.
ASSERT_TRUE(
brave_wallet::IsAllowedForContext(web_contents_->GetBrowserContext()));
auto modified_actions = customize_chrome::ApplyBraveSpecificModifications(
web_contents_.get(), GetBasicActions());
auto wallet_action_it =
@@ -323,11 +324,11 @@ TEST_F(ListActionModifiersUnitTest,
&side_panel::customize_chrome::mojom::Action::id);
ASSERT_NE(wallet_action_it, modified_actions.end());
// Disable Wallet in feature list
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(
brave_wallet::features::kNativeBraveWalletFeature);
ASSERT_FALSE(brave_wallet::IsNativeWalletEnabled());
// Disable Wallet in prefs.
prefs()->SetManagedPref(brave_wallet::kBraveWalletDisabledByPolicy,
base::Value(true));
ASSERT_FALSE(
brave_wallet::IsAllowedForContext(web_contents_->GetBrowserContext()));
modified_actions = customize_chrome::ApplyBraveSpecificModifications(
web_contents_.get(), GetBasicActions());
@@ -403,7 +404,8 @@ TEST_F(ListActionModifiersUnitTest,
ASSERT_TRUE(ai_chat::IsAIChatEnabled(prefs()));
#endif // BUILDFLAG(ENABLE_AI_CHAT)
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
ASSERT_TRUE(brave_wallet::IsNativeWalletEnabled());
ASSERT_TRUE(
brave_wallet::IsAllowedForContext(web_contents_->GetBrowserContext()));
#endif
#if BUILDFLAG(ENABLE_BRAVE_REWARDS)
ASSERT_TRUE(brave_rewards::IsSupportedForProfile(
@@ -69,14 +69,6 @@
#define BRAVE_VPN_FLAG
#endif
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
// CHROMIUM_SRC_INTERNAL_USE
#define BRAVE_WALLET_FLAG &brave_wallet::features::kNativeBraveWalletFeature,
#else
// CHROMIUM_SRC_INTERNAL_USE
#define BRAVE_WALLET_FLAG
#endif
// clang-format off
#define kForceWebContentsDarkMode kForceWebContentsDarkMode, \
BRAVE_AI_CHAT_FLAGS \
@@ -85,7 +77,6 @@
BRAVE_VPN_FLAG \
&brave_rewards::features::kBraveRewards, \
&brave_search_conversion::features::kOmniboxBanner, \
BRAVE_WALLET_FLAG \
&playlist::features::kPlaylist, \
&download::features::kParallelDownloading, \
&preferences::features::kBraveBackgroundVideoPlayback, \
+1 -1
View File
@@ -28,7 +28,7 @@ struct DynamicParams {
// Configures the renderer.
interface BraveRendererConfiguration {
// Configures the renderer with settings that won't change.
SetInitialConfiguration(bool is_tor_process);
SetInitialConfiguration(bool is_tor_process, bool is_brave_wallet_available);
// Update renderer configuration with settings that can change.
SetConfiguration(DynamicParams params);
};
@@ -192,7 +192,7 @@ void WalletDataFilesInstaller::RegisterWalletDataFilesComponentInternal(
void WalletDataFilesInstaller::MaybeRegisterWalletDataFilesComponent(
component_updater::ComponentUpdateService* cus,
PrefService* local_state) {
if (!IsNativeWalletEnabled() || !HasCreatedWallets(local_state)) {
if (!HasCreatedWallets(local_state)) {
return;
}
@@ -21,10 +21,6 @@
namespace brave_wallet {
bool IsNativeWalletEnabled() {
return base::FeatureList::IsEnabled(features::kNativeBraveWalletFeature);
}
bool IsBitcoinEnabled() {
return base::FeatureList::IsEnabled(features::kBraveWalletBitcoinFeature);
}
@@ -18,7 +18,6 @@ static_assert(BUILDFLAG(ENABLE_BRAVE_WALLET));
namespace brave_wallet {
bool IsNativeWalletEnabled();
bool IsBitcoinEnabled();
bool IsBitcoinImportEnabled();
bool IsBitcoinLedgerEnabled();
@@ -11,10 +11,6 @@
namespace brave_wallet::features {
BASE_FEATURE(kNativeBraveWalletFeature,
"NativeBraveWallet",
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kBraveWalletBitcoinFeature,
"BraveWalletBitcoin",
base::FEATURE_ENABLED_BY_DEFAULT);
@@ -13,8 +13,6 @@
static_assert(BUILDFLAG(ENABLE_BRAVE_WALLET));
namespace brave_wallet::features {
BASE_DECLARE_FEATURE(kNativeBraveWalletFeature);
BASE_DECLARE_FEATURE(kBraveWalletBitcoinFeature);
extern const base::FeatureParam<int> kBitcoinRpcThrottle;
extern const base::FeatureParam<bool> kBitcoinTestnetDiscovery;
-2
View File
@@ -69,8 +69,6 @@ OBJC_EXPORT
@property(class, nonatomic, readonly) Feature* kCosmeticFilteringSyncLoad;
@property(class, nonatomic, readonly, nullable) Feature* kGeminiFeature;
@property(class, nonatomic, readonly) Feature* kNTP;
@property(class, nonatomic, readonly, nullable)
Feature* kNativeBraveWalletFeature;
@property(class, nonatomic, readonly) Feature* kSkusFeature;
@property(class, nonatomic, readonly) Feature* kUseDevUpdaterUrl;
@property(class, nonatomic, readonly) Feature* kVerboseLoggingFeature;
-11
View File
@@ -300,17 +300,6 @@
initWithFeature:&brave_search_conversion::features::kNTP];
}
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
+ (Feature*)kNativeBraveWalletFeature {
return [[Feature alloc]
initWithFeature:&brave_wallet::features::kNativeBraveWalletFeature];
}
#else
+ (nullable Feature*)kNativeBraveWalletFeature {
return nil;
}
#endif
+ (Feature*)kSkusFeature {
return [[Feature alloc] initWithFeature:&skus::features::kSkusFeature];
}
+7 -3
View File
@@ -14,7 +14,6 @@
#include "brave/components/brave_search/renderer/brave_search_render_frame_observer.h"
#include "brave/components/brave_shields/core/common/features.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "brave/components/brave_wallet/common/buildflags/buildflags.h"
#include "brave/components/cosmetic_filters/renderer/cosmetic_filters_js_render_frame_observer.h"
#include "brave/components/playlist/content/renderer/playlist_render_frame_observer.h"
#include "brave/components/playlist/core/common/features.h"
@@ -165,8 +164,7 @@ void BraveContentRendererClient::RenderFrameCreated(
}
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
if (base::FeatureList::IsEnabled(
brave_wallet::features::kNativeBraveWalletFeature)) {
if (IsBraveWalletAvailable()) {
new brave_wallet::BraveWalletRenderFrameObserver(
render_frame,
base::BindRepeating(&BraveRenderThreadObserver::GetDynamicParams));
@@ -316,3 +314,9 @@ BraveContentRendererClient::CreateURLLoaderThrottleProvider(
bool BraveContentRendererClient::IsOnionAllowed() const {
return brave_observer_->IsOnionAllowed();
}
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
bool BraveContentRendererClient::IsBraveWalletAvailable() const {
return brave_observer_ && brave_observer_->IsBraveWalletAvailable();
}
#endif
+5
View File
@@ -9,6 +9,7 @@
#include <memory>
#include "brave/components/brave_search/renderer/brave_search_service_worker_holder.h"
#include "brave/components/brave_wallet/common/buildflags/buildflags.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "v8/include/v8.h"
@@ -54,6 +55,10 @@ class BraveContentRendererClient : public ChromeContentRendererClient {
bool IsOnionAllowed() const;
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
bool IsBraveWalletAvailable() const;
#endif
private:
std::unique_ptr<BraveRenderThreadObserver> brave_observer_;
brave_search::BraveSearchServiceWorkerHolder
+12 -1
View File
@@ -49,8 +49,13 @@ void BraveRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
renderer_configuration_receivers_.Add(this, std::move(receiver));
}
void BraveRenderThreadObserver::SetInitialConfiguration(bool is_tor_process) {
void BraveRenderThreadObserver::SetInitialConfiguration(
bool is_tor_process,
bool is_brave_wallet_available) {
is_tor_process_ = is_tor_process;
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
is_brave_wallet_available_ = is_brave_wallet_available;
#endif
}
void BraveRenderThreadObserver::SetConfiguration(
@@ -62,3 +67,9 @@ bool BraveRenderThreadObserver::IsOnionAllowed() const {
return is_tor_process_ ||
!GetDynamicConfigParams()->onion_only_in_tor_windows;
}
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
bool BraveRenderThreadObserver::IsBraveWalletAvailable() const {
return is_brave_wallet_available_;
}
#endif
+10 -1
View File
@@ -7,6 +7,7 @@
#define BRAVE_RENDERER_BRAVE_RENDER_THREAD_OBSERVER_H_
#include "brave/common/brave_renderer_configuration.mojom.h"
#include "brave/components/brave_wallet/common/buildflags/buildflags.h"
#include "content/public/renderer/render_thread_observer.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
@@ -29,6 +30,10 @@ class BraveRenderThreadObserver
bool IsOnionAllowed() const;
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
bool IsBraveWalletAvailable() const;
#endif
// Return the dynamic parameters - those that may change while the
// render process is running.
static const brave::mojom::DynamicParams& GetDynamicParams();
@@ -41,7 +46,8 @@ class BraveRenderThreadObserver
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
// brave::mojom::BraveRendererConfiguration:
void SetInitialConfiguration(bool is_tor_process) override;
void SetInitialConfiguration(bool is_tor_process,
bool is_brave_wallet_available) override;
void SetConfiguration(brave::mojom::DynamicParamsPtr params) override;
void OnRendererConfigurationAssociatedRequest(
@@ -49,6 +55,9 @@ class BraveRenderThreadObserver
receiver);
bool is_tor_process_ = false;
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
bool is_brave_wallet_available_ = false;
#endif
mojo::AssociatedReceiverSet<brave::mojom::BraveRendererConfiguration>
renderer_configuration_receivers_;
};