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 26 matching lines...) Expand all Loading... |
37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
39 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
41 #include "chrome/browser/profiles/profile_info_cache.h" | 41 #include "chrome/browser/profiles/profile_info_cache.h" |
42 #include "chrome/browser/profiles/profile_manager.h" | 42 #include "chrome/browser/profiles/profile_manager.h" |
43 #include "chrome/browser/profiles/profile_metrics.h" | 43 #include "chrome/browser/profiles/profile_metrics.h" |
44 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 44 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
45 #include "chrome/browser/profiles/profile_window.h" | 45 #include "chrome/browser/profiles/profile_window.h" |
46 #include "chrome/browser/profiles/profiles_state.h" | 46 #include "chrome/browser/profiles/profiles_state.h" |
| 47 #include "chrome/browser/search/hotword_audio_history_handler.h" |
47 #include "chrome/browser/search/hotword_service.h" | 48 #include "chrome/browser/search/hotword_service.h" |
48 #include "chrome/browser/search/hotword_service_factory.h" | 49 #include "chrome/browser/search/hotword_service_factory.h" |
49 #include "chrome/browser/search/search.h" | 50 #include "chrome/browser/search/search.h" |
50 #include "chrome/browser/search_engines/template_url_service_factory.h" | 51 #include "chrome/browser/search_engines/template_url_service_factory.h" |
51 #include "chrome/browser/signin/easy_unlock_service.h" | 52 #include "chrome/browser/signin/easy_unlock_service.h" |
52 #include "chrome/browser/signin/signin_manager_factory.h" | 53 #include "chrome/browser/signin/signin_manager_factory.h" |
53 #include "chrome/browser/sync/profile_sync_service.h" | 54 #include "chrome/browser/sync/profile_sync_service.h" |
54 #include "chrome/browser/sync/profile_sync_service_factory.h" | 55 #include "chrome/browser/sync/profile_sync_service_factory.h" |
55 #include "chrome/browser/sync/sync_ui_util.h" | 56 #include "chrome/browser/sync/sync_ui_util.h" |
56 #include "chrome/browser/themes/theme_service.h" | 57 #include "chrome/browser/themes/theme_service.h" |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 content::RecordAction(UserMetricsAction("Options_CloudPrintDevicesPage")); | 1668 content::RecordAction(UserMetricsAction("Options_CloudPrintDevicesPage")); |
1668 // Navigate in current tab to devices page. | 1669 // Navigate in current tab to devices page. |
1669 OpenURLParams params( | 1670 OpenURLParams params( |
1670 GURL(chrome::kChromeUIDevicesURL), Referrer(), | 1671 GURL(chrome::kChromeUIDevicesURL), Referrer(), |
1671 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false); | 1672 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false); |
1672 web_ui()->GetWebContents()->OpenURL(params); | 1673 web_ui()->GetWebContents()->OpenURL(params); |
1673 } | 1674 } |
1674 | 1675 |
1675 #endif | 1676 #endif |
1676 | 1677 |
| 1678 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( |
| 1679 bool always_on, bool success, bool logging_enabled) { |
| 1680 web_ui()->CallJavascriptFunction( |
| 1681 "BrowserOptions.setAudioHistorySectionVisible", |
| 1682 base::FundamentalValue(always_on), |
| 1683 base::FundamentalValue(logging_enabled)); |
| 1684 |
| 1685 // TODO(rlp): Add version with error display if !success. |
| 1686 } |
| 1687 |
1677 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1688 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
1678 const base::ListValue* args) { | 1689 const base::ListValue* args) { |
1679 Profile* profile = Profile::FromWebUI(web_ui()); | 1690 Profile* profile = Profile::FromWebUI(web_ui()); |
1680 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); | 1691 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); |
1681 if (group != "" && group != "Disabled" && | 1692 if (group != "" && group != "Disabled" && |
1682 HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1693 HotwordServiceFactory::IsHotwordAllowed(profile)) { |
1683 // Update the current error value. | 1694 // Update the current error value. |
1684 HotwordServiceFactory::IsServiceAvailable(profile); | 1695 HotwordServiceFactory::IsServiceAvailable(profile); |
1685 int error = HotwordServiceFactory::GetCurrentError(profile); | 1696 int error = HotwordServiceFactory::GetCurrentError(profile); |
1686 | 1697 |
(...skipping 13 matching lines...) Expand all Loading... |
1700 } else { | 1711 } else { |
1701 function_name = "BrowserOptions.showHotwordNoDspSection"; | 1712 function_name = "BrowserOptions.showHotwordNoDspSection"; |
1702 } | 1713 } |
1703 } else { | 1714 } else { |
1704 function_name = "BrowserOptions.showHotwordSection"; | 1715 function_name = "BrowserOptions.showHotwordSection"; |
1705 } | 1716 } |
1706 | 1717 |
1707 // Audio history should be displayed if it's enabled regardless of the | 1718 // Audio history should be displayed if it's enabled regardless of the |
1708 // hotword error state. An additional message is displayed if always-on | 1719 // hotword error state. An additional message is displayed if always-on |
1709 // hotwording is enabled. | 1720 // hotwording is enabled. |
1710 if (profile->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled) && | 1721 if (HotwordService::IsExperimentalHotwordingEnabled()) { |
1711 HotwordService::IsExperimentalHotwordingEnabled()) { | 1722 HotwordService* hotword_service = |
1712 web_ui()->CallJavascriptFunction("BrowserOptions.showAudioHistorySection", | 1723 HotwordServiceFactory::GetForProfile(profile); |
1713 base::FundamentalValue(always_on)); | 1724 if (hotword_service) { |
| 1725 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled( |
| 1726 base::Bind( |
| 1727 &BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible, |
| 1728 weak_ptr_factory_.GetWeakPtr(), |
| 1729 always_on)); |
| 1730 } |
1714 } | 1731 } |
1715 | 1732 |
1716 if (!error) { | 1733 if (!error) { |
1717 web_ui()->CallJavascriptFunction(function_name); | 1734 web_ui()->CallJavascriptFunction(function_name); |
1718 } else { | 1735 } else { |
1719 base::string16 hotword_help_url = | 1736 base::string16 hotword_help_url = |
1720 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); | 1737 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); |
1721 base::StringValue error_message(l10n_util::GetStringUTF16(error)); | 1738 base::StringValue error_message(l10n_util::GetStringUTF16(error)); |
1722 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { | 1739 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { |
1723 error_message = base::StringValue( | 1740 error_message = base::StringValue( |
(...skipping 14 matching lines...) Expand all Loading... |
1738 HotwordService::LaunchMode launch_mode = | 1755 HotwordService::LaunchMode launch_mode = |
1739 HotwordService::HOTWORD_AND_AUDIO_HISTORY; | 1756 HotwordService::HOTWORD_AND_AUDIO_HISTORY; |
1740 | 1757 |
1741 if (retrain) { | 1758 if (retrain) { |
1742 DCHECK(profile->GetPrefs()->GetBoolean( | 1759 DCHECK(profile->GetPrefs()->GetBoolean( |
1743 prefs::kHotwordAlwaysOnSearchEnabled)); | 1760 prefs::kHotwordAlwaysOnSearchEnabled)); |
1744 DCHECK(profile->GetPrefs()->GetBoolean( | 1761 DCHECK(profile->GetPrefs()->GetBoolean( |
1745 prefs::kHotwordAudioLoggingEnabled)); | 1762 prefs::kHotwordAudioLoggingEnabled)); |
1746 | 1763 |
1747 launch_mode = HotwordService::RETRAIN; | 1764 launch_mode = HotwordService::RETRAIN; |
1748 // TODO(rlp): Make sure the Chrome Audio History pref is synced | |
1749 // to the account-level Audio History setting from footprints. | |
1750 } else if (profile->GetPrefs()->GetBoolean( | 1765 } else if (profile->GetPrefs()->GetBoolean( |
1751 prefs::kHotwordAudioLoggingEnabled)) { | 1766 prefs::kHotwordAudioLoggingEnabled)) { |
1752 DCHECK(!profile->GetPrefs()->GetBoolean( | 1767 DCHECK(!profile->GetPrefs()->GetBoolean( |
1753 prefs::kHotwordAlwaysOnSearchEnabled)); | 1768 prefs::kHotwordAlwaysOnSearchEnabled)); |
1754 launch_mode = HotwordService::HOTWORD_ONLY; | 1769 launch_mode = HotwordService::HOTWORD_ONLY; |
1755 } else { | 1770 } else { |
1756 DCHECK(!profile->GetPrefs()->GetBoolean( | 1771 DCHECK(!profile->GetPrefs()->GetBoolean( |
1757 prefs::kHotwordAlwaysOnSearchEnabled)); | 1772 prefs::kHotwordAlwaysOnSearchEnabled)); |
1758 } | 1773 } |
1759 | 1774 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2086 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
2072 const policy::PolicyMap& previous, | 2087 const policy::PolicyMap& previous, |
2073 const policy::PolicyMap& current) { | 2088 const policy::PolicyMap& current) { |
2074 std::set<std::string> different_keys; | 2089 std::set<std::string> different_keys; |
2075 current.GetDifferingKeys(previous, &different_keys); | 2090 current.GetDifferingKeys(previous, &different_keys); |
2076 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2091 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
2077 SetupMetricsReportingCheckbox(); | 2092 SetupMetricsReportingCheckbox(); |
2078 } | 2093 } |
2079 | 2094 |
2080 } // namespace options | 2095 } // namespace options |
OLD | NEW |