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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/app_window.h" | 10 #include "apps/app_window.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, | 259 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, |
260 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, | 260 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, |
261 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, | 261 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, |
262 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, | 262 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, |
263 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, | 263 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, |
264 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, | 264 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, |
265 { "hotwordSearchEnable", IDS_HOTWORD_SEARCH_PREF_CHKBOX }, | 265 { "hotwordSearchEnable", IDS_HOTWORD_SEARCH_PREF_CHKBOX }, |
266 { "hotwordConfirmEnable", IDS_HOTWORD_CONFIRM_BUBBLE_ENABLE }, | 266 { "hotwordConfirmEnable", IDS_HOTWORD_CONFIRM_BUBBLE_ENABLE }, |
267 { "hotwordConfirmDisable", IDS_HOTWORD_CONFIRM_BUBBLE_DISABLE }, | 267 { "hotwordConfirmDisable", IDS_HOTWORD_CONFIRM_BUBBLE_DISABLE }, |
268 { "hotwordConfirmMessage", IDS_HOTWORD_SEARCH_PREF_DESCRIPTION }, | 268 { "hotwordConfirmMessage", IDS_HOTWORD_SEARCH_PREF_DESCRIPTION }, |
269 { "hotwordRetryDownloadButton", IDS_HOTWORD_RETRY_DOWNLOAD_BUTTON }, | |
270 { "hotwordAudioLoggingEnable", IDS_HOTWORD_AUDIO_LOGGING_ENABLE }, | 269 { "hotwordAudioLoggingEnable", IDS_HOTWORD_AUDIO_LOGGING_ENABLE }, |
271 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, | 270 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, |
272 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, | 271 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, |
273 { "languageAndSpellCheckSettingsButton", | 272 { "languageAndSpellCheckSettingsButton", |
274 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS }, | 273 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS }, |
275 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, | 274 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, |
276 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, | 275 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, |
277 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES }, | 276 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES }, |
278 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, | 277 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, |
279 { "managedUserLabel", IDS_MANAGED_USER_AVATAR_LABEL }, | 278 { "managedUserLabel", IDS_MANAGED_USER_AVATAR_LABEL }, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, | 706 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, |
708 base::Unretained(this))); | 707 base::Unretained(this))); |
709 } | 708 } |
710 #endif | 709 #endif |
711 web_ui()->RegisterMessageCallback( | 710 web_ui()->RegisterMessageCallback( |
712 "requestHotwordAvailable", | 711 "requestHotwordAvailable", |
713 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, | 712 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, |
714 base::Unretained(this))); | 713 base::Unretained(this))); |
715 | 714 |
716 web_ui()->RegisterMessageCallback( | 715 web_ui()->RegisterMessageCallback( |
717 "requestHotwordSetupRetry", | |
718 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordSetupRetry, | |
719 base::Unretained(this))); | |
720 | |
721 web_ui()->RegisterMessageCallback( | |
722 "launchEasyUnlockSetup", | 716 "launchEasyUnlockSetup", |
723 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup, | 717 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup, |
724 base::Unretained(this))); | 718 base::Unretained(this))); |
725 #if defined(OS_WIN) | 719 #if defined(OS_WIN) |
726 web_ui()->RegisterMessageCallback( | 720 web_ui()->RegisterMessageCallback( |
727 "refreshExtensionControlIndicators", | 721 "refreshExtensionControlIndicators", |
728 base::Bind( | 722 base::Bind( |
729 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, | 723 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, |
730 base::Unretained(this))); | 724 base::Unretained(this))); |
731 #endif // defined(OS_WIN) | 725 #endif // defined(OS_WIN) |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 web_ui()->GetWebContents()->OpenURL(params); | 1520 web_ui()->GetWebContents()->OpenURL(params); |
1527 } | 1521 } |
1528 | 1522 |
1529 #endif | 1523 #endif |
1530 | 1524 |
1531 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1525 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
1532 const base::ListValue* args) { | 1526 const base::ListValue* args) { |
1533 Profile* profile = Profile::FromWebUI(web_ui()); | 1527 Profile* profile = Profile::FromWebUI(web_ui()); |
1534 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); | 1528 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); |
1535 if (group != "" && group != "Disabled") { | 1529 if (group != "" && group != "Disabled") { |
1536 if (HotwordServiceFactory::IsServiceAvailable(profile)) | 1530 if (HotwordServiceFactory::IsServiceAvailable(profile)) { |
1537 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); | 1531 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); |
| 1532 } else if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
| 1533 base::StringValue error_message(l10n_util::GetStringUTF16( |
| 1534 HotwordServiceFactory::GetCurrentError(profile))); |
| 1535 base::string16 hotword_help_url = |
| 1536 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); |
| 1537 base::StringValue help_link(l10n_util::GetStringFUTF16( |
| 1538 IDS_HOTWORD_HELP_LINK, hotword_help_url)); |
| 1539 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", |
| 1540 error_message, help_link); |
| 1541 } |
1538 } | 1542 } |
1539 } | 1543 } |
1540 | 1544 |
1541 void BrowserOptionsHandler::HandleLaunchEasyUnlockSetup( | 1545 void BrowserOptionsHandler::HandleLaunchEasyUnlockSetup( |
1542 const base::ListValue* args) { | 1546 const base::ListValue* args) { |
1543 easy_unlock::LaunchEasyUnlockSetup(Profile::FromWebUI(web_ui())); | 1547 easy_unlock::LaunchEasyUnlockSetup(Profile::FromWebUI(web_ui())); |
1544 } | 1548 } |
1545 | 1549 |
1546 void BrowserOptionsHandler::HandleRequestHotwordSetupRetry( | |
1547 const base::ListValue* args) { | |
1548 // TODO(joshtrask): invoke BrowserOptions.showHotwordSection again, passing | |
1549 // the new error message if any. | |
1550 HotwordServiceFactory::RetryHotwordExtension(Profile::FromWebUI(web_ui())); | |
1551 } | |
1552 | |
1553 void BrowserOptionsHandler::HandleRefreshExtensionControlIndicators( | |
1554 const base::ListValue* args) { | |
1555 SetupExtensionControlledIndicators(); | |
1556 } | |
1557 | |
1558 #if defined(OS_CHROMEOS) | 1550 #if defined(OS_CHROMEOS) |
1559 void BrowserOptionsHandler::HandleOpenWallpaperManager( | 1551 void BrowserOptionsHandler::HandleOpenWallpaperManager( |
1560 const base::ListValue* args) { | 1552 const base::ListValue* args) { |
1561 ash::Shell::GetInstance()->user_wallpaper_delegate()->OpenSetWallpaperPage(); | 1553 ash::Shell::GetInstance()->user_wallpaper_delegate()->OpenSetWallpaperPage(); |
1562 } | 1554 } |
1563 | 1555 |
1564 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( | 1556 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( |
1565 const base::ListValue* args) { | 1557 const base::ListValue* args) { |
1566 bool enabled = false; | 1558 bool enabled = false; |
1567 args->GetBoolean(0, &enabled); | 1559 args->GetBoolean(0, &enabled); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 ExtensionRegistry::ENABLED); | 1773 ExtensionRegistry::ENABLED); |
1782 } | 1774 } |
1783 AppendExtensionData("newTabPage", extension, &extension_controlled); | 1775 AppendExtensionData("newTabPage", extension, &extension_controlled); |
1784 | 1776 |
1785 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 1777 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", |
1786 extension_controlled); | 1778 extension_controlled); |
1787 #endif // defined(OS_WIN) | 1779 #endif // defined(OS_WIN) |
1788 } | 1780 } |
1789 | 1781 |
1790 } // namespace options | 1782 } // namespace options |
OLD | NEW |