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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 ExtensionService* GetExtensionService(Profile* profile) { | 136 ExtensionService* GetExtensionService(Profile* profile) { |
137 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 137 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
138 | 138 |
139 extensions::ExtensionSystem* extension_system = | 139 extensions::ExtensionSystem* extension_system = |
140 extensions::ExtensionSystem::Get(profile); | 140 extensions::ExtensionSystem::Get(profile); |
141 return extension_system ? extension_system->extension_service() : NULL; | 141 return extension_system ? extension_system->extension_service() : NULL; |
142 } | 142 } |
143 | 143 |
144 std::string GetCurrentLocale(Profile* profile) { | 144 std::string GetCurrentLocale(Profile* profile) { |
145 std::string locale = | |
146 #if defined(OS_CHROMEOS) | 145 #if defined(OS_CHROMEOS) |
147 // On ChromeOS locale is per-profile. | 146 std::string profile_locale = |
148 profile->GetPrefs()->GetString(prefs::kApplicationLocale); | 147 profile->GetPrefs()->GetString(prefs::kApplicationLocale); |
149 #else | 148 if (!profile_locale.empty()) { |
150 g_browser_process->GetApplicationLocale(); | 149 // On ChromeOS locale is per-profile, but only if set. |
| 150 return profile_locale; |
| 151 } |
151 #endif | 152 #endif |
152 return locale; | 153 return g_browser_process->GetApplicationLocale(); |
153 } | 154 } |
154 | 155 |
155 } // namespace | 156 } // namespace |
156 | 157 |
157 namespace hotword_internal { | 158 namespace hotword_internal { |
158 // Constants for the hotword field trial. | 159 // Constants for the hotword field trial. |
159 const char kHotwordFieldTrialName[] = "VoiceTrigger"; | 160 const char kHotwordFieldTrialName[] = "VoiceTrigger"; |
160 const char kHotwordFieldTrialDisabledGroupName[] = "Disabled"; | 161 const char kHotwordFieldTrialDisabledGroupName[] = "Disabled"; |
161 // Old preference constant. | 162 // Old preference constant. |
162 const char kHotwordUnusablePrefName[] = "hotword.search_enabled"; | 163 const char kHotwordUnusablePrefName[] = "hotword.search_enabled"; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 return false; | 492 return false; |
492 | 493 |
493 std::string previous_locale = | 494 std::string previous_locale = |
494 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 495 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
495 std::string locale = GetCurrentLocale(profile_); | 496 std::string locale = GetCurrentLocale(profile_); |
496 | 497 |
497 // If it's a new locale, then the old extension should be uninstalled. | 498 // If it's a new locale, then the old extension should be uninstalled. |
498 return locale != previous_locale && | 499 return locale != previous_locale && |
499 HotwordService::DoesHotwordSupportLanguage(profile_); | 500 HotwordService::DoesHotwordSupportLanguage(profile_); |
500 } | 501 } |
OLD | NEW |