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

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: fix 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..544974f17fc93899b288abe5d6cef57188c3d723 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::DoesHotwordSupportLanguage(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) {
}
@@ -72,19 +87,7 @@ bool HotwordService::IsServiceAvailable() {
bool HotwordService::IsHotwordAllowed() {
std::string group = base::FieldTrialList::FindFullName(
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 false;
+ return !group.empty() &&
+ group != hotword_internal::kHotwordFieldTrialDisabledGroupName &&
+ DoesHotwordSupportLanguage(profile_);
}

Powered by Google App Engine
This is Rietveld 408576698