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/shell_window.h" | 10 #include "apps/shell_window.h" |
11 #include "apps/shell_window_registry.h" | 11 #include "apps/shell_window_registry.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/metrics/field_trial.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
19 #include "base/prefs/scoped_user_pref_update.h" | 20 #include "base/prefs/scoped_user_pref_update.h" |
20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
23 #include "base/value_conversions.h" | 24 #include "base/value_conversions.h" |
24 #include "base/values.h" | 25 #include "base/values.h" |
25 #include "chrome/browser/auto_launch_trial.h" | 26 #include "chrome/browser/auto_launch_trial.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, | 250 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, |
250 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, | 251 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, |
251 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, | 252 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, |
252 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, | 253 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, |
253 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, | 254 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, |
254 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, | 255 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, |
255 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, | 256 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, |
256 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, | 257 { "homePageShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, |
257 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, | 258 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, |
258 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, | 259 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, |
| 260 { "hotwordSearchDescription", IDS_HOTWORD_SEARCH_PREF_DESCRIPTION }, |
| 261 { "hotwordSearchIncognito", IDS_HOTWORD_SEARCH_INCOGNITO_PREF_CHKBOX }, |
| 262 { "hotwordSearchTimeout", IDS_HOTWORD_SEARCH_TIMEOUT_PREF_CHKBOX }, |
| 263 { "hotwordSearchTimeoutDescription", |
| 264 IDS_HOTWORD_SEARCH_TIMEOUT_PREF_DESCRIPTION }, |
259 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, | 265 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, |
260 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, | 266 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, |
261 { "languageAndSpellCheckSettingsButton", | 267 { "languageAndSpellCheckSettingsButton", |
262 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS }, | 268 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS }, |
263 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, | 269 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, |
264 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, | 270 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, |
265 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES }, | 271 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES }, |
266 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, | 272 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, |
267 { "networkPredictionEnabledDescription", | 273 { "networkPredictionEnabledDescription", |
268 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, | 274 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE); | 475 IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE); |
470 #if defined(ENABLE_FULL_PRINTING) | 476 #if defined(ENABLE_FULL_PRINTING) |
471 RegisterCloudPrintValues(values); | 477 RegisterCloudPrintValues(values); |
472 #endif | 478 #endif |
473 | 479 |
474 values->SetString("syncLearnMoreURL", chrome::kSyncLearnMoreURL); | 480 values->SetString("syncLearnMoreURL", chrome::kSyncLearnMoreURL); |
475 base::string16 omnibox_url = base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL); | 481 base::string16 omnibox_url = base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL); |
476 values->SetString( | 482 values->SetString( |
477 "defaultSearchGroupLabel", | 483 "defaultSearchGroupLabel", |
478 l10n_util::GetStringFUTF16(IDS_SEARCH_PREF_EXPLANATION, omnibox_url)); | 484 l10n_util::GetStringFUTF16(IDS_SEARCH_PREF_EXPLANATION, omnibox_url)); |
| 485 base::string16 hotword_url = base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); |
| 486 values->SetString( |
| 487 "hotwordSearchEnable", |
| 488 l10n_util::GetStringFUTF16(IDS_HOTWORD_SEARCH_PREF_CHKBOX, hotword_url)); |
479 | 489 |
480 #if defined(OS_CHROMEOS) | 490 #if defined(OS_CHROMEOS) |
481 Profile* profile = Profile::FromWebUI(web_ui()); | 491 Profile* profile = Profile::FromWebUI(web_ui()); |
482 std::string name = profile->GetProfileName(); | 492 std::string name = profile->GetProfileName(); |
483 std::string username = | 493 std::string username = |
484 name.empty() ? name : gaia::SanitizeEmail(gaia::CanonicalizeEmail(name)); | 494 name.empty() ? name : gaia::SanitizeEmail(gaia::CanonicalizeEmail(name)); |
485 values->SetString("username", username); | 495 values->SetString("username", username); |
486 #endif | 496 #endif |
487 | 497 |
488 // Pass along sync status early so it will be available during page init. | 498 // Pass along sync status early so it will be available during page init. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 #endif // defined(OS_CHROMEOS) | 701 #endif // defined(OS_CHROMEOS) |
692 | 702 |
693 #if defined(ENABLE_MDNS) | 703 #if defined(ENABLE_MDNS) |
694 if (cloud_print_mdns_ui_enabled_) { | 704 if (cloud_print_mdns_ui_enabled_) { |
695 web_ui()->RegisterMessageCallback( | 705 web_ui()->RegisterMessageCallback( |
696 "showCloudPrintDevicesPage", | 706 "showCloudPrintDevicesPage", |
697 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, | 707 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, |
698 base::Unretained(this))); | 708 base::Unretained(this))); |
699 } | 709 } |
700 #endif | 710 #endif |
| 711 web_ui()->RegisterMessageCallback( |
| 712 "requestHotwordAvailabile", |
| 713 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, |
| 714 base::Unretained(this))); |
701 } | 715 } |
702 | 716 |
703 void BrowserOptionsHandler::Uninitialize() { | 717 void BrowserOptionsHandler::Uninitialize() { |
704 registrar_.RemoveAll(); | 718 registrar_.RemoveAll(); |
705 } | 719 } |
706 | 720 |
707 void BrowserOptionsHandler::OnStateChanged() { | 721 void BrowserOptionsHandler::OnStateChanged() { |
708 UpdateSyncState(); | 722 UpdateSyncState(); |
709 } | 723 } |
710 | 724 |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 allowed); | 1509 allowed); |
1496 } | 1510 } |
1497 | 1511 |
1498 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() { | 1512 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() { |
1499 web_ui()->CallJavascriptFunction( | 1513 web_ui()->CallJavascriptFunction( |
1500 "BrowserOptions.removeCloudPrintConnectorSection"); | 1514 "BrowserOptions.removeCloudPrintConnectorSection"); |
1501 } | 1515 } |
1502 #endif // defined(OS_CHROMEOS) | 1516 #endif // defined(OS_CHROMEOS) |
1503 #endif // defined(ENABLE_FULL_PRINTING) | 1517 #endif // defined(ENABLE_FULL_PRINTING) |
1504 | 1518 |
| 1519 void BrowserOptionsHandler::SendHotwordAvailable() { |
| 1520 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); |
| 1521 if (group != "" && group != "Disabled") |
| 1522 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); |
| 1523 } |
| 1524 |
| 1525 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
| 1526 const base::ListValue* args) { |
| 1527 SendHotwordAvailable(); |
| 1528 } |
| 1529 |
1505 #if defined(OS_CHROMEOS) | 1530 #if defined(OS_CHROMEOS) |
1506 void BrowserOptionsHandler::HandleOpenWallpaperManager( | 1531 void BrowserOptionsHandler::HandleOpenWallpaperManager( |
1507 const base::ListValue* args) { | 1532 const base::ListValue* args) { |
1508 wallpaper_manager_util::OpenWallpaperManager(); | 1533 wallpaper_manager_util::OpenWallpaperManager(); |
1509 } | 1534 } |
1510 | 1535 |
1511 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( | 1536 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( |
1512 const base::ListValue* args) { | 1537 const base::ListValue* args) { |
1513 bool enabled = false; | 1538 bool enabled = false; |
1514 args->GetBoolean(0, &enabled); | 1539 args->GetBoolean(0, &enabled); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 1709 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
1685 bool has_users = !Profile::FromWebUI(web_ui())-> | 1710 bool has_users = !Profile::FromWebUI(web_ui())-> |
1686 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); | 1711 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); |
1687 base::FundamentalValue has_users_value(has_users); | 1712 base::FundamentalValue has_users_value(has_users); |
1688 web_ui()->CallJavascriptFunction( | 1713 web_ui()->CallJavascriptFunction( |
1689 "BrowserOptions.updateManagesSupervisedUsers", | 1714 "BrowserOptions.updateManagesSupervisedUsers", |
1690 has_users_value); | 1715 has_users_value); |
1691 } | 1716 } |
1692 | 1717 |
1693 } // namespace options | 1718 } // namespace options |
OLD | NEW |