spelling_engine.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 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/renderer/spelling_engine.h"
  5. #include "build/build_config.h"
  6. #include "components/spellcheck/common/spellcheck_features.h"
  7. #include "components/spellcheck/spellcheck_buildflags.h"
  8. #include "services/service_manager/public/cpp/local_interface_provider.h"
  9. #if BUILDFLAG(USE_RENDERER_SPELLCHECKER)
  10. #include "components/spellcheck/renderer/hunspell_engine.h"
  11. #endif
  12. #if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  13. #include "components/spellcheck/renderer/platform_spelling_engine.h"
  14. #endif
  15. SpellingEngine* CreateNativeSpellingEngine(
  16. service_manager::LocalInterfaceProvider* embedder_provider) {
  17. DCHECK(embedder_provider);
  18. #if BUILDFLAG(IS_WIN)
  19. // On Windows, always return a HunspellEngine. This is a simplification to
  20. // avoid needing an async Mojo call to the browser process to determine which
  21. // languages are supported by the native spell checker. Returning a
  22. // HunspellEngine for languages supported by the native spell checker is
  23. // harmless because the SpellingEngine object returned here is never used
  24. // during native spell checking. It also doesn't affect Hunspell, since these
  25. // languages are skipped during the Hunspell check.
  26. return new HunspellEngine(embedder_provider);
  27. #elif BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  28. return new PlatformSpellingEngine(embedder_provider);
  29. #elif BUILDFLAG(USE_RENDERER_SPELLCHECKER)
  30. return new HunspellEngine(embedder_provider);
  31. #else
  32. return nullptr;
  33. #endif
  34. }