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

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

Issue 1027683002: Hotword Private API: Add function and event to query the existence of a speaker model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 0fa9d0ddbc1eceff46bf0d68cb275b98bddef93e..53e1429bfe657b872ec2b9be870d0221ed7a5f2b 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -704,6 +704,33 @@ void HotwordService::DisableHotwordExtension(
}
}
+void HotwordService::SpeakerModelExistsComplete(bool exists) {
+ if (exists) {
+ profile_->GetPrefs()->
+ SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
+ } else {
+ LaunchHotwordAudioVerificationApp(HotwordService::HOTWORD_ONLY);
+ }
+}
+
+void HotwordService::OptIntoHotwording(
+ const LaunchMode& launch_mode) {
+ // First determine if we actually need to launch the app, or can just enable
+ // the pref. If Audio History has already been enabled, and we already have
+ // a speaker model, then we don't need to launch the app at all.
+ if (launch_mode == HotwordService::HOTWORD_ONLY) {
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(
+ profile_);
+ if (event_service) {
+ event_service->OnSpeakerModelExists();
+ return;
+ }
+ }
+
+ LaunchHotwordAudioVerificationApp(launch_mode);
+}
+
void HotwordService::LaunchHotwordAudioVerificationApp(
const LaunchMode& launch_mode) {
hotword_audio_verification_launch_mode_ = launch_mode;

Powered by Google App Engine
This is Rietveld 408576698