summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-04-28 19:47:46 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-16 15:19:44 +0100
commitdb9dba9487dc8c3edeb636266c35e6b0955f9226 (patch)
tree2f8d4c331a14f5bef60f096796c6140a3665ca40
parent4282866543116cfc1ae0f5a7f4be2894c54d0395 (diff)
downloadqtwebengine-chromium-db9dba9487dc8c3edeb636266c35e6b0955f9226.tar.gz
Update handling of loading the dictionary
Add notifications if dictionary can not be loaded, do not delete corrupted files, simplify naming of dictionaries - do not use hardcoded region language mapping. Change-Id: Ifcc7952e5815cadf7aeb64577988749c0d1a604d Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc11
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_service.cc4
-rw-r--r--chromium/components/spellcheck/common/spellcheck_common.cc3
-rw-r--r--chromium/content/public/browser/browser_context.h6
4 files changed, 21 insertions, 3 deletions
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
index 26c6045ae10..de5436156a8 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
@@ -383,7 +383,9 @@ SpellcheckHunspellDictionary::OpenDictionaryFile(base::TaskRunner* task_runner,
dictionary.file.Initialize(dictionary.path,
base::File::FLAG_READ | base::File::FLAG_OPEN);
} else {
+#ifndef TOOLKIT_QT
base::DeleteFile(dictionary.path);
+#endif
}
return dictionary;
@@ -414,7 +416,7 @@ void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete(
DictionaryFile file) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
dictionary_file_ = std::move(file);
-
+#ifndef TOOLKIT_QT
if (!dictionary_file_.file.IsValid()) {
// Notify browser tests that this dictionary is corrupted. Skip downloading
// the dictionary in browser tests.
@@ -433,6 +435,13 @@ void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete(
}
InformListenersOfInitialization();
+#else
+ if (!dictionary_file_.file.IsValid())
+ // We never download, so safe to reuse this handler
+ InformListenersOfDownloadFailure();
+ else
+ InformListenersOfInitialization();
+#endif
}
#endif // !defined(OS_ANDROID)
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_service.cc b/chromium/chrome/browser/spellchecker/spellcheck_service.cc
index 09256573b84..02673464a96 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_service.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_service.cc
@@ -568,6 +568,10 @@ void SpellcheckService::OnHunspellDictionaryDownloadSuccess(
void SpellcheckService::OnHunspellDictionaryDownloadFailure(
const std::string& language) {
+#ifdef TOOLKIT_QT
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ context_->FailedToLoadDictionary(language);
+#endif
}
void SpellcheckService::InitializeDictionaries(base::OnceClosure done) {
diff --git a/chromium/components/spellcheck/common/spellcheck_common.cc b/chromium/components/spellcheck/common/spellcheck_common.cc
index d216362ada7..546d8ba3180 100644
--- a/chromium/components/spellcheck/common/spellcheck_common.cc
+++ b/chromium/components/spellcheck/common/spellcheck_common.cc
@@ -157,8 +157,7 @@ base::FilePath GetVersionedFileName(base::StringPiece input_language,
}
std::string versioned_bdict_file_name(language + version + ".bdic");
#else
- std::string language = GetSpellCheckLanguageRegion(input_language);
- std::string versioned_bdict_file_name(language + ".bdic");
+ std::string versioned_bdict_file_name(input_language + ".bdic");
#endif
return dict_dir.AppendASCII(versioned_bdict_file_name);
}
diff --git a/chromium/content/public/browser/browser_context.h b/chromium/content/public/browser/browser_context.h
index 4e55b1a79ac..898a863c53b 100644
--- a/chromium/content/public/browser/browser_context.h
+++ b/chromium/content/public/browser/browser_context.h
@@ -18,6 +18,7 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/supports_user_data.h"
+#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -339,6 +340,11 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// directly, so privacy is not compromised.
virtual media::VideoDecodePerfHistory* GetVideoDecodePerfHistory();
+#if defined(TOOLKIT_QT) && BUILDFLAG(ENABLE_SPELLCHECK)
+ // Inform about not working dictionary for given language
+ virtual void FailedToLoadDictionary(const std::string& language) = 0;
+#endif
+
// Returns a LearningSession associated with |this|. Used as the central
// source from which to retrieve LearningTaskControllers for media machine
// learning.