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

* fix: re-enable synchronous spellcheck on Windows

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* revert: fix: empty suggestions with windows platform checker

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
trop[bot] 2025-02-21 20:46:13 -06:00 committed by GitHub
parent 4c81971213
commit 8e32d80512
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 63 deletions

View file

@ -193,14 +193,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
@ -1519,44 +1511,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,