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 8af8b471a405b28f535d746cbcfef4beb15ee165..dc7e805c96c46d3fa530008cf6aca1e1ac9eec0e 100644 |
--- a/chrome/browser/ui/app_list/start_page_service.cc |
+++ b/chrome/browser/ui/app_list/start_page_service.cc |
@@ -281,7 +281,7 @@ StartPageService* StartPageService::Get(Profile* profile) { |
StartPageService::StartPageService(Profile* profile) |
: profile_(profile), |
profile_destroy_observer_(new ProfileDestroyObserver(this)), |
- state_(app_list::SPEECH_RECOGNITION_OFF), |
+ state_(app_list::SPEECH_RECOGNITION_READY), |
speech_button_toggled_manually_(false), |
speech_result_obtained_(false), |
webui_finished_loading_(false), |
@@ -290,12 +290,6 @@ StartPageService::StartPageService(Profile* profile) |
microphone_available_(true), |
search_engine_is_google_(false), |
weak_factory_(this) { |
- // If experimental hotwording is enabled, then we're always "ready". |
- // Transitioning into the "hotword recognizing" state is handled by the |
- // hotword extension. |
- if (HotwordService::IsExperimentalHotwordingEnabled()) { |
- state_ = app_list::SPEECH_RECOGNITION_READY; |
- } |
if (switches::IsExperimentalAppListEnabled()) { |
TemplateURLService* template_url_service = |
TemplateURLServiceFactory::GetForProfile(profile_); |
@@ -369,14 +363,8 @@ void StartPageService::AppListShown() { |
} else if (contents_->IsCrashed()) { |
LoadStartPageURL(); |
} else if (contents_->GetWebUI()) { |
- // If experimental hotwording is enabled, don't initialize the web speech |
- // API, which is not used with |
- // experimental hotwording. |
contents_->GetWebUI()->CallJavascriptFunction( |
- "appList.startPage.onAppListShown", |
- base::FundamentalValue(HotwordEnabled()), |
- base::FundamentalValue( |
- !HotwordService::IsExperimentalHotwordingEnabled())); |
+ "appList.startPage.onAppListShown"); |
} |
#if defined(OS_CHROMEOS) |
@@ -385,15 +373,10 @@ void StartPageService::AppListShown() { |
} |
void StartPageService::AppListHidden() { |
- if (contents_->GetWebUI()) { |
- contents_->GetWebUI()->CallJavascriptFunction( |
- "appList.startPage.onAppListHidden"); |
- } |
if (!app_list::switches::IsExperimentalAppListEnabled()) |
UnloadContents(); |
- if (HotwordService::IsExperimentalHotwordingEnabled() && |
- speech_recognizer_) { |
+ if (speech_recognizer_) { |
speech_recognizer_->Stop(); |
speech_recognizer_.reset(); |
@@ -414,58 +397,33 @@ void StartPageService::ToggleSpeechRecognition( |
DCHECK(contents_); |
speech_button_toggled_manually_ = true; |
- // Speech recognition under V2 hotwording does not depend in any way on the |
- // start page web contents. Do this code path first to make this explicit and |
- // easier to identify what code needs to be deleted when V2 hotwording is |
- // stable. |
- if (HotwordService::IsExperimentalHotwordingEnabled()) { |
- if (!speech_recognizer_) { |
- std::string profile_locale; |
+ if (!speech_recognizer_) { |
+ std::string profile_locale; |
#if defined(OS_CHROMEOS) |
- profile_locale = profile_->GetPrefs()->GetString( |
- prefs::kApplicationLocale); |
+ profile_locale = profile_->GetPrefs()->GetString( |
+ prefs::kApplicationLocale); |
#endif |
- if (profile_locale.empty()) |
- profile_locale = g_browser_process->GetApplicationLocale(); |
- |
- speech_recognizer_.reset( |
- new SpeechRecognizer(weak_factory_.GetWeakPtr(), |
- profile_->GetRequestContext(), |
- profile_locale)); |
- } |
- |
- speech_recognizer_->Start(preamble); |
- return; |
- } |
- |
- if (!contents_->GetWebUI()) |
- return; |
+ if (profile_locale.empty()) |
+ profile_locale = g_browser_process->GetApplicationLocale(); |
- if (!webui_finished_loading_) { |
- pending_webui_callbacks_.push_back( |
- base::Bind(&StartPageService::ToggleSpeechRecognition, |
- base::Unretained(this), |
- preamble)); |
- return; |
+ speech_recognizer_.reset( |
+ new SpeechRecognizer(weak_factory_.GetWeakPtr(), |
+ profile_->GetRequestContext(), |
+ profile_locale)); |
} |
- contents_->GetWebUI()->CallJavascriptFunction( |
- "appList.startPage.toggleSpeechRecognition"); |
+ speech_recognizer_->Start(preamble); |
} |
bool StartPageService::HotwordEnabled() { |
// Voice input for the launcher is unsupported on non-ChromeOS platforms. |
// TODO(amistry): Make speech input, and hotwording, work on non-ChromeOS. |
#if defined(OS_CHROMEOS) |
- if (HotwordService::IsExperimentalHotwordingEnabled()) { |
- HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); |
- return state_ != SPEECH_RECOGNITION_OFF && |
- service && |
- (service->IsSometimesOnEnabled() || service->IsAlwaysOnEnabled()) && |
- service->IsServiceAvailable(); |
- } |
- return HotwordServiceFactory::IsServiceAvailable(profile_) && |
- profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled); |
+ HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); |
+ return state_ != SPEECH_RECOGNITION_OFF && |
+ service && |
+ (service->IsSometimesOnEnabled() || service->IsAlwaysOnEnabled()) && |
+ service->IsServiceAvailable(); |
#else |
return false; |
#endif |
@@ -515,8 +473,7 @@ void StartPageService::OnSpeechRecognitionStateChanged( |
if (state_ == new_state) |
return; |
- if (HotwordService::IsExperimentalHotwordingEnabled() && |
- (new_state == SPEECH_RECOGNITION_READY || |
+ if ((new_state == SPEECH_RECOGNITION_READY || |
new_state == SPEECH_RECOGNITION_OFF) && |
speech_recognizer_) { |
speech_recognizer_->Stop(); |
@@ -543,15 +500,13 @@ void StartPageService::OnSpeechRecognitionStateChanged( |
void StartPageService::GetSpeechAuthParameters(std::string* auth_scope, |
std::string* auth_token) { |
- if (HotwordService::IsExperimentalHotwordingEnabled()) { |
- HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); |
- if (service && |
- service->IsOptedIntoAudioLogging() && |
- service->IsAlwaysOnEnabled() && |
- !speech_auth_helper_->GetToken().empty()) { |
- *auth_scope = speech_auth_helper_->GetScope(); |
- *auth_token = speech_auth_helper_->GetToken(); |
- } |
+ HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); |
+ if (service && |
+ service->IsOptedIntoAudioLogging() && |
+ service->IsAlwaysOnEnabled() && |
+ !speech_auth_helper_->GetToken().empty()) { |
+ *auth_scope = speech_auth_helper_->GetScope(); |
+ *auth_token = speech_auth_helper_->GetToken(); |
} |
} |