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

Unified Diff: chrome/browser/search/hotword_service.cc

Issue 686333002: Hotword Private API: Adds speech training functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for Finalize Speaker Model Created 6 years, 2 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 b530ae6d1d3b1b6e83c0842a76e51e27b8743f3b..71521db5b98562f13777e0759be837412dfe4a29 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -162,6 +162,8 @@ const char kHotwordFieldTrialName[] = "VoiceTrigger";
const char kHotwordFieldTrialDisabledGroupName[] = "Disabled";
// Old preference constant.
const char kHotwordUnusablePrefName[] = "hotword.search_enabled";
+// String passed to indicate the training state has changed.
+const char kHotwordTrainingEnabled[] = "hotword_training_enabled";
} // namespace hotword_internal
// static
@@ -189,6 +191,7 @@ HotwordService::HotwordService(Profile* profile)
client_(NULL),
error_message_(0),
reinstall_pending_(false),
+ training_(false),
weak_factory_(this) {
extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile));
// This will be called during profile initialization which is a good time
@@ -474,6 +477,54 @@ HotwordService::GetHotwordAudioVerificationLaunchMode() {
return hotword_audio_verification_launch_mode_;
}
+void HotwordService::StartTraining() {
+ training_ = true;
+
+ if (!IsServiceAvailable())
+ return;
+
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnEnabledChanged(hotword_internal::kHotwordTrainingEnabled);
+}
+
+void HotwordService::FinalizeSpeakerModel() {
+ if (!IsServiceAvailable())
+ return;
+
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnFinalizeSpeakerModel();
+}
+
+void HotwordService::StopTraining() {
+ training_ = false;
+
+ if (!IsServiceAvailable())
+ return;
+
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnEnabledChanged(hotword_internal::kHotwordTrainingEnabled);
+}
+
+void HotwordService::NotifyHotwordTriggered() {
+ if (!IsServiceAvailable())
+ return;
+
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnHotwordTriggered();
+}
+
+bool HotwordService::IsTraining() {
+ return training_;
+}
+
void HotwordService::OnHotwordSearchEnabledChanged(
const std::string& pref_name) {
DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled));

Powered by Google App Engine
This is Rietveld 408576698