+ if (!contents_->GetWebUI())
+ return;
+
+ if (!webui_finished_loading_) {
+ pending_webui_callbacks_.push_back(
+ base::Bind(&StartPageService::ToggleSpeechRecognition,
+ base::Unretained(this)));
+ return;
+ }
+
+ if (HotwordService::IsExperimentalHotwordingEnabled()) {
+ if (!speech_recognizer_) {
+ 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_.reset(
+ new SpeechRecognizer(weak_factory_.GetWeakPtr(),
+ profile_->GetRequestContext(),
+ profile_locale));
+ }
+
+ speech_recognizer_->Start();
+ return;
+ }
+