#include "chrome/browser/accessibility/live_translate_controller_factory.h"
#include "base/no_destructor.h"
#include "chrome/browser/profiles/profile.h"
#include "components/live_caption/live_translate_controller.h"
namespace captions {
LiveTranslateController* LiveTranslateControllerFactory::GetForProfile(
Profile* profile) {
return static_cast<LiveTranslateController*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
LiveTranslateControllerFactory* LiveTranslateControllerFactory::GetInstance() {
static base::NoDestructor<LiveTranslateControllerFactory> factory;
return factory.get();
}
LiveTranslateControllerFactory::LiveTranslateControllerFactory()
: ProfileKeyedServiceFactory(
"LiveTranslateController",
ProfileSelections::Builder()
.WithRegular(ProfileSelection::kRedirectedToOriginal)
.WithGuest(ProfileSelection::kOffTheRecordOnly)
.WithSystem(ProfileSelection::kNone)
.WithAshInternals(ProfileSelection::kNone)
.Build()) {}
LiveTranslateControllerFactory::~LiveTranslateControllerFactory() = default;
bool LiveTranslateControllerFactory::ServiceIsCreatedWithBrowserContext()
const {
return true;
}
std::unique_ptr<KeyedService>
LiveTranslateControllerFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* browser_context) const {
return std::make_unique<LiveTranslateController>(
Profile::FromBrowserContext(browser_context)->GetPrefs(),
browser_context);
}
}