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