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