summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 10:22:43 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 12:36:28 +0000
commit271a6c3487a14599023a9106329505597638d793 (patch)
treee040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
parent7b2ffa587235a47d4094787d72f38102089f402a (diff)
downloadqtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc')
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc47
1 files changed, 34 insertions, 13 deletions
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
index 5c22d2cf923..d4ac62ef820 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
@@ -24,6 +24,7 @@
#include "chrome/common/chrome_paths.h"
#include "components/spellcheck/browser/spellcheck_platform.h"
#include "components/spellcheck/common/spellcheck_common.h"
+#include "components/spellcheck/common/spellcheck_features.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -117,8 +118,7 @@ SpellcheckHunspellDictionary::SpellcheckHunspellDictionary(
#if !defined(OS_ANDROID)
spellcheck_service_(spellcheck_service),
#endif
- download_status_(DOWNLOAD_NONE),
- weak_ptr_factory_(this) {
+ download_status_(DOWNLOAD_NONE) {
}
SpellcheckHunspellDictionary::~SpellcheckHunspellDictionary() {
@@ -127,27 +127,31 @@ SpellcheckHunspellDictionary::~SpellcheckHunspellDictionary() {
FROM_HERE,
base::BindOnce(&CloseDictionary, std::move(dictionary_file_.file)));
}
+
+#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
+ // Disable the language from platform spellchecker.
+ if (spellcheck::UseBrowserSpellChecker())
+ spellcheck_platform::DisableLanguage(language_);
+#endif
}
void SpellcheckHunspellDictionary::Load() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
- if (spellcheck_platform::SpellCheckerAvailable() &&
- spellcheck_platform::PlatformSupportsLanguage(language_)) {
- use_browser_spellchecker_ = true;
- spellcheck_platform::SetLanguage(language_);
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(
- &SpellcheckHunspellDictionary::InformListenersOfInitialization,
- weak_ptr_factory_.GetWeakPtr()));
+ if (spellcheck::UseBrowserSpellChecker()) {
+ if (spellcheck_platform::SpellCheckerAvailable() &&
+ spellcheck_platform::PlatformSupportsLanguage(language_)) {
+ spellcheck_platform::SetLanguage(
+ language_, base::BindOnce(&SpellcheckHunspellDictionary::
+ SpellCheckPlatformSetLanguageCompleted,
+ base::Unretained(this)));
+ }
return;
}
#endif // USE_BROWSER_SPELLCHECKER
-// Mac falls back on hunspell if its platform spellchecker isn't available.
-// However, Android does not support hunspell.
+// Android does not support hunspell.
#if !defined(OS_ANDROID)
base::PostTaskAndReplyWithResult(
task_runner_.get(), FROM_HERE,
@@ -441,3 +445,20 @@ void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() {
for (Observer& observer : observers_)
observer.OnHunspellDictionaryDownloadFailure(language_);
}
+
+#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
+void SpellcheckHunspellDictionary::SpellCheckPlatformSetLanguageCompleted(
+ bool result) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (!result)
+ return;
+
+ use_browser_spellchecker_ = true;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(
+ &SpellcheckHunspellDictionary::InformListenersOfInitialization,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+#endif