This source file includes following definitions.
- GetForProfile
- GetInstance
- ShouldShowOptInPopup
- IsServiceAvailable
- IsHotwordAllowed
- RetryHotwordExtension
- RegisterProfilePrefs
- BuildServiceInstanceFor
#include "chrome/browser/search/hotword_service_factory.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/hotword_service.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_context.h"
using content::BrowserContext;
HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) {
return static_cast<HotwordService*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
HotwordServiceFactory* HotwordServiceFactory::GetInstance() {
return Singleton<HotwordServiceFactory>::get();
}
bool HotwordServiceFactory::ShouldShowOptInPopup(BrowserContext* context) {
HotwordService* hotword_service = GetForProfile(context);
return hotword_service && hotword_service->ShouldShowOptInPopup();
}
bool HotwordServiceFactory::IsServiceAvailable(BrowserContext* context) {
HotwordService* hotword_service = GetForProfile(context);
return hotword_service && hotword_service->IsServiceAvailable();
}
bool HotwordServiceFactory::IsHotwordAllowed(BrowserContext* context) {
HotwordService* hotword_service = GetForProfile(context);
return hotword_service && hotword_service->IsHotwordAllowed();
}
bool HotwordServiceFactory::RetryHotwordExtension(Profile* profile) {
HotwordService* hotword_service = GetForProfile(profile);
return hotword_service && hotword_service->RetryHotwordExtension();
}
HotwordServiceFactory::HotwordServiceFactory()
: BrowserContextKeyedServiceFactory(
"HotwordService",
BrowserContextDependencyManager::GetInstance()) {
}
HotwordServiceFactory::~HotwordServiceFactory() {
}
void HotwordServiceFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* prefs) {
prefs->RegisterBooleanPref(prefs::kHotwordSearchEnabled,
false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kHotwordOptInPopupTimesShown,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kHotwordAudioLoggingEnabled,
true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
}
KeyedService* HotwordServiceFactory::BuildServiceInstanceFor(
BrowserContext* context) const {
return new HotwordService(Profile::FromBrowserContext(context));
}