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; |