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

Side by Side 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: Fix android build 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "apps/custom_launcher_page_contents.h" 9 #include "apps/custom_launcher_page_contents.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 if (!profile_) 465 if (!profile_)
466 return; 466 return;
467 467
468 app_list::StartPageService* service = 468 app_list::StartPageService* service =
469 app_list::StartPageService::Get(profile_); 469 app_list::StartPageService::Get(profile_);
470 if (service) { 470 if (service) {
471 service->AppListHidden(); 471 service->AppListHidden();
472 if (service->HotwordEnabled()) { 472 if (service->HotwordEnabled()) {
473 HotwordService* hotword_service = 473 HotwordService* hotword_service =
474 HotwordServiceFactory::GetForProfile(profile_); 474 HotwordServiceFactory::GetForProfile(profile_);
475 if (hotword_service) 475 if (hotword_service) {
476 hotword_service->StopHotwordSession(this); 476 hotword_service->StopHotwordSession(this);
477
478 // If we're in always-on mode, we always want to restart hotwording
479 // after closing the launcher window. So, in always-on mode, hotwording
480 // is stopped, and then started again right away. Note that hotwording
481 // may already be stopped. The call to StopHotwordSession() above both
482 // explicitly stops hotwording, if it's running, and clears the
483 // association between the hotword service and |this|. When starting up
484 // hotwording, pass nullptr as the client so that hotword triggers cause
485 // the launcher to open.
486 // TODO(amistry): This only works on ChromeOS since Chrome hides the
487 // launcher instead of destroying it. Make this work on Chrome.
488 if (hotword_service->IsAlwaysOnEnabled())
489 hotword_service->RequestHotwordSession(nullptr);
490 }
477 } 491 }
478 } 492 }
479 } 493 }
480 494
481 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { 495 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() {
482 return controller_->GetWindowIcon(); 496 return controller_->GetWindowIcon();
483 } 497 }
484 498
485 void AppListViewDelegate::OpenSettings() { 499 void AppListViewDelegate::OpenSettings() {
486 const extensions::Extension* extension = 500 const extensions::Extension* extension =
(...skipping 25 matching lines...) Expand all
512 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); 526 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop);
513 chrome::ShowFeedbackPage(browser, std::string(), 527 chrome::ShowFeedbackPage(browser, std::string(),
514 chrome::kAppLauncherCategoryTag); 528 chrome::kAppLauncherCategoryTag);
515 } 529 }
516 530
517 void AppListViewDelegate::ToggleSpeechRecognition() { 531 void AppListViewDelegate::ToggleSpeechRecognition() {
518 app_list::StartPageService* service = 532 app_list::StartPageService* service =
519 app_list::StartPageService::Get(profile_); 533 app_list::StartPageService::Get(profile_);
520 if (service) 534 if (service)
521 service->ToggleSpeechRecognition(); 535 service->ToggleSpeechRecognition();
536
537 // With the new hotword extension, stop the hotword session. With the launcher
538 // and NTP, this is unnecessary since the hotwording is implicitly stopped.
539 // However, for always on, hotword triggering launches the launcher which
540 // starts a session and hence starts the hotword detector. This results in the
541 // hotword detector and the speech-to-text engine running in parallel, which
542 // will conflict with each other (i.e. saying 'Ok Google' twice in a row
543 // should cause a search to happen for 'Ok Google', not two hotword triggers).
544 // To get around this, always stop the session when switching to speech
545 // recognition.
546 if (HotwordService::IsExperimentalHotwordingEnabled() &&
547 service && service->HotwordEnabled()) {
548 HotwordService* hotword_service =
549 HotwordServiceFactory::GetForProfile(profile_);
550 if (hotword_service)
551 hotword_service->StopHotwordSession(this);
552 }
522 } 553 }
523 554
524 void AppListViewDelegate::ShowForProfileByPath( 555 void AppListViewDelegate::ShowForProfileByPath(
525 const base::FilePath& profile_path) { 556 const base::FilePath& profile_path) {
526 controller_->ShowForProfileByPath(profile_path); 557 controller_->ShowForProfileByPath(profile_path);
527 } 558 }
528 559
529 void AppListViewDelegate::OnSpeechResult(const base::string16& result, 560 void AppListViewDelegate::OnSpeechResult(const base::string16& result,
530 bool is_final) { 561 bool is_final) {
531 speech_ui_->SetSpeechResult(result, is_final); 562 speech_ui_->SetSpeechResult(result, is_final);
532 if (is_final) { 563 if (is_final) {
533 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( 564 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds(
534 kAutoLaunchDefaultTimeoutMilliSec); 565 kAutoLaunchDefaultTimeoutMilliSec);
535 model_->search_box()->SetText(result); 566 model_->search_box()->SetText(result);
536 } 567 }
537 } 568 }
538 569
539 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { 570 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) {
540 speech_ui_->UpdateSoundLevel(level); 571 speech_ui_->UpdateSoundLevel(level);
541 } 572 }
542 573
543 void AppListViewDelegate::OnSpeechRecognitionStateChanged( 574 void AppListViewDelegate::OnSpeechRecognitionStateChanged(
544 app_list::SpeechRecognitionState new_state) { 575 app_list::SpeechRecognitionState new_state) {
545 speech_ui_->SetSpeechRecognitionState(new_state); 576 speech_ui_->SetSpeechRecognitionState(new_state);
546 577
547 app_list::StartPageService* service = 578 app_list::StartPageService* service =
548 app_list::StartPageService::Get(profile_); 579 app_list::StartPageService::Get(profile_);
549 // With the new hotword extension, we need to re-request hotwording after 580 // With the new hotword extension, we need to re-request hotwording after
550 // speech recognition has stopped. 581 // speech recognition has stopped. Do not request hotwording after the app
582 // list has already closed.
551 if (new_state == app_list::SPEECH_RECOGNITION_READY && 583 if (new_state == app_list::SPEECH_RECOGNITION_READY &&
552 HotwordService::IsExperimentalHotwordingEnabled() && 584 HotwordService::IsExperimentalHotwordingEnabled() &&
553 service && service->HotwordEnabled()) { 585 service && service->HotwordEnabled() &&
586 controller_->GetAppListWindow()) {
554 HotwordService* hotword_service = 587 HotwordService* hotword_service =
555 HotwordServiceFactory::GetForProfile(profile_); 588 HotwordServiceFactory::GetForProfile(profile_);
556 if (hotword_service) { 589 if (hotword_service) {
557 hotword_service->RequestHotwordSession(this); 590 hotword_service->RequestHotwordSession(this);
558 } 591 }
559 } 592 }
560 } 593 }
561 594
562 #if defined(TOOLKIT_VIEWS) 595 #if defined(TOOLKIT_VIEWS)
563 views::View* AppListViewDelegate::CreateStartPageWebView( 596 views::View* AppListViewDelegate::CreateStartPageWebView(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 695
663 // SigninManagerFactory is not a leaky singleton (unlike this class), and 696 // SigninManagerFactory is not a leaky singleton (unlike this class), and
664 // its destructor will check that it has no remaining observers. 697 // its destructor will check that it has no remaining observers.
665 scoped_observer_.RemoveAll(); 698 scoped_observer_.RemoveAll();
666 SigninManagerFactory::GetInstance()->RemoveObserver(this); 699 SigninManagerFactory::GetInstance()->RemoveObserver(this);
667 break; 700 break;
668 default: 701 default:
669 NOTREACHED(); 702 NOTREACHED();
670 } 703 }
671 } 704 }
OLDNEW
« 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