fix: re-enable synchronous spellcheck on Windows (#45712)

* fix: re-enable synchronous spellcheck on Windows

* revert: fix: empty suggestions with windows platform checker

---------

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
Keeley Hammond 2025-02-21 14:45:46 -08:00 committed by GitHub
parent 8d58999135
commit 6248c2436a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 63 deletions

View file

@ -194,14 +194,6 @@
#include "content/public/browser/plugin_service.h"
#endif
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/spellcheck/browser/spellcheck_platform.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/spellcheck/common/spellcheck_features.h"
#endif
#if !IS_MAS_BUILD()
#include "chrome/browser/hang_monitor/hang_crash_dump.h" // nogncheck
#endif
@ -1521,44 +1513,11 @@ void WebContents::RendererResponsive(
bool WebContents::HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) {
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
if (!params.misspelled_word.empty() && spellcheck::UseBrowserSpellChecker()) {
SpellcheckService* spellcheck_service =
SpellcheckServiceFactory::GetForContext(
render_frame_host.GetBrowserContext());
if (spellcheck_service) {
spellcheck_platform::GetPerLanguageSuggestions(
spellcheck_service->platform_spell_checker(), params.misspelled_word,
base::BindOnce(&WebContents::OnGetPlatformSuggestionsComplete,
GetWeakPtr(), std::ref(render_frame_host), params));
}
} else {
#endif
Emit("context-menu",
std::make_tuple(params, &render_frame_host,
std::optional<std::vector<std::u16string>>{}));
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
}
#endif
Emit("context-menu", std::make_pair(params, &render_frame_host));
return true;
}
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
void WebContents::OnGetPlatformSuggestionsComplete(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params,
const spellcheck::PerLanguageSuggestions&
platform_per_language_suggestions) {
std::vector<std::u16string> combined_suggestions;
spellcheck::FillSuggestions(platform_per_language_suggestions,
&combined_suggestions);
Emit("context-menu",
std::make_tuple(params, &render_frame_host,
std::make_optional(combined_suggestions)));
}
#endif
void WebContents::FindReply(content::WebContents* web_contents,
int request_id,
int number_of_matches,