diff --git a/browser/extensions/brave_extension_management.cc b/browser/extensions/brave_extension_management.cc index 7c62a1d27a06..24f3e3ff714a 100644 --- a/browser/extensions/brave_extension_management.cc +++ b/browser/extensions/brave_extension_management.cc @@ -7,10 +7,8 @@ #include -#include "base/command_line.h" #include "brave/browser/brave_browser_process_impl.h" #include "brave/browser/tor/buildflags.h" -#include "brave/common/brave_switches.h" #include "brave/common/extensions/extension_constants.h" #include "brave/common/pref_names.h" #include "brave/browser/extensions/brave_extension_provider.h" @@ -23,7 +21,6 @@ #if BUILDFLAG(ENABLE_TOR) #include "brave/browser/extensions/brave_tor_client_updater.h" -#include "brave/browser/tor/tor_profile_service.h" #endif namespace extensions { @@ -45,19 +42,15 @@ BraveExtensionManagement::~BraveExtensionManagement() { void BraveExtensionManagement::RegisterBraveExtensions() { #if BUILDFLAG(ENABLE_TOR) - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - if (!tor::TorProfileService::IsTorDisabled() && - !command_line.HasSwitch(switches::kDisableTorClientUpdaterExtension) && - !profile_->AsTestingProfile()) { + if (!profile_->AsTestingProfile()) g_brave_browser_process->tor_client_updater()->Register(); - } #endif } void BraveExtensionManagement::CleanupBraveExtensions() { #if BUILDFLAG(ENABLE_TOR) - g_brave_browser_process->tor_client_updater()->Cleanup(); + if (!profile_->AsTestingProfile()) + g_brave_browser_process->tor_client_updater()->Cleanup(); #endif } diff --git a/browser/extensions/brave_tor_client_updater.cc b/browser/extensions/brave_tor_client_updater.cc index 5ce872f7d8cf..8d97fe868b56 100644 --- a/browser/extensions/brave_tor_client_updater.cc +++ b/browser/extensions/brave_tor_client_updater.cc @@ -8,6 +8,7 @@ #include #include +#include "base/command_line.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -15,6 +16,7 @@ #include "base/task_runner.h" #include "base/task_runner_util.h" #include "brave/browser/tor/tor_profile_service.h" +#include "brave/common/brave_switches.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" #include "third_party/re2/src/re2/re2.h" @@ -119,12 +121,17 @@ BraveTorClientUpdater::~BraveTorClientUpdater() { } void BraveTorClientUpdater::Register() { - if (registered_) + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + if (tor::TorProfileService::IsTorDisabled() || + command_line.HasSwitch(switches::kDisableTorClientUpdaterExtension) || + registered_) { return; + } BraveComponent::Register(kTorClientComponentName, - g_tor_client_component_id_, - g_tor_client_component_base64_public_key_); + g_tor_client_component_id_, + g_tor_client_component_base64_public_key_); registered_ = true; }