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

Side by Side Diff: trunk/src/chrome/browser/search/hotword_service.cc

Issue 340413003: Revert 277718 "[Hotword] Remove non-English languages due to fea..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 "en_us", 48 "de",
49 "fr",
50 "ru"
49 }; 51 };
50 52
51 // Enum describing the state of the hotword preference. 53 // Enum describing the state of the hotword preference.
52 // This is used for UMA stats -- do not reorder or delete items; only add to 54 // This is used for UMA stats -- do not reorder or delete items; only add to
53 // the end. 55 // the end.
54 enum HotwordEnabled { 56 enum HotwordEnabled {
55 UNSET = 0, // The hotword preference has not been set. 57 UNSET = 0, // The hotword preference has not been set.
56 ENABLED, // The hotword preference is enabled. 58 ENABLED, // The hotword preference is enabled.
57 DISABLED, // The hotword preference is disabled. 59 DISABLED, // The hotword preference is disabled.
58 NUM_HOTWORD_ENABLED_METRICS 60 NUM_HOTWORD_ENABLED_METRICS
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 #if defined(OS_CHROMEOS) 161 #if defined(OS_CHROMEOS)
160 // On ChromeOS locale is per-profile. 162 // On ChromeOS locale is per-profile.
161 profile->GetPrefs()->GetString(prefs::kApplicationLocale); 163 profile->GetPrefs()->GetString(prefs::kApplicationLocale);
162 #else 164 #else
163 g_browser_process->GetApplicationLocale(); 165 g_browser_process->GetApplicationLocale();
164 #endif 166 #endif
165 std::string normalized_locale = l10n_util::NormalizeLocale(locale); 167 std::string normalized_locale = l10n_util::NormalizeLocale(locale);
166 StringToLowerASCII(&normalized_locale); 168 StringToLowerASCII(&normalized_locale);
167 169
168 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) { 170 for (size_t i = 0; i < arraysize(kSupportedLocales); i++) {
169 if (kSupportedLocales[i] == normalized_locale) 171 if (normalized_locale.compare(0, 2, kSupportedLocales[i]) == 0)
170 return true; 172 return true;
171 } 173 }
172 return false; 174 return false;
173 } 175 }
174 176
175 HotwordService::HotwordService(Profile* profile) 177 HotwordService::HotwordService(Profile* profile)
176 : profile_(profile), 178 : profile_(profile),
177 client_(NULL), 179 client_(NULL),
178 error_message_(0) { 180 error_message_(0) {
179 // This will be called during profile initialization which is a good time 181 // This will be called during profile initialization which is a good time
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 364
363 DCHECK(client_ == client); 365 DCHECK(client_ == client);
364 366
365 client_ = NULL; 367 client_ = NULL;
366 HotwordPrivateEventService* event_service = 368 HotwordPrivateEventService* event_service =
367 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); 369 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
368 if (event_service) 370 if (event_service)
369 event_service->OnHotwordSessionStopped(); 371 event_service->OnHotwordSessionStopped();
370 #endif 372 #endif
371 } 373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698