diff options
author | rlp <rlp@chromium.org> | 2014-12-22 18:25:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-23 02:26:51 +0000 |
commit | 7b4f8bbadd0950e2a81e8687caebd7af5f4dcd14 (patch) | |
tree | 67a4029bb56ef0adfdf8d44f89e560fd0c4df324 | |
parent | 7f84b4cf686a5fc6e523f4f4bf3e750064dbc21c (diff) | |
download | chromium_src-7b4f8bbadd0950e2a81e8687caebd7af5f4dcd14.zip chromium_src-7b4f8bbadd0950e2a81e8687caebd7af5f4dcd14.tar.gz chromium_src-7b4f8bbadd0950e2a81e8687caebd7af5f4dcd14.tar.bz2 |
[Hotword] Don't show hotword options if search provider is not Google.
This CL moves the search provider check into the function which
determines how to display hotwording. Prior to this, it was only being
updated when the search provider was changed and other javascript could
come along and re-show the hotword section (even though it was now
supposed to be hidden). Now every time the hotwording should be
displayed, the search provider is checked beforehand. This is the
logically correct way to do it.
BUG=442938
Review URL: https://codereview.chromium.org/815683003
Cr-Commit-Position: refs/heads/master@{#309522}
-rw-r--r-- | chrome/browser/ui/webui/options/browser_options_handler.cc | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc index b807d16..9b97b8f 100644 --- a/chrome/browser/ui/webui/options/browser_options_handler.cc +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc @@ -1190,24 +1190,9 @@ void BrowserOptionsHandler::OnTemplateURLServiceChanged() { template_url_service_->is_default_search_managed() || template_url_service_->IsExtensionControlledDefaultSearch())); - if (default_index != -1 && model_urls[default_index]->HasGoogleBaseURLs( - template_url_service_->search_terms_data())) { - // If the user has chosen Google as the default search provider, make - // hotwording as an option available again. - HandleRequestHotwordAvailable(nullptr); - } else { - // If the user has chosen a default search provide other than Google, turn - // off hotwording since other providers don't provide that functionality. - web_ui()->CallJavascriptFunction( - "BrowserOptions.setAllHotwordSectionsVisible", - base::FundamentalValue(false)); - HotwordService* hotword_service = - HotwordServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); - if (hotword_service) - hotword_service->DisableHotwordPreferences(); - } - SetupExtensionControlledIndicators(); + + HandleRequestHotwordAvailable(nullptr); } void BrowserOptionsHandler::SetDefaultSearchEngine( @@ -1681,6 +1666,30 @@ void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( void BrowserOptionsHandler::HandleRequestHotwordAvailable( const base::ListValue* args) { Profile* profile = Profile::FromWebUI(web_ui()); + + bool is_search_provider_google = false; + if (template_url_service_) { + const TemplateURL* default_url = + template_url_service_->GetDefaultSearchProvider(); + if (default_url && default_url->HasGoogleBaseURLs( + template_url_service_->search_terms_data())) { + is_search_provider_google = true; + } + } + + if (!is_search_provider_google) { + // If the user has chosen a default search provide other than Google, turn + // off hotwording since other providers don't provide that functionality. + web_ui()->CallJavascriptFunction( + "BrowserOptions.setAllHotwordSectionsVisible", + base::FundamentalValue(false)); + HotwordService* hotword_service = + HotwordServiceFactory::GetForProfile(profile); + if (hotword_service) + hotword_service->DisableHotwordPreferences(); + return; + } + std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); if (group != "" && group != "Disabled" && HotwordServiceFactory::IsHotwordAllowed(profile)) { |