#ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_PROCESS_H_
#define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_PROCESS_H_
#include "android_webview/browser/aw_apk_type.h"
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/aw_enterprise_authentication_app_link_manager.h"
#include "android_webview/browser/aw_feature_list_creator.h"
#include "android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h"
#include "android_webview/browser/safe_browsing/aw_safe_browsing_allowlist_manager.h"
#include "android_webview/browser/safe_browsing/aw_safe_browsing_ui_manager.h"
#include "android_webview/common/aw_features.h"
#include "base/memory/raw_ptr.h"
#include "components/os_crypt/async/browser/os_crypt_async.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/android/remote_database_manager.h"
#include "components/safe_browsing/content/browser/triggers/trigger_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "net/log/net_log.h"
#include "services/network/network_service.h"
namespace embedder_support {
class OriginTrialsSettingsStorage;
}
namespace android_webview {
namespace prefs {
extern const char kAuthAndroidNegotiateAccountType[];
extern const char kAuthServerAllowlist[];
extern const char kEnterpriseAuthAppLinkPolicy[];
extern const char kLastKnownAppCacheQuota[];
}
class AwContentsLifecycleNotifier;
class VisibilityMetricsLogger;
class AwBrowserProcess {
public:
explicit AwBrowserProcess(AwContentBrowserClient* browser_client);
AwBrowserProcess(const AwBrowserProcess&) = delete;
AwBrowserProcess& operator=(const AwBrowserProcess&) = delete;
~AwBrowserProcess();
static AwBrowserProcess* GetInstance();
PrefService* local_state();
AwBrowserPolicyConnector* browser_policy_connector();
VisibilityMetricsLogger* visibility_metrics_logger();
void CreateBrowserPolicyConnector();
void CreateLocalState();
void InitSafeBrowsing();
int64_t GetHostAppCacheQuota();
void FetchHostAppCacheQuota();
safe_browsing::RemoteSafeBrowsingDatabaseManager* GetSafeBrowsingDBManager();
safe_browsing::TriggerManager* GetSafeBrowsingTriggerManager();
AwSafeBrowsingAllowlistManager* GetSafeBrowsingAllowlistManager() const;
AwSafeBrowsingUIManager* GetSafeBrowsingUIManager() const;
os_crypt_async::OSCryptAsync* GetOSCryptAsync() const;
static void RegisterNetworkContextLocalStatePrefs(
PrefRegistrySimple* pref_registry);
static void RegisterEnterpriseAuthenticationAppLinkPolicyPref(
PrefRegistrySimple* pref_registry);
static void RegisterAppCacheQuotaLocalStatePref(
PrefRegistrySimple* pref_registry);
network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams();
void PreMainMessageLoopRun();
static void TriggerMinidumpUploading();
static ApkType GetApkType();
EnterpriseAuthenticationAppLinkManager*
GetEnterpriseAuthenticationAppLinkManager();
embedder_support::OriginTrialsSettingsStorage*
GetOriginTrialsSettingsStorage();
AwContentBrowserClient* GetBrowserClient();
static bool DidEarlyPerfettoInitialization();
private:
void CreateSafeBrowsingUIManager();
void CreateSafeBrowsingAllowlistManager();
void OnAuthPrefsChanged();
void OnLoseForeground();
std::unique_ptr<AwBrowserPolicyConnector> browser_policy_connector_;
raw_ptr<AwFeatureListCreator> aw_feature_list_creator_;
std::unique_ptr<PrefService> local_state_;
scoped_refptr<AwSafeBrowsingUIManager> safe_browsing_ui_manager_;
std::unique_ptr<safe_browsing::TriggerManager> safe_browsing_trigger_manager_;
scoped_refptr<safe_browsing::RemoteSafeBrowsingDatabaseManager>
safe_browsing_db_manager_;
bool safe_browsing_db_manager_started_ = false;
PrefChangeRegistrar pref_change_registrar_;
std::unique_ptr<AwSafeBrowsingAllowlistManager>
safe_browsing_allowlist_manager_;
base::Lock lock_;
int64_t app_cache_quota_ GUARDED_BY(lock_) = -1;
std::unique_ptr<VisibilityMetricsLogger> visibility_metrics_logger_;
std::unique_ptr<AwContentsLifecycleNotifier> aw_contents_lifecycle_notifier_;
std::unique_ptr<EnterpriseAuthenticationAppLinkManager> app_link_manager_;
std::unique_ptr<embedder_support::OriginTrialsSettingsStorage>
origin_trials_settings_storage_;
std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
raw_ref<AwContentBrowserClient> browser_client_;
};
}
#endif