browser_process_impl.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright (c) 2012 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. Each
  5. // service is lazily created when requested the first time. The service getters
  6. // will return NULL if the service is not available, so callers must check for
  7. // this condition.
  8. #ifndef ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
  9. #define ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
  10. #include <memory>
  11. #include <string>
  12. #include "base/command_line.h"
  13. #include "chrome/browser/browser_process.h"
  14. #include "components/embedder_support/origin_trials/origin_trials_settings_storage.h"
  15. #include "components/prefs/pref_service.h"
  16. #include "components/prefs/value_map_pref_store.h"
  17. #include "printing/buildflags/buildflags.h"
  18. #include "services/network/public/cpp/network_quality_tracker.h"
  19. #include "services/network/public/cpp/shared_url_loader_factory.h"
  20. #include "shell/browser/net/system_network_context_manager.h"
  21. #if BUILDFLAG(IS_LINUX)
  22. #include "components/os_crypt/sync/key_storage_util_linux.h"
  23. #endif
  24. namespace printing {
  25. class PrintJobManager;
  26. }
  27. // Empty definition for std::unique_ptr, rather than a forward declaration
  28. class BackgroundModeManager {};
  29. // NOT THREAD SAFE, call only from the main thread.
  30. // These functions shouldn't return NULL unless otherwise noted.
  31. class BrowserProcessImpl : public BrowserProcess {
  32. public:
  33. BrowserProcessImpl();
  34. ~BrowserProcessImpl() override;
  35. // disable copy
  36. BrowserProcessImpl(const BrowserProcessImpl&) = delete;
  37. BrowserProcessImpl& operator=(const BrowserProcessImpl&) = delete;
  38. static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store);
  39. BuildState* GetBuildState() override;
  40. void PostEarlyInitialization();
  41. void PreCreateThreads();
  42. void PreMainMessageLoopRun();
  43. void PostDestroyThreads() {}
  44. void PostMainMessageLoopRun();
  45. void SetSystemLocale(const std::string& locale);
  46. const std::string& GetSystemLocale() const;
  47. #if BUILDFLAG(IS_LINUX)
  48. void SetLinuxStorageBackend(os_crypt::SelectedLinuxBackend selected_backend);
  49. const std::string& GetLinuxStorageBackend() const;
  50. #endif
  51. void EndSession() override {}
  52. void FlushLocalStateAndReply(base::OnceClosure reply) override {}
  53. bool IsShuttingDown() override;
  54. metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
  55. override;
  56. metrics::MetricsService* metrics_service() override;
  57. ProfileManager* profile_manager() override;
  58. PrefService* local_state() override;
  59. scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
  60. override;
  61. variations::VariationsService* variations_service() override;
  62. BrowserProcessPlatformPart* platform_part() override;
  63. extensions::EventRouterForwarder* extension_event_router_forwarder() override;
  64. NotificationUIManager* notification_ui_manager() override;
  65. NotificationPlatformBridge* notification_platform_bridge() override;
  66. SystemNetworkContextManager* system_network_context_manager() override;
  67. network::NetworkQualityTracker* network_quality_tracker() override;
  68. embedder_support::OriginTrialsSettingsStorage*
  69. GetOriginTrialsSettingsStorage() override;
  70. policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
  71. policy::PolicyService* policy_service() override;
  72. IconManager* icon_manager() override;
  73. GpuModeManager* gpu_mode_manager() override;
  74. printing::PrintPreviewDialogController* print_preview_dialog_controller()
  75. override;
  76. printing::BackgroundPrintingManager* background_printing_manager() override;
  77. IntranetRedirectDetector* intranet_redirect_detector() override;
  78. DownloadStatusUpdater* download_status_updater() override;
  79. DownloadRequestLimiter* download_request_limiter() override;
  80. BackgroundModeManager* background_mode_manager() override;
  81. StatusTray* status_tray() override;
  82. safe_browsing::SafeBrowsingService* safe_browsing_service() override;
  83. subresource_filter::RulesetService* subresource_filter_ruleset_service()
  84. override;
  85. component_updater::ComponentUpdateService* component_updater() override;
  86. MediaFileSystemRegistry* media_file_system_registry() override;
  87. WebRtcLogUploader* webrtc_log_uploader() override;
  88. network_time::NetworkTimeTracker* network_time_tracker() override;
  89. gcm::GCMDriver* gcm_driver() override;
  90. resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
  91. override;
  92. resource_coordinator::TabManager* GetTabManager() override;
  93. SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
  94. HidSystemTrayIcon* hid_system_tray_icon() override;
  95. UsbSystemTrayIcon* usb_system_tray_icon() override;
  96. void CreateDevToolsProtocolHandler() override {}
  97. void CreateDevToolsAutoOpener() override {}
  98. void set_background_mode_manager_for_test(
  99. std::unique_ptr<BackgroundModeManager> manager) override {}
  100. #if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX))
  101. void StartAutoupdateTimer() override {}
  102. #endif
  103. void SetApplicationLocale(const std::string& locale) override;
  104. const std::string& GetApplicationLocale() override;
  105. printing::PrintJobManager* print_job_manager() override;
  106. StartupData* startup_data() override;
  107. private:
  108. void CreateNetworkQualityObserver();
  109. network::NetworkQualityTracker* GetNetworkQualityTracker();
  110. #if BUILDFLAG(ENABLE_PRINTING)
  111. std::unique_ptr<printing::PrintJobManager> print_job_manager_;
  112. #endif
  113. std::unique_ptr<PrefService> local_state_;
  114. std::string locale_;
  115. std::string system_locale_;
  116. #if BUILDFLAG(IS_LINUX)
  117. std::string selected_linux_storage_backend_;
  118. #endif
  119. embedder_support::OriginTrialsSettingsStorage origin_trials_settings_storage_;
  120. std::unique_ptr<network::NetworkQualityTracker> network_quality_tracker_;
  121. std::unique_ptr<
  122. network::NetworkQualityTracker::RTTAndThroughputEstimatesObserver>
  123. network_quality_observer_;
  124. };
  125. #endif // ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_