Commit b8fb1ae3 authored by Nancy Wang's avatar Nancy Wang Committed by Chromium LUCI CQ

Start the full restore service when the profile is ready.

Create the full restore service when the profile is ready. The full
restore service must be called before 'NotifyUserProfileLoaded',
because NotifyUserProfileLoaded notifies the ash to prepare the virtual
desk restoration. However, the virtual desk restoration should be
decided by the full restore service. So full restore service must be
created before NotifyUserProfileLoaded is called.

There is a full restore flag to control the full restore service:
https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/chromeos/full_restore/full_restore_service_factory.cc;l=25
The flag is disabled currently, so before the feature is ready, no
impact on the current implementation.

PRD:go/cros-full-restore-prd
Mock:go/cros-full-restore
Design doc: go/chrome-os-full-restore-dd

BUG=1146900

Change-Id: I21f68ce61166557eb24f69a2afbd8921fa091ebc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563192Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832565}
parent 2538ed2a
......@@ -18,6 +18,7 @@
#include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
#include "chrome/browser/chromeos/file_system_provider/service_factory.h"
#include "chrome/browser/chromeos/fileapi/file_change_service_factory.h"
#include "chrome/browser/chromeos/full_restore/full_restore_service_factory.h"
#include "chrome/browser/chromeos/guest_os/guest_os_registry_service_factory.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager_factory.h"
#include "chrome/browser/chromeos/launcher_search_provider/launcher_search_provider_service_factory.h"
......@@ -58,6 +59,7 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
AuthPolicyCredentialsManagerFactory::GetInstance();
bluetooth::DebugLogsManagerFactory::GetInstance();
cert_provisioning::CertProvisioningSchedulerUserServiceFactory::GetInstance();
chromeos::full_restore::FullRestoreServiceFactory::GetInstance();
CroshLoaderFactory::GetInstance();
#if defined(USE_CUPS)
CupsProxyServiceManagerFactory::GetInstance();
......
......@@ -20,24 +20,6 @@ FullRestoreServiceFactory* FullRestoreServiceFactory::GetInstance() {
return instance.get();
}
// static
FullRestoreService* FullRestoreServiceFactory::GetForBrowserContext(
content::BrowserContext* browser_context) {
if (!ash::features::IsFullRestoreEnabled())
return nullptr;
// No service for non-regular user profile, or ephemeral user profile.
Profile* profile = Profile::FromBrowserContext(browser_context);
if (!ProfileHelper::IsRegularProfile(profile) ||
ProfileHelper::IsEphemeralUserProfile(profile)) {
return nullptr;
}
return static_cast<FullRestoreService*>(
FullRestoreServiceFactory::GetInstance()->GetServiceForBrowserContext(
browser_context, true));
}
FullRestoreServiceFactory::FullRestoreServiceFactory()
: BrowserContextKeyedServiceFactory(
"FullRestoreService",
......@@ -49,8 +31,22 @@ FullRestoreServiceFactory::~FullRestoreServiceFactory() = default;
KeyedService* FullRestoreServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
if (!ash::features::IsFullRestoreEnabled())
return nullptr;
// No service for non-regular user profile, or ephemeral user profile.
Profile* profile = Profile::FromBrowserContext(context);
if (!ProfileHelper::IsRegularProfile(profile) ||
ProfileHelper::IsEphemeralUserProfile(profile)) {
return nullptr;
}
return new FullRestoreService(Profile::FromBrowserContext(context));
}
bool FullRestoreServiceFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
} // namespace full_restore
} // namespace chromeos
......@@ -21,9 +21,6 @@ class FullRestoreServiceFactory : public BrowserContextKeyedServiceFactory {
public:
static FullRestoreServiceFactory* GetInstance();
static FullRestoreService* GetForBrowserContext(
content::BrowserContext* browser_context);
private:
friend base::NoDestructor<FullRestoreServiceFactory>;
......@@ -37,6 +34,7 @@ class FullRestoreServiceFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
};
} // namespace full_restore
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment