<commit_before>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/preferences.h"

#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/prefs/pref_member.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/chromeos/drive/drive_file_system_util.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/input_method/xkeyboard.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/drm_settings.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/power_manager_settings.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "googleurl/src/gurl.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/events/event_utils.h"
#include "unicode/timezone.h"

namespace chromeos {

static const char kFallbackInputMethodLocale[] = "en-US";

Preferences::Preferences()
    : prefs_(NULL),
      input_method_manager_(input_method::InputMethodManager::GetInstance()) {
}

Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
    : input_method_manager_(input_method_manager) {
}

Preferences::~Preferences() {}

// static
void Preferences::RegisterUserPrefs(PrefService* prefs) {
  std::string hardware_keyboard_id;
  // TODO(yusukes): Remove the runtime hack.
  if (base::chromeos::IsRunningOnChromeOS()) {
    input_method::InputMethodManager* manager =
        input_method::InputMethodManager::GetInstance();
    if (manager) {
      hardware_keyboard_id =
          manager->GetInputMethodUtil()->GetHardwareInputMethodId();
    }
  } else {
    hardware_keyboard_id = "xkb:us::eng";  // only for testing.
  }

  prefs->RegisterBooleanPref(prefs::kTapToClickEnabled,
                             true,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kTapDraggingEnabled,
                             false,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerClick,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerSwipe,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(
      prefs::kNaturalScroll,
      CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kNaturalScrollDefault),
      PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kPrimaryMouseButtonRight,
                             false,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kLabsMediaplayerEnabled,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kLabsAdvancedFilesystemEnabled,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  // Check if the accessibility pref is already registered, which can happen
  // in WizardController::RegisterPrefs. We still want to try to register
  // the pref here in case of Chrome/Linux with ChromeOS=1.
  if (prefs->FindPreference(prefs::kSpokenFeedbackEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kSpokenFeedbackEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kHighContrastEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kHighContrastEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kScreenMagnifierScale) == NULL) {
    prefs->RegisterDoublePref(prefs::kScreenMagnifierScale,
                              std::numeric_limits<double>::min(),
                              PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kMagnifierType) == NULL) {
    prefs->RegisterStringPref(prefs::kMagnifierType,
                              "",
                              PrefService::SYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kShouldAlwaysShowAccessibilityMenu) ==
      NULL) {
    prefs->RegisterBooleanPref(prefs::kShouldAlwaysShowAccessibilityMenu,
                              "",
                              PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kVirtualKeyboardEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kVirtualKeyboardEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  prefs->RegisterIntegerPref(prefs::kMouseSensitivity,
                             3,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity,
                             3,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kUse24HourClock,<commit_msg>Fix the bug that A11y tray is enabled by default<commit_after>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/preferences.h"

#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/prefs/pref_member.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/chromeos/drive/drive_file_system_util.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/input_method/xkeyboard.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/drm_settings.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/power_manager_settings.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "googleurl/src/gurl.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/events/event_utils.h"
#include "unicode/timezone.h"

namespace chromeos {

static const char kFallbackInputMethodLocale[] = "en-US";

Preferences::Preferences()
    : prefs_(NULL),
      input_method_manager_(input_method::InputMethodManager::GetInstance()) {
}

Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
    : input_method_manager_(input_method_manager) {
}

Preferences::~Preferences() {}

// static
void Preferences::RegisterUserPrefs(PrefService* prefs) {
  std::string hardware_keyboard_id;
  // TODO(yusukes): Remove the runtime hack.
  if (base::chromeos::IsRunningOnChromeOS()) {
    input_method::InputMethodManager* manager =
        input_method::InputMethodManager::GetInstance();
    if (manager) {
      hardware_keyboard_id =
          manager->GetInputMethodUtil()->GetHardwareInputMethodId();
    }
  } else {
    hardware_keyboard_id = "xkb:us::eng";  // only for testing.
  }

  prefs->RegisterBooleanPref(prefs::kTapToClickEnabled,
                             true,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kTapDraggingEnabled,
                             false,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerClick,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerSwipe,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(
      prefs::kNaturalScroll,
      CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kNaturalScrollDefault),
      PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kPrimaryMouseButtonRight,
                             false,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kLabsMediaplayerEnabled,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kLabsAdvancedFilesystemEnabled,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  // Check if the accessibility pref is already registered, which can happen
  // in WizardController::RegisterPrefs. We still want to try to register
  // the pref here in case of Chrome/Linux with ChromeOS=1.
  if (prefs->FindPreference(prefs::kSpokenFeedbackEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kSpokenFeedbackEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kHighContrastEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kHighContrastEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kScreenMagnifierScale) == NULL) {
    prefs->RegisterDoublePref(prefs::kScreenMagnifierScale,
                              std::numeric_limits<double>::min(),
                              PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kMagnifierType) == NULL) {
    prefs->RegisterStringPref(prefs::kMagnifierType,
                              "",
                              PrefService::SYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kShouldAlwaysShowAccessibilityMenu) ==
      NULL) {
    prefs->RegisterBooleanPref(prefs::kShouldAlwaysShowAccessibilityMenu,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  if (prefs->FindPreference(prefs::kVirtualKeyboardEnabled) == NULL) {
    prefs->RegisterBooleanPref(prefs::kVirtualKeyboardEnabled,
                               false,
                               PrefService::UNSYNCABLE_PREF);
  }
  prefs->RegisterIntegerPref(prefs::kMouseSensitivity,
                             3,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity,
                             3,
                             PrefService::SYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kUse24HourClock,
{'fraction_non_alphanumeric': 0.10527205136870564, 'fraction_numerical': 0.002027712064886786, 'mean_word_length': 2.886080105055811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2218113', 'n_tokens_mistral': 3472, 'n_tokens_neox': 3425, 'n_words': 463}