Commit bb3f7ba2 authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen
Browse files

Fix preferences references


We were using the wrong spellcheck preferences, they have moved to the
spellcheck component. It mostly worked because their internal names had
stayed the same.

Change-Id: I485b11d88ee9c6e13d9c2b769c271d27bee4ba30
Reviewed-by: default avatarMichal Klocek <michal.klocek@qt.io>
Reviewed-by: default avatarAlexandru Croitor <alexandru.croitor@qt.io>
Showing with 10 additions and 10 deletions
...@@ -63,8 +63,9 @@ ...@@ -63,8 +63,9 @@
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#if BUILDFLAG(ENABLE_SPELLCHECK) #if BUILDFLAG(ENABLE_SPELLCHECK)
#include "chrome/common/pref_names.h"
#include "chrome/browser/spellchecker/spellcheck_service.h" #include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/common/pref_names.h"
#include "components/spellcheck/browser/pref_names.h"
#endif #endif
namespace QtWebEngineCore { namespace QtWebEngineCore {
...@@ -80,12 +81,11 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) ...@@ -80,12 +81,11 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
#if BUILDFLAG(ENABLE_SPELLCHECK) #if BUILDFLAG(ENABLE_SPELLCHECK)
// Initial spellcheck settings // Initial spellcheck settings
registry->RegisterListPref(prefs::kSpellCheckDictionaries, new base::ListValue());
registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
registry->RegisterStringPref(prefs::kSpellCheckDictionary, std::string()); registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, new base::ListValue());
registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string());
registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, false); registry->RegisterBooleanPref(spellcheck::prefs::kEnableSpellcheck, false);
registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, false); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false);
#endif //ENABLE_SPELLCHECK #endif //ENABLE_SPELLCHECK
m_prefService = factory.Create(std::move(registry.get())); m_prefService = factory.Create(std::move(registry.get()));
user_prefs::UserPrefs::Set(this, m_prefService.get()); user_prefs::UserPrefs::Set(this, m_prefService.get());
...@@ -216,7 +216,7 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language) ...@@ -216,7 +216,7 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language)
void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages)
{ {
StringListPrefMember dictionaries_pref; StringListPrefMember dictionaries_pref;
dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get()); dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get());
std::vector<std::string> dictionaries; std::vector<std::string> dictionaries;
dictionaries.reserve(languages.size()); dictionaries.reserve(languages.size());
for (const auto &language : languages) for (const auto &language : languages)
...@@ -227,7 +227,7 @@ void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) ...@@ -227,7 +227,7 @@ void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages)
QStringList BrowserContextQt::spellCheckLanguages() const QStringList BrowserContextQt::spellCheckLanguages() const
{ {
QStringList spellcheck_dictionaries; QStringList spellcheck_dictionaries;
for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) { for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) {
std::string dictionary; std::string dictionary;
if (value->GetAsString(&dictionary)) if (value->GetAsString(&dictionary))
spellcheck_dictionaries.append(QString::fromStdString(dictionary)); spellcheck_dictionaries.append(QString::fromStdString(dictionary));
...@@ -238,12 +238,12 @@ QStringList BrowserContextQt::spellCheckLanguages() const ...@@ -238,12 +238,12 @@ QStringList BrowserContextQt::spellCheckLanguages() const
void BrowserContextQt::setSpellCheckEnabled(bool enabled) void BrowserContextQt::setSpellCheckEnabled(bool enabled)
{ {
m_prefService->SetBoolean(prefs::kEnableContinuousSpellcheck, enabled); m_prefService->SetBoolean(spellcheck::prefs::kEnableSpellcheck, enabled);
} }
bool BrowserContextQt::isSpellCheckEnabled() const bool BrowserContextQt::isSpellCheckEnabled() const
{ {
return m_prefService->GetBoolean(prefs::kEnableContinuousSpellcheck); return m_prefService->GetBoolean(spellcheck::prefs::kEnableSpellcheck);
} }
#endif //ENABLE_SPELLCHECK #endif //ENABLE_SPELLCHECK
} // namespace QtWebEngineCore } // namespace QtWebEngineCore
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment