This source file includes following definitions.
- GetForProfile
- GetForProfileIfExisting
- GetForProfileForSessionRestore
- ShutdownForProfile
- GetInstance
- BuildServiceInstanceFor
- ServiceIsCreatedWithBrowserContext
- ServiceIsNULLWhileTesting
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_data_deleter.h"
#include "chrome/browser/sessions/session_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
SessionService* SessionServiceFactory::GetForProfile(Profile* profile) {
#if defined(OS_ANDROID)
return NULL;
#else
return static_cast<SessionService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
#endif
}
SessionService* SessionServiceFactory::GetForProfileIfExisting(
Profile* profile) {
#if defined(OS_ANDROID)
return NULL;
#else
return static_cast<SessionService*>(
GetInstance()->GetServiceForBrowserContext(profile, false));
#endif
}
SessionService* SessionServiceFactory::GetForProfileForSessionRestore(
Profile* profile) {
SessionService* service = GetForProfile(profile);
if (!service) {
GetInstance()->Disassociate(profile);
service = GetForProfile(profile);
}
return service;
}
void SessionServiceFactory::ShutdownForProfile(Profile* profile) {
DeleteSessionOnlyData(profile);
SessionServiceFactory* factory = GetInstance();
factory->GetServiceForBrowserContext(profile, true);
factory->BrowserContextShutdown(profile);
factory->BrowserContextDestroyed(profile);
factory->Associate(profile, NULL);
}
SessionServiceFactory* SessionServiceFactory::GetInstance() {
return Singleton<SessionServiceFactory>::get();
}
SessionServiceFactory::SessionServiceFactory()
: BrowserContextKeyedServiceFactory(
"SessionService",
BrowserContextDependencyManager::GetInstance()) {
}
SessionServiceFactory::~SessionServiceFactory() {
}
KeyedService* SessionServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
SessionService* service = NULL;
service = new SessionService(static_cast<Profile*>(profile));
service->ResetFromCurrentBrowsers();
return service;
}
bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
bool SessionServiceFactory::ServiceIsNULLWhileTesting() const {
return true;
}