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

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

Issue 938713004: Add Now setting and migration logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 { "extensionControlled", IDS_OPTIONS_TAB_EXTENSION_CONTROLLED }, 270 { "extensionControlled", IDS_OPTIONS_TAB_EXTENSION_CONTROLLED },
271 { "extensionDisable", IDS_OPTIONS_TAB_EXTENSION_CONTROLLED_DISABLE }, 271 { "extensionDisable", IDS_OPTIONS_TAB_EXTENSION_CONTROLLED_DISABLE },
272 { "fontSettingsCustomizeFontsButton", 272 { "fontSettingsCustomizeFontsButton",
273 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON }, 273 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON },
274 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM }, 274 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM },
275 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, 275 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE },
276 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, 276 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM },
277 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, 277 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL },
278 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, 278 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE },
279 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, 279 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL },
280 { "googleNowLauncherEnable", IDS_OPTIONS_ENABLE_GOOGLE_NOW },
280 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, 281 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS },
281 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, 282 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP },
282 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, 283 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON },
283 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, 284 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB },
284 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, 285 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL },
285 { "hotwordAlwaysOnAudioHistoryDescription", 286 { "hotwordAlwaysOnAudioHistoryDescription",
286 IDS_HOTWORD_ALWAYS_ON_AUDIO_HISTORY_DESCRIPTION }, 287 IDS_HOTWORD_ALWAYS_ON_AUDIO_HISTORY_DESCRIPTION },
287 { "hotwordAlwaysOnDesc", IDS_HOTWORD_SEARCH_ALWAYS_ON_DESCRIPTION }, 288 { "hotwordAlwaysOnDesc", IDS_HOTWORD_SEARCH_ALWAYS_ON_DESCRIPTION },
288 { "hotwordAudioHistoryManage", IDS_HOTWORD_AUDIO_HISTORY_MANAGE_LINK }, 289 { "hotwordAudioHistoryManage", IDS_HOTWORD_AUDIO_HISTORY_MANAGE_LINK },
289 { "hotwordAudioLoggingEnable", IDS_HOTWORD_AUDIO_LOGGING_ENABLE }, 290 { "hotwordAudioLoggingEnable", IDS_HOTWORD_AUDIO_LOGGING_ENABLE },
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 771
771 #if defined(ENABLE_SERVICE_DISCOVERY) 772 #if defined(ENABLE_SERVICE_DISCOVERY)
772 if (cloud_print_mdns_ui_enabled_) { 773 if (cloud_print_mdns_ui_enabled_) {
773 web_ui()->RegisterMessageCallback( 774 web_ui()->RegisterMessageCallback(
774 "showCloudPrintDevicesPage", 775 "showCloudPrintDevicesPage",
775 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, 776 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage,
776 base::Unretained(this))); 777 base::Unretained(this)));
777 } 778 }
778 #endif 779 #endif
779 web_ui()->RegisterMessageCallback( 780 web_ui()->RegisterMessageCallback(
781 "requestGoogleNowAvailable",
782 base::Bind(&BrowserOptionsHandler::HandleRequestGoogleNowAvailable,
783 base::Unretained(this)));
784
785 web_ui()->RegisterMessageCallback(
780 "requestHotwordAvailable", 786 "requestHotwordAvailable",
781 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, 787 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable,
782 base::Unretained(this))); 788 base::Unretained(this)));
783 789
784 web_ui()->RegisterMessageCallback( 790 web_ui()->RegisterMessageCallback(
785 "launchHotwordAudioVerificationApp", 791 "launchHotwordAudioVerificationApp",
786 base::Bind( 792 base::Bind(
787 &BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp, 793 &BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp,
788 base::Unretained(this))); 794 base::Unretained(this)));
789 795
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 "BrowserOptions.updateSearchEngines", 1211 "BrowserOptions.updateSearchEngines",
1206 search_engines, 1212 search_engines,
1207 base::FundamentalValue(default_index), 1213 base::FundamentalValue(default_index),
1208 base::FundamentalValue( 1214 base::FundamentalValue(
1209 template_url_service_->is_default_search_managed() || 1215 template_url_service_->is_default_search_managed() ||
1210 template_url_service_->IsExtensionControlledDefaultSearch())); 1216 template_url_service_->IsExtensionControlledDefaultSearch()));
1211 1217
1212 SetupExtensionControlledIndicators(); 1218 SetupExtensionControlledIndicators();
1213 1219
1214 HandleRequestHotwordAvailable(nullptr); 1220 HandleRequestHotwordAvailable(nullptr);
1221 HandleRequestGoogleNowAvailable(nullptr);
1215 } 1222 }
1216 1223
1217 void BrowserOptionsHandler::SetDefaultSearchEngine( 1224 void BrowserOptionsHandler::SetDefaultSearchEngine(
1218 const base::ListValue* args) { 1225 const base::ListValue* args) {
1219 int selected_index = -1; 1226 int selected_index = -1;
1220 if (!ExtractIntegerValue(args, &selected_index)) { 1227 if (!ExtractIntegerValue(args, &selected_index)) {
1221 NOTREACHED(); 1228 NOTREACHED();
1222 return; 1229 return;
1223 } 1230 }
1224 1231
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( 1685 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible(
1679 const base::string16& audio_history_state, 1686 const base::string16& audio_history_state,
1680 bool success, bool logging_enabled) { 1687 bool success, bool logging_enabled) {
1681 bool visible = logging_enabled && success; 1688 bool visible = logging_enabled && success;
1682 web_ui()->CallJavascriptFunction( 1689 web_ui()->CallJavascriptFunction(
1683 "BrowserOptions.setAudioHistorySectionVisible", 1690 "BrowserOptions.setAudioHistorySectionVisible",
1684 base::FundamentalValue(visible), 1691 base::FundamentalValue(visible),
1685 base::StringValue(audio_history_state)); 1692 base::StringValue(audio_history_state));
1686 } 1693 }
1687 1694
1695 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable(
1696 const base::ListValue* args) {
1697 bool is_search_provider_google = false;
1698 if (template_url_service_ && template_url_service_->loaded()) {
1699 const TemplateURL* default_url =
1700 template_url_service_->GetDefaultSearchProvider();
1701 if (default_url && default_url->HasGoogleBaseURLs(
1702 template_url_service_->search_terms_data())) {
1703 is_search_provider_google = true;
1704 }
1705 }
1706
1707 std::string group = base::FieldTrialList::FindFullName("GoogleNowLauncher");
1708 bool has_field_trial = !group.empty() && group != "Disabled";
1709
1710 bool should_show = is_search_provider_google && has_field_trial;
1711 web_ui()->CallJavascriptFunction(
1712 "BrowserOptions.setNowSectionVisible",
1713 base::FundamentalValue(should_show));
1714 }
1715
1688 void BrowserOptionsHandler::HandleRequestHotwordAvailable( 1716 void BrowserOptionsHandler::HandleRequestHotwordAvailable(
1689 const base::ListValue* args) { 1717 const base::ListValue* args) {
1690 Profile* profile = Profile::FromWebUI(web_ui()); 1718 Profile* profile = Profile::FromWebUI(web_ui());
1691 1719
1692 bool is_search_provider_google = false; 1720 bool is_search_provider_google = false;
1693 // The check for default search provider is only valid if the 1721 // The check for default search provider is only valid if the
1694 // |template_url_service_| has loaded already. 1722 // |template_url_service_| has loaded already.
1695 if (template_url_service_ && template_url_service_->loaded()) { 1723 if (template_url_service_ && template_url_service_->loaded()) {
1696 const TemplateURL* default_url = 1724 const TemplateURL* default_url =
1697 template_url_service_->GetDefaultSearchProvider(); 1725 template_url_service_->GetDefaultSearchProvider();
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, 2148 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
2121 const policy::PolicyMap& previous, 2149 const policy::PolicyMap& previous,
2122 const policy::PolicyMap& current) { 2150 const policy::PolicyMap& current) {
2123 std::set<std::string> different_keys; 2151 std::set<std::string> different_keys;
2124 current.GetDifferingKeys(previous, &different_keys); 2152 current.GetDifferingKeys(previous, &different_keys);
2125 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) 2153 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled))
2126 SetupMetricsReportingCheckbox(); 2154 SetupMetricsReportingCheckbox();
2127 } 2155 }
2128 2156
2129 } // namespace options 2157 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698