| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 // checks it. | 1776 // checks it. |
| 1777 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1777 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
| 1778 // Update the current error value. | 1778 // Update the current error value. |
| 1779 HotwordServiceFactory::IsServiceAvailable(profile); | 1779 HotwordServiceFactory::IsServiceAvailable(profile); |
| 1780 int error = HotwordServiceFactory::GetCurrentError(profile); | 1780 int error = HotwordServiceFactory::GetCurrentError(profile); |
| 1781 | 1781 |
| 1782 std::string function_name; | 1782 std::string function_name; |
| 1783 bool always_on = false; | 1783 bool always_on = false; |
| 1784 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 1784 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 1785 bool authenticated = signin && signin->IsAuthenticated(); | 1785 bool authenticated = signin && signin->IsAuthenticated(); |
| 1786 if (HotwordService::IsExperimentalHotwordingEnabled()) { | 1786 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { |
| 1787 if (HotwordServiceFactory::IsAlwaysOnAvailable() && | 1787 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; |
| 1788 authenticated) { | 1788 always_on = true; |
| 1789 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; | 1789 // Show the retrain link if always-on is enabled. |
| 1790 always_on = true; | 1790 if (profile->GetPrefs()->GetBoolean( |
| 1791 // Show the retrain link if always-on is enabled. | 1791 prefs::kHotwordAlwaysOnSearchEnabled)) { |
| 1792 if (profile->GetPrefs()->GetBoolean( | 1792 web_ui()->CallJavascriptFunction( |
| 1793 prefs::kHotwordAlwaysOnSearchEnabled)) { | 1793 "BrowserOptions.setHotwordRetrainLinkVisible", |
| 1794 web_ui()->CallJavascriptFunction( | 1794 base::FundamentalValue(true)); |
| 1795 "BrowserOptions.setHotwordRetrainLinkVisible", | |
| 1796 base::FundamentalValue(true)); | |
| 1797 } | |
| 1798 } else { | |
| 1799 function_name = "BrowserOptions.showHotwordNoDspSection"; | |
| 1800 } | 1795 } |
| 1801 } else { | 1796 } else { |
| 1802 function_name = "BrowserOptions.showHotwordSection"; | 1797 function_name = "BrowserOptions.showHotwordNoDspSection"; |
| 1803 } | 1798 } |
| 1804 | 1799 |
| 1805 // Audio history should be displayed if it's enabled regardless of the | 1800 // Audio history should be displayed if it's enabled regardless of the |
| 1806 // hotword error state if the user is signed in. If the user is not signed | 1801 // hotword error state if the user is signed in. If the user is not signed |
| 1807 // in, audio history is meaningless. This is only displayed if always-on | 1802 // in, audio history is meaningless. This is only displayed if always-on |
| 1808 // hotwording is available. | 1803 // hotwording is available. |
| 1809 if (HotwordService::IsExperimentalHotwordingEnabled() && | 1804 if (authenticated && always_on) { |
| 1810 authenticated && always_on) { | |
| 1811 std::string user_display_name = signin->GetAuthenticatedUsername(); | 1805 std::string user_display_name = signin->GetAuthenticatedUsername(); |
| 1812 DCHECK(!user_display_name.empty()); | 1806 DCHECK(!user_display_name.empty()); |
| 1813 base::string16 audio_history_state = | 1807 base::string16 audio_history_state = |
| 1814 l10n_util::GetStringFUTF16(IDS_HOTWORD_AUDIO_HISTORY_ENABLED, | 1808 l10n_util::GetStringFUTF16(IDS_HOTWORD_AUDIO_HISTORY_ENABLED, |
| 1815 base::ASCIIToUTF16(user_display_name)); | 1809 base::ASCIIToUTF16(user_display_name)); |
| 1816 HotwordService* hotword_service = | 1810 HotwordService* hotword_service = |
| 1817 HotwordServiceFactory::GetForProfile(profile); | 1811 HotwordServiceFactory::GetForProfile(profile); |
| 1818 if (hotword_service) { | 1812 if (hotword_service) { |
| 1819 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled( | 1813 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled( |
| 1820 base::Bind( | 1814 base::Bind( |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2167 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 2174 const policy::PolicyMap& previous, | 2168 const policy::PolicyMap& previous, |
| 2175 const policy::PolicyMap& current) { | 2169 const policy::PolicyMap& current) { |
| 2176 std::set<std::string> different_keys; | 2170 std::set<std::string> different_keys; |
| 2177 current.GetDifferingKeys(previous, &different_keys); | 2171 current.GetDifferingKeys(previous, &different_keys); |
| 2178 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2172 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
| 2179 SetupMetricsReportingCheckbox(); | 2173 SetupMetricsReportingCheckbox(); |
| 2180 } | 2174 } |
| 2181 | 2175 |
| 2182 } // namespace options | 2176 } // namespace options |
| OLD | NEW |