Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / search / hotword_service_factory.cc
index 0cc83f8..571b4b3 100644 (file)
 
 // 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));
 }
@@ -36,6 +29,18 @@ bool HotwordServiceFactory::ShouldShowOptInPopup(Profile* profile) {
   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",
@@ -50,21 +55,10 @@ void HotwordServiceFactory::RegisterProfilePrefs(
     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(