aw_browser_process.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Copyright (c) 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This interface is for managing the global services of the application.
  5. #ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_PROCESS_H_
  6. #define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_PROCESS_H_
  7. #include "android_webview/browser/aw_apk_type.h"
  8. #include "android_webview/browser/aw_browser_context.h"
  9. #include "android_webview/browser/aw_enterprise_authentication_app_link_manager.h"
  10. #include "android_webview/browser/aw_feature_list_creator.h"
  11. #include "android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h"
  12. #include "android_webview/browser/safe_browsing/aw_safe_browsing_allowlist_manager.h"
  13. #include "android_webview/browser/safe_browsing/aw_safe_browsing_ui_manager.h"
  14. #include "base/feature_list.h"
  15. #include "base/memory/raw_ptr.h"
  16. #include "components/prefs/pref_change_registrar.h"
  17. #include "components/prefs/pref_service.h"
  18. #include "components/safe_browsing/android/remote_database_manager.h"
  19. #include "components/safe_browsing/content/browser/triggers/trigger_manager.h"
  20. #include "content/public/browser/network_service_instance.h"
  21. #include "net/log/net_log.h"
  22. #include "services/network/network_service.h"
  23. namespace android_webview {
  24. namespace prefs {
  25. // Used for Kerberos authentication.
  26. extern const char kAuthAndroidNegotiateAccountType[];
  27. extern const char kAuthServerAllowlist[];
  28. extern const char kEnterpriseAuthAppLinkPolicy[];
  29. } // namespace prefs
  30. class AwContentsLifecycleNotifier;
  31. class VisibilityMetricsLogger;
  32. class AwBrowserProcess {
  33. public:
  34. AwBrowserProcess(AwFeatureListCreator* aw_feature_list_creator);
  35. AwBrowserProcess(const AwBrowserProcess&) = delete;
  36. AwBrowserProcess& operator=(const AwBrowserProcess&) = delete;
  37. ~AwBrowserProcess();
  38. static AwBrowserProcess* GetInstance();
  39. PrefService* local_state();
  40. AwBrowserPolicyConnector* browser_policy_connector();
  41. VisibilityMetricsLogger* visibility_metrics_logger();
  42. void CreateBrowserPolicyConnector();
  43. void CreateLocalState();
  44. void InitSafeBrowsing();
  45. safe_browsing::RemoteSafeBrowsingDatabaseManager* GetSafeBrowsingDBManager();
  46. // Called on UI thread.
  47. // This method lazily creates TriggerManager.
  48. // Needs to happen after |safe_browsing_ui_manager_| is created.
  49. safe_browsing::TriggerManager* GetSafeBrowsingTriggerManager();
  50. // InitSafeBrowsing must be called first.
  51. // Called on UI and IO threads.
  52. AwSafeBrowsingAllowlistManager* GetSafeBrowsingAllowlistManager() const;
  53. // InitSafeBrowsing must be called first.
  54. // Called on UI and IO threads.
  55. AwSafeBrowsingUIManager* GetSafeBrowsingUIManager() const;
  56. static void RegisterNetworkContextLocalStatePrefs(
  57. PrefRegistrySimple* pref_registry);
  58. static void RegisterEnterpriseAuthenticationAppLinkPolicyPref(
  59. PrefRegistrySimple* pref_registry);
  60. // Constructs HttpAuthDynamicParams based on |local_state_|.
  61. network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams();
  62. void PreMainMessageLoopRun();
  63. static void TriggerMinidumpUploading();
  64. static ApkType GetApkType();
  65. EnterpriseAuthenticationAppLinkManager*
  66. GetEnterpriseAuthenticationAppLinkManager();
  67. private:
  68. void CreateSafeBrowsingUIManager();
  69. void CreateSafeBrowsingAllowlistManager();
  70. void OnAuthPrefsChanged();
  71. void OnLoseForeground();
  72. // Must be destroyed after |local_state_|.
  73. std::unique_ptr<AwBrowserPolicyConnector> browser_policy_connector_;
  74. // If non-null, this object holds a pref store that will be taken by
  75. // AwBrowserProcess to create the |local_state_|.
  76. // The AwFeatureListCreator is owned by AwMainDelegate.
  77. raw_ptr<AwFeatureListCreator> aw_feature_list_creator_;
  78. std::unique_ptr<PrefService> local_state_;
  79. // Accessed on both UI and IO threads.
  80. scoped_refptr<AwSafeBrowsingUIManager> safe_browsing_ui_manager_;
  81. // Accessed on UI thread only.
  82. std::unique_ptr<safe_browsing::TriggerManager> safe_browsing_trigger_manager_;
  83. // These two are accessed on IO thread only.
  84. scoped_refptr<safe_browsing::RemoteSafeBrowsingDatabaseManager>
  85. safe_browsing_db_manager_;
  86. bool safe_browsing_db_manager_started_ = false;
  87. PrefChangeRegistrar pref_change_registrar_;
  88. // TODO(amalova): Consider to make AllowlistManager per-profile.
  89. // Accessed on UI and IO threads.
  90. std::unique_ptr<AwSafeBrowsingAllowlistManager>
  91. safe_browsing_allowlist_manager_;
  92. std::unique_ptr<VisibilityMetricsLogger> visibility_metrics_logger_;
  93. std::unique_ptr<AwContentsLifecycleNotifier> aw_contents_lifecycle_notifier_;
  94. std::unique_ptr<EnterpriseAuthenticationAppLinkManager> app_link_manager_;
  95. };
  96. } // namespace android_webview
  97. #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_PROCESS_H_