Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 800523002: [Hotword] Sync Audio History pref every 24 hours, when opening chrome://settings and . . . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another compile error Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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::ShowHotwordAudioHistorySection(
1679 bool always_on, bool success, bool logging_enabled) {
1680 if (success && logging_enabled) {
Dan Beam 2014/12/12 20:04:20 if !success or !logging_enabled should this sectio
rpetterson 2014/12/12 20:19:36 Ideally, if !success we would show an error. I act
Dan Beam 2014/12/12 20:25:46 i generally ask this type of question whenever I s
rpetterson 2014/12/12 21:39:56 Since I prefer doing things the right way, I've up
1681 web_ui()->CallJavascriptFunction("BrowserOptions.showAudioHistorySection",
1682 base::FundamentalValue(always_on));
1683 }
1684 // TODO(rlp): Add version with error display.
1685 }
1686
1677 void BrowserOptionsHandler::HandleRequestHotwordAvailable( 1687 void BrowserOptionsHandler::HandleRequestHotwordAvailable(
1678 const base::ListValue* args) { 1688 const base::ListValue* args) {
1679 Profile* profile = Profile::FromWebUI(web_ui()); 1689 Profile* profile = Profile::FromWebUI(web_ui());
1680 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); 1690 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger");
1681 if (group != "" && group != "Disabled" && 1691 if (group != "" && group != "Disabled" &&
1682 HotwordServiceFactory::IsHotwordAllowed(profile)) { 1692 HotwordServiceFactory::IsHotwordAllowed(profile)) {
1683 // Update the current error value. 1693 // Update the current error value.
1684 HotwordServiceFactory::IsServiceAvailable(profile); 1694 HotwordServiceFactory::IsServiceAvailable(profile);
1685 int error = HotwordServiceFactory::GetCurrentError(profile); 1695 int error = HotwordServiceFactory::GetCurrentError(profile);
1686 1696
(...skipping 13 matching lines...) Expand all
1700 } else { 1710 } else {
1701 function_name = "BrowserOptions.showHotwordNoDspSection"; 1711 function_name = "BrowserOptions.showHotwordNoDspSection";
1702 } 1712 }
1703 } else { 1713 } else {
1704 function_name = "BrowserOptions.showHotwordSection"; 1714 function_name = "BrowserOptions.showHotwordSection";
1705 } 1715 }
1706 1716
1707 // Audio history should be displayed if it's enabled regardless of the 1717 // Audio history should be displayed if it's enabled regardless of the
1708 // hotword error state. An additional message is displayed if always-on 1718 // hotword error state. An additional message is displayed if always-on
1709 // hotwording is enabled. 1719 // hotwording is enabled.
1710 if (profile->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled) && 1720 if (HotwordService::IsExperimentalHotwordingEnabled()) {
1711 HotwordService::IsExperimentalHotwordingEnabled()) { 1721 HotwordService* hotword_service =
1712 web_ui()->CallJavascriptFunction("BrowserOptions.showAudioHistorySection", 1722 HotwordServiceFactory::GetForProfile(profile);
1713 base::FundamentalValue(always_on)); 1723 if (hotword_service)
Dan Beam 2014/12/12 20:04:20 curlies
rpetterson 2014/12/12 20:19:36 Done.
1724 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled(
1725 base::Bind(&BrowserOptionsHandler::ShowHotwordAudioHistorySection,
1726 weak_ptr_factory_.GetWeakPtr(),
1727 always_on));
1714 } 1728 }
1715 1729
1716 if (!error) { 1730 if (!error) {
1717 web_ui()->CallJavascriptFunction(function_name); 1731 web_ui()->CallJavascriptFunction(function_name);
1718 } else { 1732 } else {
1719 base::string16 hotword_help_url = 1733 base::string16 hotword_help_url =
1720 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); 1734 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL);
1721 base::StringValue error_message(l10n_util::GetStringUTF16(error)); 1735 base::StringValue error_message(l10n_util::GetStringUTF16(error));
1722 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { 1736 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) {
1723 error_message = base::StringValue( 1737 error_message = base::StringValue(
(...skipping 14 matching lines...) Expand all
1738 HotwordService::LaunchMode launch_mode = 1752 HotwordService::LaunchMode launch_mode =
1739 HotwordService::HOTWORD_AND_AUDIO_HISTORY; 1753 HotwordService::HOTWORD_AND_AUDIO_HISTORY;
1740 1754
1741 if (retrain) { 1755 if (retrain) {
1742 DCHECK(profile->GetPrefs()->GetBoolean( 1756 DCHECK(profile->GetPrefs()->GetBoolean(
1743 prefs::kHotwordAlwaysOnSearchEnabled)); 1757 prefs::kHotwordAlwaysOnSearchEnabled));
1744 DCHECK(profile->GetPrefs()->GetBoolean( 1758 DCHECK(profile->GetPrefs()->GetBoolean(
1745 prefs::kHotwordAudioLoggingEnabled)); 1759 prefs::kHotwordAudioLoggingEnabled));
1746 1760
1747 launch_mode = HotwordService::RETRAIN; 1761 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( 1762 } else if (profile->GetPrefs()->GetBoolean(
1751 prefs::kHotwordAudioLoggingEnabled)) { 1763 prefs::kHotwordAudioLoggingEnabled)) {
1752 DCHECK(!profile->GetPrefs()->GetBoolean( 1764 DCHECK(!profile->GetPrefs()->GetBoolean(
1753 prefs::kHotwordAlwaysOnSearchEnabled)); 1765 prefs::kHotwordAlwaysOnSearchEnabled));
1754 launch_mode = HotwordService::HOTWORD_ONLY; 1766 launch_mode = HotwordService::HOTWORD_ONLY;
1755 } else { 1767 } else {
1756 DCHECK(!profile->GetPrefs()->GetBoolean( 1768 DCHECK(!profile->GetPrefs()->GetBoolean(
1757 prefs::kHotwordAlwaysOnSearchEnabled)); 1769 prefs::kHotwordAlwaysOnSearchEnabled));
1758 } 1770 }
1759 1771
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, 2083 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
2072 const policy::PolicyMap& previous, 2084 const policy::PolicyMap& previous,
2073 const policy::PolicyMap& current) { 2085 const policy::PolicyMap& current) {
2074 std::set<std::string> different_keys; 2086 std::set<std::string> different_keys;
2075 current.GetDifferingKeys(previous, &different_keys); 2087 current.GetDifferingKeys(previous, &different_keys);
2076 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) 2088 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled))
2077 SetupMetricsReportingCheckbox(); 2089 SetupMetricsReportingCheckbox();
2078 } 2090 }
2079 2091
2080 } // namespace options 2092 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698