| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/search/hotword_service.h" | 5 #include "chrome/browser/search/hotword_service.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 const char kHotwordFieldTrialName[] = "VoiceTrigger"; | 166 const char kHotwordFieldTrialName[] = "VoiceTrigger"; |
| 167 const char kHotwordFieldTrialDisabledGroupName[] = "Disabled"; | 167 const char kHotwordFieldTrialDisabledGroupName[] = "Disabled"; |
| 168 // Old preference constant. | 168 // Old preference constant. |
| 169 const char kHotwordUnusablePrefName[] = "hotword.search_enabled"; | 169 const char kHotwordUnusablePrefName[] = "hotword.search_enabled"; |
| 170 } // namespace hotword_internal | 170 } // namespace hotword_internal |
| 171 | 171 |
| 172 // static | 172 // static |
| 173 bool HotwordService::DoesHotwordSupportLanguage(Profile* profile) { | 173 bool HotwordService::DoesHotwordSupportLanguage(Profile* profile) { |
| 174 std::string normalized_locale = | 174 std::string normalized_locale = |
| 175 l10n_util::NormalizeLocale(GetCurrentLocale(profile)); | 175 l10n_util::NormalizeLocale(GetCurrentLocale(profile)); |
| 176 StringToLowerASCII(&normalized_locale); | 176 base::StringToLowerASCII(&normalized_locale); |
| 177 | 177 |
| 178 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) { | 178 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) { |
| 179 if (normalized_locale.compare(0, 2, kSupportedLocales[i]) == 0) | 179 if (normalized_locale.compare(0, 2, kSupportedLocales[i]) == 0) |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 HotwordService::HotwordService(Profile* profile) | 185 HotwordService::HotwordService(Profile* profile) |
| 186 : profile_(profile), | 186 : profile_(profile), |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 return false; | 503 return false; |
| 504 | 504 |
| 505 std::string previous_locale = | 505 std::string previous_locale = |
| 506 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 506 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
| 507 std::string locale = GetCurrentLocale(profile_); | 507 std::string locale = GetCurrentLocale(profile_); |
| 508 | 508 |
| 509 // If it's a new locale, then the old extension should be uninstalled. | 509 // If it's a new locale, then the old extension should be uninstalled. |
| 510 return locale != previous_locale && | 510 return locale != previous_locale && |
| 511 HotwordService::DoesHotwordSupportLanguage(profile_); | 511 HotwordService::DoesHotwordSupportLanguage(profile_); |
| 512 } | 512 } |
| OLD | NEW |