1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_
6 #define CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_
10 #include "base/sequence_checker.h"
11 #include "chrome/browser/browser_process_platform_part_chromeos.h"
12 #include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
13 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
15 class BrowserProcessPlatformPartTestApi;
19 class AccountManagerFactory;
20 class AshProxyMonitor;
21 class BrowserContextFlusher;
22 class ChromeSessionManager;
23 class ChromeUserManager;
24 class InSessionPasswordChangeManager;
26 class SchedulerConfigurationManager;
27 class TimeZoneResolver;
30 class AutomaticRebootManager;
31 class DeviceDisablingManager;
32 class DeviceDisablingManagerDefaultDelegate;
33 class TimeZoneResolverManager;
39 class BrowserPolicyConnectorAsh;
42 class ScopedKeepAlive;
44 class BrowserProcessPlatformPart : public BrowserProcessPlatformPartChromeOS {
46 BrowserProcessPlatformPart();
48 BrowserProcessPlatformPart(const BrowserProcessPlatformPart&) = delete;
49 BrowserProcessPlatformPart& operator=(const BrowserProcessPlatformPart&) =
52 ~BrowserProcessPlatformPart() override;
54 void InitializeAutomaticRebootManager();
55 void ShutdownAutomaticRebootManager();
57 void InitializeChromeUserManager();
58 void DestroyChromeUserManager();
60 void InitializeDeviceDisablingManager();
61 void ShutdownDeviceDisablingManager();
63 void InitializeSessionManager();
64 void ShutdownSessionManager();
66 void InitializeCrosComponentManager();
67 void ShutdownCrosComponentManager();
69 void InitializeSchedulerConfigurationManager();
70 void ShutdownSchedulerConfigurationManager();
72 void InitializeAshProxyMonitor();
73 void ShutdownAshProxyMonitor();
75 // Initializes all services that need the primary profile. Gets called as soon
76 // as the primary profile is available, which implies that the primary user
77 // has logged in. The services are shut down automatically when the primary
78 // profile is destroyed.
79 // Use this for simple 'leaf-type' services with no or negligible inter-
80 // dependencies. If your service has more complex dependencies, consider using
81 // a BrowserContextKeyedService and restricting service creation to the
83 void InitializePrimaryProfileServices(Profile* primary_profile);
85 // Used to register a KeepAlive when Ash is initialized, and release it
86 // when until Chrome starts exiting. Ensure we stay running the whole time.
87 void RegisterKeepAlive();
88 void UnregisterKeepAlive();
90 // Returns the ProfileHelper instance that is used to identify
91 // users and their profiles in Chrome OS multi user session.
92 ash::ProfileHelper* profile_helper();
94 ash::system::AutomaticRebootManager* automatic_reboot_manager() {
95 return automatic_reboot_manager_.get();
98 policy::BrowserPolicyConnectorAsh* browser_policy_connector_ash();
100 ash::ChromeSessionManager* session_manager() {
101 return session_manager_.get();
104 ash::ChromeUserManager* user_manager() { return chrome_user_manager_.get(); }
106 ash::SchedulerConfigurationManager* scheduler_configuration_manager() {
107 return scheduler_configuration_manager_.get();
110 ash::system::DeviceDisablingManager* device_disabling_manager() {
111 return device_disabling_manager_.get();
114 scoped_refptr<component_updater::CrOSComponentManager>
115 cros_component_manager() {
116 return cros_component_manager_;
119 ash::AshProxyMonitor* ash_proxy_monitor() { return ash_proxy_monitor_.get(); }
121 ash::system::TimeZoneResolverManager* GetTimezoneResolverManager();
123 ash::TimeZoneResolver* GetTimezoneResolver();
125 // Overridden from BrowserProcessPlatformPartBase:
126 void StartTearDown() override;
127 void AttemptExit(bool try_to_quit_application) override;
129 ash::system::SystemClock* GetSystemClock();
130 void DestroySystemClock();
132 ash::AccountManagerFactory* GetAccountManagerFactory();
134 ash::InSessionPasswordChangeManager* in_session_password_change_manager() {
135 return in_session_password_change_manager_.get();
138 static void EnsureFactoryBuilt();
141 // BrowserProcessPlatformPartChromeOS:
142 bool CanRestoreUrlsForProfile(const Profile* profile) const override;
145 friend class BrowserProcessPlatformPartTestApi;
147 void CreateProfileHelper();
149 void ShutdownPrimaryProfileServices();
151 std::unique_ptr<ash::ChromeSessionManager> session_manager_;
153 bool created_profile_helper_;
154 std::unique_ptr<ash::ProfileHelper> profile_helper_;
156 std::unique_ptr<ash::BrowserContextFlusher> browser_context_flusher_;
158 std::unique_ptr<ash::system::AutomaticRebootManager>
159 automatic_reboot_manager_;
161 std::unique_ptr<ash::ChromeUserManager> chrome_user_manager_;
163 std::unique_ptr<ash::system::DeviceDisablingManagerDefaultDelegate>
164 device_disabling_manager_delegate_;
165 std::unique_ptr<ash::system::DeviceDisablingManager>
166 device_disabling_manager_;
168 std::unique_ptr<ash::system::TimeZoneResolverManager>
169 timezone_resolver_manager_;
170 std::unique_ptr<ash::TimeZoneResolver> timezone_resolver_;
172 std::unique_ptr<ash::system::SystemClock> system_clock_;
174 std::unique_ptr<ScopedKeepAlive> keep_alive_;
176 // Whether cros_component_manager_ has been initialized for test. Set by
177 // BrowserProcessPlatformPartTestApi.
178 bool using_testing_cros_component_manager_ = false;
179 scoped_refptr<component_updater::CrOSComponentManager>
180 cros_component_manager_;
182 std::unique_ptr<ash::AccountManagerFactory> account_manager_factory_;
184 std::unique_ptr<ash::InSessionPasswordChangeManager>
185 in_session_password_change_manager_;
187 base::CallbackListSubscription primary_profile_shutdown_subscription_;
189 std::unique_ptr<ash::SchedulerConfigurationManager>
190 scheduler_configuration_manager_;
192 std::unique_ptr<ash::AshProxyMonitor> ash_proxy_monitor_;
194 SEQUENCE_CHECKER(sequence_checker_);
197 #endif // CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_