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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 693393004: Add error indicators to always-on andno-dsp hotword checkboxes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove error conditions used for testing Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false); 1614 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false);
1615 web_ui()->GetWebContents()->OpenURL(params); 1615 web_ui()->GetWebContents()->OpenURL(params);
1616 } 1616 }
1617 1617
1618 #endif 1618 #endif
1619 1619
1620 void BrowserOptionsHandler::HandleRequestHotwordAvailable( 1620 void BrowserOptionsHandler::HandleRequestHotwordAvailable(
1621 const base::ListValue* args) { 1621 const base::ListValue* args) {
1622 Profile* profile = Profile::FromWebUI(web_ui()); 1622 Profile* profile = Profile::FromWebUI(web_ui());
1623 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); 1623 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger");
1624 base::FundamentalValue enabled(
1625 profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled));
1626 if (group != "" && group != "Disabled" && 1624 if (group != "" && group != "Disabled" &&
1627 HotwordServiceFactory::IsHotwordAllowed(profile)) { 1625 HotwordServiceFactory::IsHotwordAllowed(profile)) {
1628 // Update the current error value. 1626 // Update the current error value.
1629 HotwordServiceFactory::IsServiceAvailable(profile); 1627 HotwordServiceFactory::IsServiceAvailable(profile);
1630 int error = HotwordServiceFactory::GetCurrentError(profile); 1628 int error = HotwordServiceFactory::GetCurrentError(profile);
1629
1630 std::string fcn_name;
rpetterson 2014/11/03 18:14:16 what does "fcn" stand for? maybe a name that makes
kcarattini 2014/11/03 23:39:24 Done.
1631 if (CommandLine::ForCurrentProcess()->HasSwitch( 1631 if (CommandLine::ForCurrentProcess()->HasSwitch(
1632 switches::kEnableExperimentalHotwording)) { 1632 switches::kEnableExperimentalHotwording)) {
1633 if (HotwordServiceFactory::IsHotwordHardwareAvailable()) { 1633 if (HotwordServiceFactory::IsHotwordHardwareAvailable()) {
1634 web_ui()->CallJavascriptFunction( 1634 fcn_name = "BrowserOptions.showHotwordAlwaysOnSection";
1635 "BrowserOptions.showHotwordAlwaysOnSection");
1636 } else { 1635 } else {
1637 web_ui()->CallJavascriptFunction( 1636 fcn_name = "BrowserOptions.showHotwordNoDSPSection";
1638 "BrowserOptions.showHotwordNoDSPSection");
1639 } 1637 }
1640 } else if (!error) { 1638 } else {
1641 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", 1639 fcn_name = "BrowserOptions.showHotwordSection";
1642 enabled); 1640 }
1641
1642 if (!error) {
1643 web_ui()->CallJavascriptFunction(fcn_name);
1643 } else { 1644 } else {
1644 base::string16 hotword_help_url = 1645 base::string16 hotword_help_url =
1645 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); 1646 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL);
1646 base::StringValue error_message(l10n_util::GetStringUTF16(error)); 1647 base::StringValue error_message(l10n_util::GetStringUTF16(error));
1647 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { 1648 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) {
1648 error_message = base::StringValue( 1649 error_message = base::StringValue(
1649 l10n_util::GetStringFUTF16(error, hotword_help_url)); 1650 l10n_util::GetStringFUTF16(error, hotword_help_url));
1650 } 1651 }
1651 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", 1652 web_ui()->CallJavascriptFunction(fcn_name, error_message);
1652 enabled, error_message);
1653 } 1653 }
1654 } 1654 }
1655 } 1655 }
1656 1656
1657 void BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp( 1657 void BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp(
1658 const base::ListValue* args) { 1658 const base::ListValue* args) {
1659 Profile* profile = Profile::FromWebUI(web_ui()); 1659 Profile* profile = Profile::FromWebUI(web_ui());
1660 1660
1661 bool retrain = false; 1661 bool retrain = false;
1662 bool success = args->GetBoolean(0, &retrain); 1662 bool success = args->GetBoolean(0, &retrain);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 1985
1986 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, 1986 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked,
1987 bool disabled) { 1987 bool disabled) {
1988 web_ui()->CallJavascriptFunction( 1988 web_ui()->CallJavascriptFunction(
1989 "BrowserOptions.setMetricsReportingCheckboxState", 1989 "BrowserOptions.setMetricsReportingCheckboxState",
1990 base::FundamentalValue(checked), 1990 base::FundamentalValue(checked),
1991 base::FundamentalValue(disabled)); 1991 base::FundamentalValue(disabled));
1992 } 1992 }
1993 1993
1994 } // namespace options 1994 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698