Skip to content

Commit

Permalink
Use ExtensionPrefs instead of custom pref handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Jul 17, 2019
1 parent a61bbbf commit 26afc11
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
4 changes: 0 additions & 4 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kNewTabPageShowClock, true);
registry->RegisterBooleanPref(kNewTabPageShowTopSites, true);
registry->RegisterBooleanPref(kNewTabPageShowStats, true);

// Whether Brave Wallet has been enabled at least once and should therefore
// be loaded on future startups.
registry->RegisterBooleanPref(kWalletHasBeenLoadedOnce, false);
}

} // namespace brave
2 changes: 0 additions & 2 deletions browser/brave_profile_prefs_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, MiscBravePrefs) {
browser()->profile()->GetPrefs()->GetBoolean(kHideBraveRewardsButton));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kIPFSCompanionEnabled));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kWalletHasBeenLoadedOnce));
}

IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest,
Expand Down
13 changes: 4 additions & 9 deletions browser/extensions/brave_component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "chrome/common/pref_names.h"
#include "components/grit/brave_components_resources.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"

namespace extensions {
Expand Down Expand Up @@ -54,11 +55,6 @@ void BraveComponentLoader::OnComponentReady(std::string extension_id,
ExtensionPrefs::Get((content::BrowserContext *)profile_)->
SetAllowFileAccess(extension_id, true);
}
#if BUILDFLAG(BRAVE_WALLET_ENABLED)
if (extension_id == ethereum_remote_client_extension_id) {
profile_prefs_->SetBoolean(kWalletHasBeenLoadedOnce, true);
}
#endif
}

void BraveComponentLoader::AddExtension(const std::string& extension_id,
Expand Down Expand Up @@ -115,10 +111,9 @@ void BraveComponentLoader::AddDefaultComponentExtensions(
}

#if BUILDFLAG(BRAVE_WALLET_ENABLED)
// If brave://wallet has been loaded at least once, then load it again
// on future startups.
if (profile_prefs_->FindPreference(kWalletHasBeenLoadedOnce) &&
profile_prefs_->GetBoolean(kWalletHasBeenLoadedOnce)) {
// If brave://wallet has been loaded at least once, then load it again.
if (ExtensionPrefs::Get((content::BrowserContext *)profile_)->
HasPrefForExtension(ethereum_remote_client_extension_id)) {
AddEthereumRemoteClientExtension();
}
#endif
Expand Down
1 change: 0 additions & 1 deletion common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ const char kNewTabPageShowBackgroundImage[] =
const char kNewTabPageShowClock[] = "brave.new_tab_page.show_clock";
const char kNewTabPageShowTopSites[] = "brave.new_tab_page.show_top_sites";
const char kNewTabPageShowStats[] = "brave.new_tab_page.show_stats";
const char kWalletHasBeenLoadedOnce[] = "brave.wallet_enabled";
1 change: 0 additions & 1 deletion common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,5 @@ extern const char kNewTabPageShowBackgroundImage[];
extern const char kNewTabPageShowClock[];
extern const char kNewTabPageShowTopSites[];
extern const char kNewTabPageShowStats[];
extern const char kWalletHasBeenLoadedOnce[];

#endif // BRAVE_COMMON_PREF_NAMES_H_

0 comments on commit 26afc11

Please sign in to comment.