Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: chrome/browser/search/hotword_service.cc

Issue 158143002: Fine tuned availability of hotword plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/hotword_service.cc
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc
index 713f9f87a819ffae3d4945bdf7b120fd54fa6fc0..422224fac7a828fcbdf072997cff64cb0d19e63c 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -26,6 +26,21 @@ const char kHotwordFieldTrialName[] = "VoiceTrigger";
const char kHotwordFieldTrialDisabledGroupName[] = "Disabled";
} // namespace hotword_internal
+// static
+bool HotwordService::DoesLanguageSupportHotword(Profile* profile) {
+ std::string locale =
+#if defined(OS_CHROMEOS)
+ // On ChromeOS locale is per-profile.
+ profile->GetPrefs()->GetString(prefs::kApplicationLocale);
+#else
+ g_browser_process->GetApplicationLocale();
+#endif
+ // Only available for English now.
+ std::string normalized_locale = l10n_util::NormalizeLocale(locale);
+ return normalized_locale == "en" || normalized_locale == "en_us" ||
+ normalized_locale =="en_US";
+}
+
HotwordService::HotwordService(Profile* profile)
: profile_(profile) {
}
@@ -74,17 +89,7 @@ bool HotwordService::IsHotwordAllowed() {
hotword_internal::kHotwordFieldTrialName);
if (!group.empty() &&
group != hotword_internal::kHotwordFieldTrialDisabledGroupName) {
- std::string locale =
-#if defined(OS_CHROMEOS)
- // On ChromeOS locale is per-profile.
- profile_->GetPrefs()->GetString(prefs::kApplicationLocale);
-#else
- g_browser_process->GetApplicationLocale();
-#endif
- // Only available for English now.
- std::string normalized_locale = l10n_util::NormalizeLocale(locale);
- return normalized_locale == "en" || normalized_locale == "en_us" ||
- normalized_locale =="en_US";
+ return DoesLanguageSupportHotword(profile_);
rpetterson 2014/02/09 18:27:19 The if statement is no longer necessary. Just ret
Jun Mukai 2014/02/10 20:50:37 Done.
}
return false;
}

Powered by Google App Engine
This is Rietveld 408576698