blob: 5d27e2cbede65e387f8a16f9500da908829056e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2019 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 "components/spellcheck/renderer/spelling_engine.h"
#include "build/build_config.h"
#include "components/spellcheck/common/spellcheck_features.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
#if BUILDFLAG(USE_RENDERER_SPELLCHECKER)
#include "components/spellcheck/renderer/hunspell_engine.h"
#endif
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
#include "components/spellcheck/renderer/platform_spelling_engine.h"
#endif
SpellingEngine* CreateNativeSpellingEngine(
service_manager::LocalInterfaceProvider* embedder_provider) {
DCHECK(embedder_provider);
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
#if defined(OS_WIN)
if (spellcheck::UseWinHybridSpellChecker()) {
// On Windows, when using the hybrid spellchecker, both Hunspell and the
// platform are used for spellchecking. Ideally we'd want to know which
// languages are supported by the platform spellchecker, and only create a
// HunspellEngine for languages that aren't. Unfortunately, performing that
// check must be done asynchronously on the browser side, while this
// function must return synchronously. However, because the platform
// spellchecker uses a code path that does not involve a SpellingEngine when
// performing spellchecking, a solution is to create a HunspellEngine for
// every language, even those that the platform supports. Because the
// languages that the platform spellchecker supports are initialized on the
// browser side, the HunspellEngine returned here will remain disabled for
// these languages, so they will be skipped when performing the Hunspell
// check.
return new HunspellEngine(embedder_provider);
} else if (spellcheck::UseBrowserSpellChecker()) {
return new PlatformSpellingEngine(embedder_provider);
}
#else
return new PlatformSpellingEngine(embedder_provider);
#endif // defined(OS_WIN)
#endif // BUILDFLAG(USE_BROWSER_SPELLCHECKER)
#if BUILDFLAG(USE_RENDERER_SPELLCHECKER)
return new HunspellEngine(embedder_provider);
#endif // BUILDFLAG(USE_RENDERER_SPELLCHECKER)
}
|