OLD | NEW |
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 Loading... |
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 function_name; |
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 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; |
1635 "BrowserOptions.showHotwordAlwaysOnSection"); | |
1636 } else { | 1635 } else { |
1637 web_ui()->CallJavascriptFunction( | 1636 function_name = "BrowserOptions.showHotwordNoDspSection"; |
1638 "BrowserOptions.showHotwordNoDSPSection"); | |
1639 } | 1637 } |
1640 } else if (!error) { | 1638 } else { |
1641 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", | 1639 function_name = "BrowserOptions.showHotwordSection"; |
1642 enabled); | 1640 } |
| 1641 |
| 1642 if (!error) { |
| 1643 web_ui()->CallJavascriptFunction(function_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(function_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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 | 1989 |
1990 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 1990 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
1991 bool disabled) { | 1991 bool disabled) { |
1992 web_ui()->CallJavascriptFunction( | 1992 web_ui()->CallJavascriptFunction( |
1993 "BrowserOptions.setMetricsReportingCheckboxState", | 1993 "BrowserOptions.setMetricsReportingCheckboxState", |
1994 base::FundamentalValue(checked), | 1994 base::FundamentalValue(checked), |
1995 base::FundamentalValue(disabled)); | 1995 base::FundamentalValue(disabled)); |
1996 } | 1996 } |
1997 | 1997 |
1998 } // namespace options | 1998 } // namespace options |
OLD | NEW |