spellcheck_features.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/spellcheck/common/spellcheck_features.h"
  5. #include "base/system/sys_info.h"
  6. #include "build/build_config.h"
  7. #include "components/spellcheck/spellcheck_buildflags.h"
  8. #if BUILDFLAG(IS_WIN)
  9. #include "base/win/windows_version.h"
  10. #endif
  11. namespace spellcheck {
  12. #if BUILDFLAG(ENABLE_SPELLCHECK)
  13. bool UseBrowserSpellChecker() {
  14. #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  15. return false;
  16. #elif BUILDFLAG(IS_WIN)
  17. return base::FeatureList::IsEnabled(spellcheck::kWinUseBrowserSpellChecker) &&
  18. WindowsVersionSupportsSpellchecker();
  19. #else
  20. return true;
  21. #endif
  22. }
  23. #if BUILDFLAG(IS_WIN)
  24. const base::Feature kWinUseBrowserSpellChecker{
  25. "WinUseBrowserSpellChecker", base::FEATURE_ENABLED_BY_DEFAULT};
  26. const base::Feature kWinDelaySpellcheckServiceInit{
  27. "WinDelaySpellcheckServiceInit", base::FEATURE_ENABLED_BY_DEFAULT};
  28. const base::Feature kWinRetrieveSuggestionsOnlyOnDemand{
  29. "WinRetrieveSuggestionsOnlyOnDemand", base::FEATURE_ENABLED_BY_DEFAULT};
  30. bool WindowsVersionSupportsSpellchecker() {
  31. return base::win::GetVersion() > base::win::Version::WIN7 &&
  32. base::win::GetVersion() < base::win::Version::WIN_LAST;
  33. }
  34. #endif // BUILDFLAG(IS_WIN)
  35. #if BUILDFLAG(IS_ANDROID)
  36. bool IsAndroidSpellCheckFeatureEnabled() {
  37. return !base::SysInfo::IsLowEndDevice();
  38. }
  39. #endif // BUILDFLAG(IS_ANDROID)
  40. #endif // BUILDFLAG(ENABLE_SPELLCHECK)
  41. } // namespace spellcheck