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

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: Rebase 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
« no previous file with comments | « chrome/browser/search/hotword_service.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/hotword_service.cc
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc
index d90f68243677e3519d66b3185036076d857af370..8e6f4699fd6e387ff105ee776a2420dae9fc4716 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -163,6 +163,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
@@ -190,6 +192,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
@@ -477,6 +480,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));
« no previous file with comments | « chrome/browser/search/hotword_service.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698