| Index: chrome/browser/ui/app_list/start_page_service.cc
|
| diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc
|
| index b8af9bd5f3656fb6fab272a425c34731fd487bda..1d13df3ef70924183649b3995a9f1e1c72008dab 100644
|
| --- a/chrome/browser/ui/app_list/start_page_service.cc
|
| +++ b/chrome/browser/ui/app_list/start_page_service.cc
|
| @@ -11,11 +11,13 @@
|
| #include "base/memory/singleton.h"
|
| #include "base/metrics/user_metrics.h"
|
| #include "base/prefs/pref_service.h"
|
| +#include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/media/media_stream_infobar_delegate.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/search/hotword_service.h"
|
| #include "chrome/browser/search/hotword_service_factory.h"
|
| +#include "chrome/browser/ui/app_list/app_list_speech_recognizer.h"
|
| #include "chrome/browser/ui/app_list/recommended_apps.h"
|
| #include "chrome/browser/ui/app_list/start_page_observer.h"
|
| #include "chrome/browser/ui/app_list/start_page_service_factory.h"
|
| @@ -136,7 +138,8 @@ void StartPageService::RemoveObserver(StartPageObserver* observer) {
|
| void StartPageService::AppListShown() {
|
| if (!contents_) {
|
| LoadContents();
|
| - } else if (contents_->GetWebUI()) {
|
| + } else if (contents_->GetWebUI() &&
|
| + !HotwordService::IsExperimentalHotwordingEnabled()) {
|
| // If experimental hotwording is enabled, don't enable hotwording in the
|
| // start page, since the hotword extension is taking care of this.
|
| bool hotword_enabled = HotwordEnabled() &&
|
| @@ -154,6 +157,11 @@ void StartPageService::AppListHidden() {
|
| }
|
| if (!app_list::switches::IsExperimentalAppListEnabled())
|
| UnloadContents();
|
| +
|
| + if (HotwordService::IsExperimentalHotwordingEnabled() &&
|
| + speech_recognizer_.get()) {
|
| + speech_recognizer_->Stop();
|
| + }
|
| }
|
|
|
| void StartPageService::ToggleSpeechRecognition() {
|
| @@ -162,14 +170,32 @@ void StartPageService::ToggleSpeechRecognition() {
|
| if (!contents_->GetWebUI())
|
| return;
|
|
|
| - if (webui_finished_loading_) {
|
| - contents_->GetWebUI()->CallJavascriptFunction(
|
| - "appList.startPage.toggleSpeechRecognition");
|
| - } else {
|
| + if (!webui_finished_loading_) {
|
| pending_webui_callbacks_.push_back(
|
| base::Bind(&StartPageService::ToggleSpeechRecognition,
|
| base::Unretained(this)));
|
| + return;
|
| }
|
| +
|
| + if (HotwordService::IsExperimentalHotwordingEnabled()) {
|
| + if (!speech_recognizer_.get()) {
|
| + std::string profile_locale;
|
| +#if defined(OS_CHROMEOS)
|
| + profile_locale = profile_->GetPrefs()->GetString(
|
| + prefs::kApplicationLocale);
|
| +#endif
|
| + if (profile_locale.empty())
|
| + profile_locale = g_browser_process->GetApplicationLocale();
|
| +
|
| + speech_recognizer_ = new AppListSpeechRecognizer(this, profile_locale);
|
| + }
|
| +
|
| + speech_recognizer_->Start();
|
| + return;
|
| + }
|
| +
|
| + contents_->GetWebUI()->CallJavascriptFunction(
|
| + "appList.startPage.toggleSpeechRecognition");
|
| }
|
|
|
| bool StartPageService::HotwordEnabled() {
|
| @@ -218,6 +244,13 @@ void StartPageService::OnSpeechSoundLevelChanged(int16 level) {
|
|
|
| void StartPageService::OnSpeechRecognitionStateChanged(
|
| SpeechRecognitionState new_state) {
|
| +
|
| + if (HotwordService::IsExperimentalHotwordingEnabled() &&
|
| + new_state == SPEECH_RECOGNITION_READY &&
|
| + speech_recognizer_.get()) {
|
| + speech_recognizer_->Stop();
|
| + }
|
| +
|
| if (!InSpeechRecognition(state_) && InSpeechRecognition(new_state)) {
|
| if (!speech_button_toggled_manually_ &&
|
| state_ == SPEECH_RECOGNITION_HOTWORD_LISTENING) {
|
|
|