// static
HotwordService* HotwordServiceFactory::GetForProfile(Profile* profile) {
- if (!profile ||
- (profile->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled) &&
- !profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) ||
- (profile->IsOffTheRecord() &&
- !profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchIncognitoEnabled)))
- return NULL;
-
return static_cast<HotwordService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
return hotword_service && hotword_service->ShouldShowOptInPopup();
}
+// static
+bool HotwordServiceFactory::IsServiceAvailable(Profile* profile) {
+ HotwordService* hotword_service = GetForProfile(profile);
+ return hotword_service && hotword_service->IsServiceAvailable();
+}
+
+// static
+bool HotwordServiceFactory::IsHotwordAllowed(Profile* profile) {
+ HotwordService* hotword_service = GetForProfile(profile);
+ return hotword_service && hotword_service->IsHotwordAllowed();
+}
+
HotwordServiceFactory::HotwordServiceFactory()
: BrowserContextKeyedServiceFactory(
"HotwordService",
user_prefs::PrefRegistrySyncable* prefs) {
prefs->RegisterBooleanPref(prefs::kHotwordSearchEnabled,
false,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
- prefs->RegisterBooleanPref(prefs::kHotwordSearchIncognitoEnabled,
- false,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kHotwordOptInPopupTimesShown,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
- prefs->RegisterBooleanPref(prefs::kHotwordSearchTimeoutEnabled,
- true,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-}
-
-content::BrowserContext* HotwordServiceFactory::GetBrowserContextToUse(
- content::BrowserContext* context) const {
- return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
BrowserContextKeyedService* HotwordServiceFactory::BuildServiceInstanceFor(