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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 | 773 |
773 #if defined(ENABLE_SERVICE_DISCOVERY) | 774 #if defined(ENABLE_SERVICE_DISCOVERY) |
774 if (cloud_print_mdns_ui_enabled_) { | 775 if (cloud_print_mdns_ui_enabled_) { |
775 web_ui()->RegisterMessageCallback( | 776 web_ui()->RegisterMessageCallback( |
776 "showCloudPrintDevicesPage", | 777 "showCloudPrintDevicesPage", |
777 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, | 778 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, |
778 base::Unretained(this))); | 779 base::Unretained(this))); |
779 } | 780 } |
780 #endif | 781 #endif |
781 web_ui()->RegisterMessageCallback( | 782 web_ui()->RegisterMessageCallback( |
| 783 "requestGoogleNowAvailable", |
| 784 base::Bind(&BrowserOptionsHandler::HandleRequestGoogleNowAvailable, |
| 785 base::Unretained(this))); |
| 786 |
| 787 web_ui()->RegisterMessageCallback( |
782 "requestHotwordAvailable", | 788 "requestHotwordAvailable", |
783 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, | 789 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, |
784 base::Unretained(this))); | 790 base::Unretained(this))); |
785 | 791 |
786 web_ui()->RegisterMessageCallback( | 792 web_ui()->RegisterMessageCallback( |
787 "launchHotwordAudioVerificationApp", | 793 "launchHotwordAudioVerificationApp", |
788 base::Bind( | 794 base::Bind( |
789 &BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp, | 795 &BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp, |
790 base::Unretained(this))); | 796 base::Unretained(this))); |
791 | 797 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 "BrowserOptions.updateSearchEngines", | 1213 "BrowserOptions.updateSearchEngines", |
1208 search_engines, | 1214 search_engines, |
1209 base::FundamentalValue(default_index), | 1215 base::FundamentalValue(default_index), |
1210 base::FundamentalValue( | 1216 base::FundamentalValue( |
1211 template_url_service_->is_default_search_managed() || | 1217 template_url_service_->is_default_search_managed() || |
1212 template_url_service_->IsExtensionControlledDefaultSearch())); | 1218 template_url_service_->IsExtensionControlledDefaultSearch())); |
1213 | 1219 |
1214 SetupExtensionControlledIndicators(); | 1220 SetupExtensionControlledIndicators(); |
1215 | 1221 |
1216 HandleRequestHotwordAvailable(nullptr); | 1222 HandleRequestHotwordAvailable(nullptr); |
| 1223 HandleRequestGoogleNowAvailable(nullptr); |
1217 } | 1224 } |
1218 | 1225 |
1219 void BrowserOptionsHandler::SetDefaultSearchEngine( | 1226 void BrowserOptionsHandler::SetDefaultSearchEngine( |
1220 const base::ListValue* args) { | 1227 const base::ListValue* args) { |
1221 int selected_index = -1; | 1228 int selected_index = -1; |
1222 if (!ExtractIntegerValue(args, &selected_index)) { | 1229 if (!ExtractIntegerValue(args, &selected_index)) { |
1223 NOTREACHED(); | 1230 NOTREACHED(); |
1224 return; | 1231 return; |
1225 } | 1232 } |
1226 | 1233 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( | 1687 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( |
1681 const base::string16& audio_history_state, | 1688 const base::string16& audio_history_state, |
1682 bool success, bool logging_enabled) { | 1689 bool success, bool logging_enabled) { |
1683 bool visible = logging_enabled && success; | 1690 bool visible = logging_enabled && success; |
1684 web_ui()->CallJavascriptFunction( | 1691 web_ui()->CallJavascriptFunction( |
1685 "BrowserOptions.setAudioHistorySectionVisible", | 1692 "BrowserOptions.setAudioHistorySectionVisible", |
1686 base::FundamentalValue(visible), | 1693 base::FundamentalValue(visible), |
1687 base::StringValue(audio_history_state)); | 1694 base::StringValue(audio_history_state)); |
1688 } | 1695 } |
1689 | 1696 |
| 1697 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( |
| 1698 const base::ListValue* args) { |
| 1699 bool is_search_provider_google = false; |
| 1700 if (template_url_service_ && template_url_service_->loaded()) { |
| 1701 const TemplateURL* default_url = |
| 1702 template_url_service_->GetDefaultSearchProvider(); |
| 1703 if (default_url && default_url->HasGoogleBaseURLs( |
| 1704 template_url_service_->search_terms_data())) { |
| 1705 is_search_provider_google = true; |
| 1706 } |
| 1707 } |
| 1708 |
| 1709 std::string group = base::FieldTrialList::FindFullName("GoogleNowLauncher"); |
| 1710 bool has_field_trial = !group.empty() && group != "Disabled"; |
| 1711 |
| 1712 bool should_show = is_search_provider_google && has_field_trial; |
| 1713 web_ui()->CallJavascriptFunction( |
| 1714 "BrowserOptions.setNowSectionVisible", |
| 1715 base::FundamentalValue(should_show)); |
| 1716 } |
| 1717 |
1690 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1718 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
1691 const base::ListValue* args) { | 1719 const base::ListValue* args) { |
1692 Profile* profile = Profile::FromWebUI(web_ui()); | 1720 Profile* profile = Profile::FromWebUI(web_ui()); |
1693 | 1721 |
1694 bool is_search_provider_google = false; | 1722 bool is_search_provider_google = false; |
1695 // The check for default search provider is only valid if the | 1723 // The check for default search provider is only valid if the |
1696 // |template_url_service_| has loaded already. | 1724 // |template_url_service_| has loaded already. |
1697 if (template_url_service_ && template_url_service_->loaded()) { | 1725 if (template_url_service_ && template_url_service_->loaded()) { |
1698 const TemplateURL* default_url = | 1726 const TemplateURL* default_url = |
1699 template_url_service_->GetDefaultSearchProvider(); | 1727 template_url_service_->GetDefaultSearchProvider(); |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2150 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
2123 const policy::PolicyMap& previous, | 2151 const policy::PolicyMap& previous, |
2124 const policy::PolicyMap& current) { | 2152 const policy::PolicyMap& current) { |
2125 std::set<std::string> different_keys; | 2153 std::set<std::string> different_keys; |
2126 current.GetDifferingKeys(previous, &different_keys); | 2154 current.GetDifferingKeys(previous, &different_keys); |
2127 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2155 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
2128 SetupMetricsReportingCheckbox(); | 2156 SetupMetricsReportingCheckbox(); |
2129 } | 2157 } |
2130 | 2158 |
2131 } // namespace options | 2159 } // namespace options |
OLD | NEW |