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

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

Issue 134103005: [Hotword] Putting preferences under search for hotword service. Putting behind a flag. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adding a line. maybe it will help? Created 6 years, 11 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 <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
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
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
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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 allowed); 1511 allowed);
1498 } 1512 }
1499 1513
1500 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() { 1514 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() {
1501 web_ui()->CallJavascriptFunction( 1515 web_ui()->CallJavascriptFunction(
1502 "BrowserOptions.removeCloudPrintConnectorSection"); 1516 "BrowserOptions.removeCloudPrintConnectorSection");
1503 } 1517 }
1504 #endif // defined(OS_CHROMEOS) 1518 #endif // defined(OS_CHROMEOS)
1505 #endif // defined(ENABLE_FULL_PRINTING) 1519 #endif // defined(ENABLE_FULL_PRINTING)
1506 1520
1521 void BrowserOptionsHandler::SendHotwordAvailable() {
1522 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger");
1523 if (group != "" && group != "Disabled")
1524 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection");
1525 }
1526
1527 void BrowserOptionsHandler::HandleRequestHotwordAvailable(
1528 const base::ListValue* args) {
1529 SendHotwordAvailable();
1530 }
1531
1507 #if defined(OS_CHROMEOS) 1532 #if defined(OS_CHROMEOS)
1508 void BrowserOptionsHandler::HandleOpenWallpaperManager( 1533 void BrowserOptionsHandler::HandleOpenWallpaperManager(
1509 const base::ListValue* args) { 1534 const base::ListValue* args) {
1510 wallpaper_manager_util::OpenWallpaperManager(); 1535 wallpaper_manager_util::OpenWallpaperManager();
1511 } 1536 }
1512 1537
1513 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( 1538 void BrowserOptionsHandler::VirtualKeyboardChangeCallback(
1514 const base::ListValue* args) { 1539 const base::ListValue* args) {
1515 bool enabled = false; 1540 bool enabled = false;
1516 args->GetBoolean(0, &enabled); 1541 args->GetBoolean(0, &enabled);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/browser/ui/webui/options/settings_app_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698