diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-04-28 19:47:46 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-23 13:31:33 +0200 |
commit | e6fbb0a33e5d34bcdace02c0eef046a47b563fe8 (patch) | |
tree | ecfcdb6bf3d98ee38165cf8ec5c87c573d06b4a9 | |
parent | 7f4afec076907599f7c2c4452cb61e6f616e1c2c (diff) | |
download | qtwebengine-chromium-e6fbb0a33e5d34bcdace02c0eef046a47b563fe8.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>
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 fc6c6a98b7c..737facca648 100644 --- a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc +++ b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc @@ -362,7 +362,9 @@ SpellcheckHunspellDictionary::OpenDictionaryFile(const base::FilePath& path) { dictionary.file.Initialize(dictionary.path, base::File::FLAG_READ | base::File::FLAG_OPEN); } else { +#ifndef TOOLKIT_QT base::DeleteFile(dictionary.path, false); +#endif } return dictionary; @@ -392,7 +394,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. @@ -411,6 +413,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 d66d4faf867..ef444bd5c6f 100644 --- a/chromium/chrome/browser/spellchecker/spellcheck_service.cc +++ b/chromium/chrome/browser/spellchecker/spellcheck_service.cc @@ -316,6 +316,10 @@ void SpellcheckService::OnHunspellDictionaryDownloadSuccess( void SpellcheckService::OnHunspellDictionaryDownloadFailure( const std::string& language) { +#ifdef TOOLKIT_QT + DCHECK_CURRENTLY_ON(BrowserThread::UI); + context_->FailedToLoadDictionary(language); +#endif } // static diff --git a/chromium/components/spellcheck/common/spellcheck_common.cc b/chromium/components/spellcheck/common/spellcheck_common.cc index 4896516906c..0c676161b28 100644 --- a/chromium/components/spellcheck/common/spellcheck_common.cc +++ b/chromium/components/spellcheck/common/spellcheck_common.cc @@ -137,8 +137,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 ddb42286696..f51e88f5021 100644 --- a/chromium/content/public/browser/browser_context.h +++ b/chromium/content/public/browser/browser_context.h @@ -16,6 +16,7 @@ #include "base/callback_forward.h" #include "base/containers/hash_tables.h" #include "base/supports_user_data.h" +#include "components/spellcheck/spellcheck_buildflags.h" #include "content/common/content_export.h" #include "net/url_request/url_request_interceptor.h" #include "net/url_request/url_request_job_factory.h" @@ -316,6 +317,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 + private: const std::string media_device_id_salt_; bool was_notify_will_be_destroyed_called_ = false; |