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

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

Issue 992173002: Delete the old hotwording integration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hotword-remove-disable-option
Patch Set: Rebase. Created 5 years, 9 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/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();
}
}
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.cc ('k') | chrome/browser/ui/webui/app_list/start_page_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698