browser_process_impl.h 5.4 KB

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