1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_
#define CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_
#include <memory>
#include "base/callback_list.h"
#include "base/sequence_checker.h"
#include "chrome/browser/browser_process_platform_part_base.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
class BrowserProcessPlatformPartTestApi;
class Profile;
class ScopedKeepAlive;
namespace app_list {
class EssentialSearchManager;
} // namespace app_list
namespace ash {
class AccountManagerFactory;
class AshProxyMonitor;
class BrowserContextFlusher;
class ChromeSessionManager;
class CrosSettingsHolder;
class InSessionPasswordChangeManager;
class PolicyUserManagerController;
class ProfileHelper;
class ProfileUserManagerController;
class SchedulerConfigurationManager;
class SecureDnsManager;
class UserImageManagerRegistry;
namespace system {
class AutomaticRebootManager;
class DeviceDisablingManager;
class DeviceDisablingManagerDefaultDelegate;
class TimeZoneResolverManager;
class SystemClock;
} // namespace system
} // namespace ash
namespace policy {
class BrowserPolicyConnectorAsh;
class DeviceRestrictionScheduleController;
} // namespace policy
namespace user_manager {
class MultiUserSignInPolicyController;
class UserManager;
} // namespace user_manager
class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase {
public:
BrowserProcessPlatformPart();
BrowserProcessPlatformPart(const BrowserProcessPlatformPart&) = delete;
BrowserProcessPlatformPart& operator=(const BrowserProcessPlatformPart&) =
delete;
~BrowserProcessPlatformPart() override;
void InitializeAutomaticRebootManager();
void ShutdownAutomaticRebootManager();
void InitializeUserManager();
void ShutdownUserManager();
void DestroyUserManager();
void InitializeDeviceRestrictionScheduleController();
void ShutdownDeviceRestrictionScheduleController();
void InitializeDeviceDisablingManager();
void ShutdownDeviceDisablingManager();
void InitializeSessionManager();
void ShutdownSessionManager();
void InitializeCrosSettings();
void ShutdownCrosSettings();
void InitializeComponentManager();
void ShutdownComponentManager();
void InitializeSchedulerConfigurationManager();
void ShutdownSchedulerConfigurationManager();
void InitializeAshProxyMonitor();
void ShutdownAshProxyMonitor();
// Initializes all services that need the primary profile. Gets called as soon
// as the primary profile is available, which implies that the primary user
// has logged in. The services are shut down automatically when the primary
// profile is destroyed.
// Use this for simple 'leaf-type' services with no or negligible inter-
// dependencies. If your service has more complex dependencies, consider using
// a BrowserContextKeyedService and restricting service creation to the
// primary profile.
void InitializePrimaryProfileServices(Profile* primary_profile);
// Used to register a KeepAlive when Ash is initialized, and release it
// when until Chrome starts exiting. Ensure we stay running the whole time.
void RegisterKeepAlive();
void UnregisterKeepAlive();
// Returns the ProfileHelper instance that is used to identify
// users and their profiles in Chrome OS multi user session.
ash::ProfileHelper* profile_helper();
ash::system::AutomaticRebootManager* automatic_reboot_manager() {
return automatic_reboot_manager_.get();
}
policy::BrowserPolicyConnectorAsh* browser_policy_connector_ash();
ash::ChromeSessionManager* session_manager() {
return session_manager_.get();
}
user_manager::UserManager* user_manager() { return user_manager_.get(); }
user_manager::MultiUserSignInPolicyController*
multi_user_sign_in_policy_controller() {
return multi_user_sign_in_policy_controller_.get();
}
ash::SchedulerConfigurationManager* scheduler_configuration_manager() {
return scheduler_configuration_manager_.get();
}
policy::DeviceRestrictionScheduleController*
device_restriction_schedule_controller() {
return device_restriction_schedule_controller_.get();
}
ash::system::DeviceDisablingManager* device_disabling_manager() {
return device_disabling_manager_.get();
}
scoped_refptr<component_updater::ComponentManagerAsh>
component_manager_ash() {
return component_manager_ash_;
}
ash::AshProxyMonitor* ash_proxy_monitor() { return ash_proxy_monitor_.get(); }
ash::SecureDnsManager* secure_dns_manager() {
return secure_dns_manager_.get();
}
app_list::EssentialSearchManager* essential_search_manager() {
return essential_search_manager_.get();
}
ash::InSessionPasswordChangeManager* in_session_password_change_manager() {
return in_session_password_change_manager_.get();
}
ash::system::TimeZoneResolverManager* GetTimezoneResolverManager();
// Overridden from BrowserProcessPlatformPartBase:
void StartTearDown() override;
ash::system::SystemClock* GetSystemClock();
void DestroySystemClock();
ash::AccountManagerFactory* GetAccountManagerFactory();
static void EnsureFactoryBuilt();
private:
// An observer that restores urls based on the on startup setting after a new
// browser is added to the BrowserList.
class BrowserRestoreObserver : public BrowserListObserver {
public:
explicit BrowserRestoreObserver(
const BrowserProcessPlatformPart* browser_process_platform_part);
~BrowserRestoreObserver() override;
protected:
// BrowserListObserver:
void OnBrowserAdded(Browser* browser) override;
private:
// Returns true, if the url defined in the on startup setting should be
// opened. Otherwise, returns false.
bool ShouldRestoreUrls(Browser* browser) const;
// Returns true, if the url defined in the on startup setting should be
// opened in a new browser. Otherwise, returns false.
bool ShouldOpenUrlsInNewBrowser(Browser* browser) const;
// Restores urls based on the on startup setting.
void RestoreUrls(Browser* browser);
// Called when a session is restored.
void OnSessionRestoreDone(Profile* profile, int num_tabs_restored);
const raw_ptr<const BrowserProcessPlatformPart>
browser_process_platform_part_;
base::CallbackListSubscription on_session_restored_callback_subscription_;
};
BrowserRestoreObserver browser_restore_observer_;
friend class BrowserProcessPlatformPartTestApi;
// Returns true if we can restore URLs for `profile`. Restoring URLs should
// only be allowed for regular signed-in users.
bool CanRestoreUrlsForProfile(const Profile* profile) const;
void CreateProfileHelper();
void ShutdownPrimaryProfileServices();
std::unique_ptr<ash::ChromeSessionManager> session_manager_;
bool created_profile_helper_;
std::unique_ptr<ash::ProfileHelper> profile_helper_;
std::unique_ptr<ash::BrowserContextFlusher> browser_context_flusher_;
std::unique_ptr<ash::system::AutomaticRebootManager>
automatic_reboot_manager_;
std::unique_ptr<user_manager::UserManager> user_manager_;
std::unique_ptr<ash::ProfileUserManagerController>
profile_user_manager_controller_;
std::unique_ptr<ash::PolicyUserManagerController>
policy_user_manager_controller_;
std::unique_ptr<ash::UserImageManagerRegistry> user_image_manager_registry_;
std::unique_ptr<user_manager::MultiUserSignInPolicyController>
multi_user_sign_in_policy_controller_;
std::unique_ptr<policy::DeviceRestrictionScheduleController>
device_restriction_schedule_controller_;
std::unique_ptr<ash::system::DeviceDisablingManagerDefaultDelegate>
device_disabling_manager_delegate_;
std::unique_ptr<ash::system::DeviceDisablingManager>
device_disabling_manager_;
std::unique_ptr<ash::system::TimeZoneResolverManager>
timezone_resolver_manager_;
std::unique_ptr<ash::system::SystemClock> system_clock_;
std::unique_ptr<ScopedKeepAlive> keep_alive_;
std::unique_ptr<ash::CrosSettingsHolder> cros_settings_holder_;
// Whether `component_manager_ash_` has been initialized for test. Set by
// BrowserProcessPlatformPartTestApi.
bool using_testing_component_manager_ash_ = false;
scoped_refptr<component_updater::ComponentManagerAsh> component_manager_ash_;
std::unique_ptr<ash::AccountManagerFactory> account_manager_factory_;
std::unique_ptr<app_list::EssentialSearchManager> essential_search_manager_;
std::unique_ptr<ash::InSessionPasswordChangeManager>
in_session_password_change_manager_;
base::CallbackListSubscription primary_profile_shutdown_subscription_;
std::unique_ptr<ash::SchedulerConfigurationManager>
scheduler_configuration_manager_;
std::unique_ptr<ash::AshProxyMonitor> ash_proxy_monitor_;
std::unique_ptr<ash::SecureDnsManager> secure_dns_manager_;
SEQUENCE_CHECKER(sequence_checker_);
};
#endif // CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_ASH_H_
|