To add a new BraveVpnService implementation based on Architecture 2.0, which must co-exist with Architecture 1.0 for quite a while, we need to split service's interface and implementation. All the external components will keep accessing VPN service via the BraveVpnService interface, but the implementation mostly goes into BraveVpnServiceImpl. This change revisits the approach how Brave VPN is enabled in GN. New flags are introduced: enable_brave_vpn_v1 and enable_brave_vpn_v2. Currently, only V1 architecture is implemented, hence, the GN flag enable_brave_vpn_v1 is enabled by default, and enable_brave_vpn_v2 is disabled by default. enable_brave_vpn becomes a dependent flag: it is enabled when either enable_brave_vpn_v1, or enable_brave_vpn_v2, or both are enabled. Implements part of https://github.com/brave/brave-browser/issues/54597
238 lines
7.8 KiB
C++
238 lines
7.8 KiB
C++
/* Copyright (c) 2019 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 https://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef BRAVE_BROWSER_BRAVE_BROWSER_PROCESS_IMPL_H_
|
|
#define BRAVE_BROWSER_BRAVE_BROWSER_PROCESS_IMPL_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "base/memory/scoped_refptr.h"
|
|
#include "base/sequence_checker.h"
|
|
#include "brave/browser/brave_browser_process.h"
|
|
#include "brave/components/ai_chat/core/common/buildflags/buildflags.h"
|
|
#include "brave/components/brave_ads/buildflags/buildflags.h"
|
|
#include "brave/components/brave_component_updater/browser/brave_component.h"
|
|
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
|
|
#include "brave/components/speedreader/common/buildflags/buildflags.h"
|
|
#include "brave/components/tor/brave_tor_pluggable_transport_updater.h"
|
|
#include "brave/components/tor/buildflags/buildflags.h"
|
|
#include "brave/components/url_sanitizer/core/browser/url_sanitizer_component_installer.h"
|
|
#include "build/build_config.h"
|
|
#include "chrome/browser/browser_process_impl.h"
|
|
#include "extensions/buildflags/buildflags.h"
|
|
|
|
namespace brave {
|
|
class BraveReferralsService;
|
|
} // namespace brave
|
|
|
|
namespace brave_component_updater {
|
|
class LocalDataFilesService;
|
|
} // namespace brave_component_updater
|
|
|
|
namespace brave_shields {
|
|
class AdBlockService;
|
|
} // namespace brave_shields
|
|
|
|
namespace https_upgrade_exceptions {
|
|
class HttpsUpgradeExceptionsService;
|
|
} // namespace https_upgrade_exceptions
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_STATS_UPDATER)
|
|
namespace brave_stats {
|
|
class BraveStatsUpdater;
|
|
} // namespace brave_stats
|
|
#endif
|
|
|
|
namespace debounce {
|
|
class DebounceComponentInstaller;
|
|
} // namespace debounce
|
|
|
|
namespace misc_metrics {
|
|
class ProcessMiscMetrics;
|
|
} // namespace misc_metrics
|
|
|
|
namespace request_otr {
|
|
#if BUILDFLAG(ENABLE_REQUEST_OTR)
|
|
class RequestOTRComponentInstallerPolicy;
|
|
#endif
|
|
} // namespace request_otr
|
|
|
|
namespace ntp_background_images {
|
|
class NTPBackgroundImagesService;
|
|
} // namespace ntp_background_images
|
|
|
|
namespace p3a {
|
|
class HistogramsBraveizer;
|
|
class P3AService;
|
|
} // namespace p3a
|
|
|
|
namespace tor {
|
|
class BraveTorClientUpdater;
|
|
class BraveTorPluggableTransportUpdater;
|
|
} // namespace tor
|
|
|
|
namespace speedreader {
|
|
class SpeedreaderRewriterService;
|
|
}
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
namespace brave_ads {
|
|
class BraveStatsHelper;
|
|
class ResourceComponent;
|
|
} // namespace brave_ads
|
|
#endif // BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
|
|
namespace ai_chat {
|
|
#if BUILDFLAG(ENABLE_BRAVE_AI_CHAT_AGENT_PROFILE)
|
|
class AIChatAgentProfileManager;
|
|
#endif
|
|
} // namespace ai_chat
|
|
|
|
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID)
|
|
class DayZeroBrowserUIExptManager;
|
|
#endif
|
|
|
|
class BraveBrowserProcessImpl : public BraveBrowserProcess,
|
|
public BrowserProcessImpl {
|
|
public:
|
|
explicit BraveBrowserProcessImpl(StartupData* startup_data);
|
|
BraveBrowserProcessImpl(const BraveBrowserProcessImpl&) = delete;
|
|
BraveBrowserProcessImpl& operator=(const BraveBrowserProcessImpl&) = delete;
|
|
~BraveBrowserProcessImpl() override;
|
|
|
|
// BrowserProcess implementation.
|
|
|
|
ProfileManager* profile_manager() override;
|
|
NotificationPlatformBridge* notification_platform_bridge() override;
|
|
|
|
// BraveBrowserProcess implementation.
|
|
|
|
void StartBraveServices() override;
|
|
brave_shields::AdBlockService* ad_block_service() override;
|
|
https_upgrade_exceptions::HttpsUpgradeExceptionsService*
|
|
https_upgrade_exceptions_service() override;
|
|
debounce::DebounceComponentInstaller* debounce_component_installer() override;
|
|
#if BUILDFLAG(ENABLE_REQUEST_OTR)
|
|
request_otr::RequestOTRComponentInstallerPolicy*
|
|
request_otr_component_installer() override;
|
|
#endif
|
|
brave::URLSanitizerComponentInstaller* URLSanitizerComponentInstaller()
|
|
override;
|
|
brave_component_updater::LocalDataFilesService* local_data_files_service()
|
|
override;
|
|
#if BUILDFLAG(ENABLE_TOR)
|
|
tor::BraveTorClientUpdater* tor_client_updater() override;
|
|
tor::BraveTorPluggableTransportUpdater* tor_pluggable_transport_updater()
|
|
override;
|
|
#endif
|
|
p3a::P3AService* p3a_service() override;
|
|
brave::BraveReferralsService* brave_referrals_service() override;
|
|
#if BUILDFLAG(ENABLE_BRAVE_STATS_UPDATER)
|
|
brave_stats::BraveStatsUpdater* brave_stats_updater() override;
|
|
#endif
|
|
#if BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
brave_ads::BraveStatsHelper* ads_brave_stats_helper() override;
|
|
brave_ads::ResourceComponent* resource_component() override;
|
|
#endif // BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
ntp_background_images::NTPBackgroundImagesService*
|
|
ntp_background_images_service() override;
|
|
#if BUILDFLAG(ENABLE_SPEEDREADER)
|
|
speedreader::SpeedreaderRewriterService* speedreader_rewriter_service()
|
|
override;
|
|
#endif
|
|
#if BUILDFLAG(ENABLE_BRAVE_VPN_V1)
|
|
brave_vpn::BraveVPNConnectionManager* brave_vpn_connection_manager() override;
|
|
#endif
|
|
misc_metrics::ProcessMiscMetrics* process_misc_metrics() override;
|
|
|
|
private:
|
|
// BrowserProcessImpl overrides:
|
|
void Init() override;
|
|
void PreMainMessageLoopRun() override;
|
|
#if !BUILDFLAG(IS_ANDROID)
|
|
void StartTearDown() override;
|
|
void PostDestroyThreads() override;
|
|
#endif
|
|
|
|
void CreateProfileManager();
|
|
|
|
#if BUILDFLAG(ENABLE_TOR)
|
|
void OnTorEnabledChanged();
|
|
#endif
|
|
|
|
void InitBraveStatsHelper();
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_AI_CHAT_AGENT_PROFILE)
|
|
void CreateAIChatAgentProfileManager();
|
|
#endif
|
|
|
|
brave_component_updater::BraveComponent::Delegate*
|
|
brave_component_updater_delegate();
|
|
|
|
// Sequence checker must stay on top to avoid UaF issues when data members use
|
|
// `g_browser_process->profile_manager()`.
|
|
SEQUENCE_CHECKER(sequence_checker_);
|
|
|
|
// local_data_files_service_ should always be first because it needs
|
|
// to be destroyed last
|
|
std::unique_ptr<brave_component_updater::LocalDataFilesService>
|
|
local_data_files_service_;
|
|
std::unique_ptr<brave_component_updater::BraveComponent::Delegate>
|
|
brave_component_updater_delegate_;
|
|
std::unique_ptr<brave_shields::AdBlockService> ad_block_service_;
|
|
std::unique_ptr<https_upgrade_exceptions::HttpsUpgradeExceptionsService>
|
|
https_upgrade_exceptions_service_;
|
|
std::unique_ptr<debounce::DebounceComponentInstaller>
|
|
debounce_component_installer_;
|
|
#if BUILDFLAG(ENABLE_REQUEST_OTR)
|
|
std::unique_ptr<request_otr::RequestOTRComponentInstallerPolicy>
|
|
request_otr_component_installer_;
|
|
#endif
|
|
std::unique_ptr<brave::URLSanitizerComponentInstaller>
|
|
url_sanitizer_component_installer_;
|
|
#if BUILDFLAG(ENABLE_BRAVE_STATS_UPDATER)
|
|
std::unique_ptr<brave_stats::BraveStatsUpdater> brave_stats_updater_;
|
|
#endif
|
|
std::unique_ptr<brave::BraveReferralsService> brave_referrals_service_;
|
|
#if BUILDFLAG(ENABLE_TOR)
|
|
std::unique_ptr<tor::BraveTorClientUpdater> tor_client_updater_;
|
|
std::unique_ptr<tor::BraveTorPluggableTransportUpdater>
|
|
tor_pluggable_transport_updater_;
|
|
#endif
|
|
scoped_refptr<p3a::P3AService> p3a_service_;
|
|
scoped_refptr<p3a::HistogramsBraveizer> histogram_braveizer_;
|
|
std::unique_ptr<ntp_background_images::NTPBackgroundImagesService>
|
|
ntp_background_images_service_;
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
std::unique_ptr<brave_ads::ResourceComponent> resource_component_;
|
|
std::unique_ptr<brave_ads::BraveStatsHelper> brave_stats_helper_;
|
|
#endif // BUILDFLAG(ENABLE_BRAVE_ADS)
|
|
|
|
#if BUILDFLAG(ENABLE_SPEEDREADER)
|
|
std::unique_ptr<speedreader::SpeedreaderRewriterService>
|
|
speedreader_rewriter_service_;
|
|
#endif
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_VPN_V1)
|
|
std::unique_ptr<brave_vpn::BraveVPNConnectionManager>
|
|
brave_vpn_connection_manager_;
|
|
#endif
|
|
|
|
std::unique_ptr<misc_metrics::ProcessMiscMetrics> process_misc_metrics_;
|
|
|
|
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID)
|
|
std::unique_ptr<DayZeroBrowserUIExptManager>
|
|
day_zero_browser_ui_expt_manager_;
|
|
#endif
|
|
|
|
#if BUILDFLAG(ENABLE_BRAVE_AI_CHAT_AGENT_PROFILE)
|
|
std::unique_ptr<ai_chat::AIChatAgentProfileManager>
|
|
ai_chat_agent_profile_manager_;
|
|
#endif
|
|
};
|
|
|
|
#endif // BRAVE_BROWSER_BRAVE_BROWSER_PROCESS_IMPL_H_
|