From 0bf8a13a4d0391339bae686e199fb922b64a1dcc Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 28 Apr 2016 19:20:33 +0200 Subject: Remove availableDictionaries from spellcheck api This method is broken, since SpellcheckerService is lazily initialized and dictionaries might be not loaded yet. Moreover there is a missing implementation on mac. Instead log warning when SpellcheckService can not load dictionary. Change-Id: Ifa2e769d83307543fa6cdf529475e9ab980022f0 Reviewed-by: Allan Sandfeld Jensen --- src/core/browser_context_adapter.cpp | 9 --------- src/core/browser_context_qt.cpp | 20 ++++++-------------- src/core/browser_context_qt.h | 2 +- src/webengine/api/qquickwebengineprofile.cpp | 25 ------------------------- src/webengine/api/qquickwebengineprofile.h | 1 - src/webenginewidgets/api/qwebengineprofile.cpp | 17 ----------------- src/webenginewidgets/api/qwebengineprofile.h | 1 - 7 files changed, 7 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index e0f933562..fe667c570 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -466,15 +466,6 @@ void BrowserContextAdapter::clearHttpCache() m_browserContext->url_request_getter_->clearHttpCache(); } -QStringList BrowserContextAdapter::spellCheckLanguages(const QStringList &acceptLanguages) -{ -#if defined(ENABLE_SPELLCHECK) - return m_browserContext->spellCheckLanguages(acceptLanguages); -#else - return QStringList(); -#endif -} - void BrowserContextAdapter::setSpellCheckLanguage(const QString &language) { #if defined(ENABLE_SPELLCHECK) diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 5b3115530..e76222d48 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -47,6 +47,7 @@ #include "ssl_host_state_delegate_qt.h" #include "type_conversion.h" #include "url_request_context_getter_qt.h" +#include "web_engine_library_info.h" #include "base/time/time.h" #include "content/public/browser/browser_thread.h" @@ -54,6 +55,7 @@ #include "net/proxy/proxy_config_service.h" #if defined(ENABLE_SPELLCHECK) +#include "base/base_paths.h" #include "base/prefs/pref_member.h" #include "base/prefs/pref_service.h" #include "base/prefs/testing_pref_store.h" @@ -201,22 +203,12 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::Pr return url_request_getter_.get(); } - #if defined(ENABLE_SPELLCHECK) -QStringList BrowserContextQt::spellCheckLanguages(const QStringList& acceptedLanguages) +void BrowserContextQt::failedToLoadDictionary(const std::string &language) { - QStringList result; -#if !defined(OS_MACOSX) // no SpellcheckService::GetSpellCheckLanguages - m_prefService->SetString(prefs::kAcceptLanguages,acceptedLanguages.join(",").toStdString()); - - std::vector vec; - SpellcheckService::GetSpellCheckLanguages(this, &vec); - - for (std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { - result << QString::fromStdString(*it); - } -#endif - return result; + Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + qWarning() << "Could not load dictionary for:" << toQt(language) << endl + << "Make sure that correct bdic file is in:" << toQt(WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES).value()); } void BrowserContextQt::setSpellCheckLanguage(const QString &language) diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h index 08ac05fd4..e2156f147 100644 --- a/src/core/browser_context_qt.h +++ b/src/core/browser_context_qt.h @@ -92,7 +92,7 @@ public: BrowserContextAdapter *adapter() { return m_adapter; } #if defined(ENABLE_SPELLCHECK) - QStringList spellCheckLanguages(const QStringList &acceptLanguages); + void failedToLoadDictionary(const std::string& language) override; void setSpellCheckLanguage(const QString &language); QString spellCheckLanguage() const; void setSpellCheckEnabled(bool enabled); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index d7a84c106..cf9d7ab2f 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -612,31 +612,6 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() return profile; } -/*! - \qmlmethod void QQuickWebEngineProfile::availableDictionaries() - - Returns the subset of \a languages supported by the spell checker. - Checks whether the spell checker dictionary is installed for the specified - language from the \a languages list. If the dictionary file is missing - or corrupted, the language is removed from the returned list. - - \since QtWebEngine 1.3 -*/ - -/*! - Returns the subset of \a languages supported by the spell checker. - Checks whether the spell checker dictionary is installed for the specified - language from the \a languages list. If the dictionary file is missing - or corrupted, the language is removed from the returned list. - - \since QtWebEngine 1.3 -*/ -QStringList QQuickWebEngineProfile::availableDictionaries(const QStringList &languages) -{ - const Q_D(QQuickWebEngineProfile); - return d->browserContext()->spellCheckLanguages(languages); -} - /*! \property QQuickWebEngineProfile::spellCheckLanguage \brief the language used by the spell checker. diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index 8d120d10e..273375fc6 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -131,7 +131,6 @@ public: void clearHttpCache(); - Q_REVISION(2) Q_INVOKABLE QStringList availableDictionaries(const QStringList &languages); Q_REVISION(2) void setSpellCheckLanguage(const QString &language); Q_REVISION(2) QString spellCheckLanguage() const; Q_REVISION(2) void setSpellCheckEnabled(bool enabled); diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 2dab0aa08..1f5912667 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -555,23 +555,6 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile() return profile; } -/*! - \since 5.7 - - Returns the subset of \a languages supported by the spell checker. - - Checks whether the spell checker dictionary is installed for the specified - language from the \a languages list. If the dictionary file is missing - or corrupted, the language is removed from the returned list. - - \sa setSpellCheckLanguage() -*/ -QStringList QWebEngineProfile::availableDictionaries(const QStringList &languages) -{ - const Q_D(QWebEngineProfile); - return d->browserContext()->spellCheckLanguages(languages); -} - /*! \since 5.7 diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 9c473eee9..868b4b0f5 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -121,7 +121,6 @@ public: void clearHttpCache(); - QStringList availableDictionaries(const QStringList &languages); void setSpellCheckLanguage(const QString &language); QString spellCheckLanguage() const; void setSpellCheckEnabled(bool enabled); -- cgit v1.2.3