summaryrefslogtreecommitdiff
path: root/chromium/components/spellcheck/renderer/spellcheck_provider.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/spellcheck/renderer/spellcheck_provider.cc')
-rw-r--r--chromium/components/spellcheck/renderer/spellcheck_provider.cc57
1 files changed, 26 insertions, 31 deletions
diff --git a/chromium/components/spellcheck/renderer/spellcheck_provider.cc b/chromium/components/spellcheck/renderer/spellcheck_provider.cc
index 58e2434a7ce..76f4452ab02 100644
--- a/chromium/components/spellcheck/renderer/spellcheck_provider.cc
+++ b/chromium/components/spellcheck/renderer/spellcheck_provider.cc
@@ -134,8 +134,10 @@ void SpellCheckProvider::RequestTextChecking(
last_results_.Assign(blink::WebVector<blink::WebTextCheckingResult>());
last_identifier_ = text_check_completions_.Add(std::move(completion));
-#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
- if (spellcheck::UseWinHybridSpellChecker()) {
+#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
+ if (spellcheck::UseBrowserSpellChecker()) {
+#if defined(OS_WIN)
+ // Determine whether a hybrid check is needed.
bool use_hunspell = spellcheck_->EnabledLanguageCount() > 0;
bool use_native =
spellcheck_->EnabledLanguageCount() != spellcheck_->LanguageCount();
@@ -145,33 +147,26 @@ void SpellCheckProvider::RequestTextChecking(
return;
}
- if (use_native) {
- // Some languages can be handled by the native spell checker. Use the
- // regular browser spell check code path. If hybrid spell check is
- // required (i.e. some locales must be checked by Hunspell), misspellings
- // from the native spell checker will be double-checked with Hunspell in
- // the |OnRespondTextCheck| callback.
- hybrid_requests_info_[last_identifier_] = {/*used_hunspell=*/use_hunspell,
- /*used_native=*/use_native,
- base::TimeTicks::Now()};
- GetSpellCheckHost().RequestTextCheck(
- text, routing_id(),
- base::BindOnce(&SpellCheckProvider::OnRespondTextCheck,
- weak_factory_.GetWeakPtr(), last_identifier_, text));
- } else {
+ if (!use_native) {
// No language can be handled by the native spell checker. Use the regular
// Hunspell code path.
GetSpellCheckHost().CallSpellingService(
text,
base::BindOnce(&SpellCheckProvider::OnRespondSpellingService,
weak_factory_.GetWeakPtr(), last_identifier_, text));
+ return;
}
- return;
- }
-#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
-#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
- if (spellcheck::UseBrowserSpellChecker()) {
+ // Some languages can be handled by the native spell checker. Use the
+ // regular browser spell check code path. If hybrid spell check is
+ // required (i.e. some locales must be checked by Hunspell), misspellings
+ // from the native spell checker will be double-checked with Hunspell in
+ // the |OnRespondTextCheck| callback.
+ hybrid_requests_info_[last_identifier_] = {/*used_hunspell=*/use_hunspell,
+ /*used_native=*/use_native,
+ base::TimeTicks::Now()};
+#endif // defined(OS_WIN)
+
// Text check (unified request for grammar and spell check) is only
// available for browser process, so we ask the system spellchecker
// over mojo or return an empty result if the checker is not available.
@@ -221,16 +216,16 @@ void SpellCheckProvider::CheckSpelling(
const int kWordStart = 0;
if (optional_suggestions) {
-#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
base::TimeTicks suggestions_start = base::TimeTicks::Now();
-#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
spellcheck::PerLanguageSuggestions per_language_suggestions;
spellcheck_->SpellCheckWord(word.c_str(), kWordStart, word.size(),
routing_id(), &offset, &length,
&per_language_suggestions);
-#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
- if (spellcheck::UseWinHybridSpellChecker() &&
+#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
+ if (spellcheck::UseBrowserSpellChecker() &&
spellcheck_->EnabledLanguageCount() < spellcheck_->LanguageCount()) {
// Also fetch suggestions from the browser process (native spellchecker).
// This is a synchronous Mojo call, because this method must return
@@ -249,7 +244,7 @@ void SpellCheckProvider::CheckSpelling(
spellcheck_renderer_metrics::RecordHunspellSuggestionDuration(
base::TimeTicks::Now() - suggestions_start);
}
-#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
std::vector<base::string16> suggestions;
spellcheck::FillSuggestions(per_language_suggestions, &suggestions);
@@ -342,29 +337,29 @@ void SpellCheckProvider::OnRespondTextCheck(
SpellCheck::ResultFilter result_filter = SpellCheck::DO_NOT_MODIFY;
-#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
const auto& request_info = hybrid_requests_info_.find(identifier);
- if (spellcheck::UseWinHybridSpellChecker() &&
+ if (spellcheck::UseBrowserSpellChecker() &&
request_info != hybrid_requests_info_.end() &&
request_info->second.used_hunspell && request_info->second.used_native) {
// Not all locales could be checked by the native spell checker. Verify each
// mistake against Hunspell in the locales that weren't checked.
result_filter = SpellCheck::USE_HUNSPELL_FOR_HYBRID_CHECK;
}
-#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
spellcheck_->CreateTextCheckingResults(result_filter,
/*line_offset=*/0, line, results,
&textcheck_results);
-#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
if (request_info != hybrid_requests_info_.end()) {
spellcheck_renderer_metrics::RecordSpellcheckDuration(
base::TimeTicks::Now() - request_info->second.request_start_ticks,
request_info->second.used_hunspell, request_info->second.used_native);
hybrid_requests_info_.erase(request_info);
}
-#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER)
+#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
completion->DidFinishCheckingText(textcheck_results);