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

Unified Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 631913004: Open the launcher when hotword is triggered in always-on mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hotword-google-com-ntp
Patch Set: Address review comments. 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/ui/app_list/app_list_view_delegate.cc
diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc
index c1620a878ae6a78865c34716701c8ec8cbc8be4b..83b8e09d787fa0a448f05ae99092799ecb2bc784 100644
--- a/chrome/browser/ui/app_list/app_list_view_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc
@@ -472,8 +472,22 @@ void AppListViewDelegate::ViewClosing() {
if (service->HotwordEnabled()) {
HotwordService* hotword_service =
HotwordServiceFactory::GetForProfile(profile_);
- if (hotword_service)
+ if (hotword_service) {
hotword_service->StopHotwordSession(this);
+
+ // If we're in always-on mode, we always want to restart hotwording
+ // after closing the launcher window. So, in always-on mode, hotwording
+ // is stopped, and then started again right away. Note that hotwording
+ // may already be stopped. The call to StopHotwordSession() above both
+ // explicitly stops hotwording, if it's running, and clears the
+ // association between the hotword service and 'this'. When starting up
Matt Giuca 2014/10/13 22:45:00 nit: Write |this| instead of 'this'.
Anand Mistry (off Chromium) 2014/10/13 22:56:14 Done.
+ // hotwording, pass NULL as the client so that hotword triggers cause
+ // the launcher to open.
+ // TODO(amistry): This only works on ChromeOS since Chrome hides the
+ // launcher instead of destroying it. Make this work on Chrome.
+ if (hotword_service->IsAlwaysOnEnabled())
+ hotword_service->RequestHotwordSession(NULL);
Matt Giuca 2014/10/13 22:45:00 nit: Use nullptr. Also change the above comment.
Anand Mistry (off Chromium) 2014/10/13 22:56:14 Done.
+ }
}
}
}
@@ -519,6 +533,23 @@ void AppListViewDelegate::ToggleSpeechRecognition() {
app_list::StartPageService::Get(profile_);
if (service)
service->ToggleSpeechRecognition();
+
+ // With the new hotword extension, stop the hotword session. With the launcher
+ // and NTP, this is unnecessary since the hotwording is implicitly stopped.
+ // However, for always on, hotword triggering launches the launcher which
+ // starts a session and hence starts the hotword detector. This results in the
+ // hotword detector and the speech-to-text engine running in parallel, which
+ // will conflict with each other (i.e. saying 'Ok Google' twice in a row
+ // should cause a search to happen for 'Ok Google', not two hotword triggers).
+ // To get around this, always stop the session when switching to speech
+ // recognition.
+ if (HotwordService::IsExperimentalHotwordingEnabled() &&
+ service && service->HotwordEnabled()) {
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(profile_);
+ if (hotword_service)
+ hotword_service->StopHotwordSession(this);
+ }
}
void AppListViewDelegate::ShowForProfileByPath(
@@ -547,10 +578,12 @@ void AppListViewDelegate::OnSpeechRecognitionStateChanged(
app_list::StartPageService* service =
app_list::StartPageService::Get(profile_);
// With the new hotword extension, we need to re-request hotwording after
- // speech recognition has stopped.
+ // speech recognition has stopped. Do not request hotwording after the app
+ // list has already closed.
if (new_state == app_list::SPEECH_RECOGNITION_READY &&
HotwordService::IsExperimentalHotwordingEnabled() &&
- service && service->HotwordEnabled()) {
+ service && service->HotwordEnabled() &&
+ controller_->GetAppListWindow()) {
HotwordService* hotword_service =
HotwordServiceFactory::GetForProfile(profile_);
if (hotword_service) {
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_impl.cc ('k') | chrome/browser/ui/app_list/start_page_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698