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 27 matching lines...) Expand all Loading... |
38 #if defined(ENABLE_EXTENSIONS) | 38 #if defined(ENABLE_EXTENSIONS) |
39 using extensions::BrowserContextKeyedAPIFactory; | 39 using extensions::BrowserContextKeyedAPIFactory; |
40 using extensions::HotwordPrivateEventService; | 40 using extensions::HotwordPrivateEventService; |
41 #endif | 41 #endif |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Allowed languages for hotwording. | 45 // Allowed languages for hotwording. |
46 static const char* kSupportedLocales[] = { | 46 static const char* kSupportedLocales[] = { |
47 "en", | 47 "en", |
48 "de", | 48 "en_us", |
49 "fr", | |
50 "ru" | |
51 }; | 49 }; |
52 | 50 |
53 // Enum describing the state of the hotword preference. | 51 // Enum describing the state of the hotword preference. |
54 // This is used for UMA stats -- do not reorder or delete items; only add to | 52 // This is used for UMA stats -- do not reorder or delete items; only add to |
55 // the end. | 53 // the end. |
56 enum HotwordEnabled { | 54 enum HotwordEnabled { |
57 UNSET = 0, // The hotword preference has not been set. | 55 UNSET = 0, // The hotword preference has not been set. |
58 ENABLED, // The hotword preference is enabled. | 56 ENABLED, // The hotword preference is enabled. |
59 DISABLED, // The hotword preference is disabled. | 57 DISABLED, // The hotword preference is disabled. |
60 NUM_HOTWORD_ENABLED_METRICS | 58 NUM_HOTWORD_ENABLED_METRICS |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
162 // On ChromeOS locale is per-profile. | 160 // On ChromeOS locale is per-profile. |
163 profile->GetPrefs()->GetString(prefs::kApplicationLocale); | 161 profile->GetPrefs()->GetString(prefs::kApplicationLocale); |
164 #else | 162 #else |
165 g_browser_process->GetApplicationLocale(); | 163 g_browser_process->GetApplicationLocale(); |
166 #endif | 164 #endif |
167 std::string normalized_locale = l10n_util::NormalizeLocale(locale); | 165 std::string normalized_locale = l10n_util::NormalizeLocale(locale); |
168 StringToLowerASCII(&normalized_locale); | 166 StringToLowerASCII(&normalized_locale); |
169 | 167 |
170 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) { | 168 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) { |
171 if (normalized_locale.compare(0, 2, kSupportedLocales[i]) == 0) | 169 if (kSupportedLocales[i] == normalized_locale) |
172 return true; | 170 return true; |
173 } | 171 } |
174 return false; | 172 return false; |
175 } | 173 } |
176 | 174 |
177 HotwordService::HotwordService(Profile* profile) | 175 HotwordService::HotwordService(Profile* profile) |
178 : profile_(profile), | 176 : profile_(profile), |
179 client_(NULL), | 177 client_(NULL), |
180 error_message_(0) { | 178 error_message_(0) { |
181 // This will be called during profile initialization which is a good time | 179 // This will be called during profile initialization which is a good time |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 362 |
365 DCHECK(client_ == client); | 363 DCHECK(client_ == client); |
366 | 364 |
367 client_ = NULL; | 365 client_ = NULL; |
368 HotwordPrivateEventService* event_service = | 366 HotwordPrivateEventService* event_service = |
369 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); | 367 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
370 if (event_service) | 368 if (event_service) |
371 event_service->OnHotwordSessionStopped(); | 369 event_service->OnHotwordSessionStopped(); |
372 #endif | 370 #endif |
373 } | 371 } |
OLD | NEW |