diff options
Diffstat (limited to 'src/core/browser_context_qt.cpp')
-rw-r--r-- | src/core/browser_context_qt.cpp | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 1c326fb83..a6801e1d7 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -54,31 +54,31 @@ #include "content/public/browser/storage_partition.h" #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" -#include "base/prefs/pref_service.h" -#include "base/prefs/pref_service_factory.h" -#include "base/prefs/pref_registry_simple.h" +#include "components/prefs/pref_member.h" +#include "components/prefs/pref_service.h" +#include "components/prefs/testing_pref_store.h" +#include "components/prefs/pref_service.h" +#include "components/prefs/pref_service_factory.h" +#include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" +#if defined(ENABLE_SPELLCHECK) #include "chrome/common/pref_names.h" #include "chrome/browser/spellchecker/spellcheck_service.h" #endif namespace QtWebEngineCore { -#if defined(ENABLE_SPELLCHECK) BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) : m_adapter(adapter), m_prefStore(new TestingPrefStore()) { m_prefStore->SetInitializationCompleted(); - base::PrefServiceFactory factory; + PrefServiceFactory factory; factory.set_user_prefs(m_prefStore); scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); +#if defined(ENABLE_SPELLCHECK) // Initial spellcheck settings registry->RegisterListPref(prefs::kSpellCheckDictionaries, new base::ListValue()); registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); @@ -86,15 +86,10 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, false); registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, false); +#endif //ENABLE_SPELLCHECK m_prefService = factory.Create(std::move(registry.get())); user_prefs::UserPrefs::Set(this, m_prefService.get()); } -#else -BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) - : m_adapter(adapter) -{ -} -#endif //ENABLE_SPELLCHECK BrowserContextQt::~BrowserContextQt() { @@ -102,6 +97,16 @@ BrowserContextQt::~BrowserContextQt() content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, resourceContext.release()); } +PrefService* BrowserContextQt::GetPrefs() +{ + return m_prefService.get(); +} + +const PrefService* BrowserContextQt::GetPrefs() const +{ + return m_prefService.get(); +} + base::FilePath BrowserContextQt::GetPath() const { return toFilePath(m_adapter->dataPath()); @@ -122,24 +127,15 @@ net::URLRequestContextGetter *BrowserContextQt::GetRequestContext() return url_request_getter_.get(); } -net::URLRequestContextGetter *BrowserContextQt::GetRequestContextForRenderProcess(int) -{ - return GetRequestContext(); -} - -net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContext() -{ - return GetRequestContext(); -} - -net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContextForRenderProcess(int) +net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContext() { - return GetRequestContext(); + return url_request_getter_.get(); } -net::URLRequestContextGetter *BrowserContextQt::GetMediaRequestContextForStoragePartition(const base::FilePath&, bool) +net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContextForStoragePartition(const base::FilePath&, bool) { - return GetRequestContext(); + Q_UNIMPLEMENTED(); + return nullptr; } content::ResourceContext *BrowserContextQt::GetResourceContext() @@ -177,7 +173,7 @@ content::SSLHostStateDelegate* BrowserContextQt::GetSSLHostStateDelegate() return sslHostStateDelegate.get(); } -scoped_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&) +std::unique_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&) { return nullptr; } @@ -200,6 +196,15 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::Pr return url_request_getter_.get(); } +net::URLRequestContextGetter *BrowserContextQt::CreateRequestContextForStoragePartition( + const base::FilePath& partition_path, bool in_memory, + content::ProtocolHandlerMap* protocol_handlers, + content::URLRequestInterceptorScopedVector request_interceptors) +{ + Q_UNIMPLEMENTED(); + return nullptr; +} + #if defined(ENABLE_SPELLCHECK) void BrowserContextQt::failedToLoadDictionary(const std::string &language) { @@ -208,18 +213,27 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language) << "Make sure that correct bdic file is in:" << toQt(WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES).value()); } -void BrowserContextQt::setSpellCheckLanguage(const QString &language) +void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) { - base::ListValue dictionaries; - dictionaries.AppendString(language.toStdString()); - m_prefService->Set(prefs::kSpellCheckDictionaries, dictionaries); + StringListPrefMember dictionaries_pref; + dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get()); + std::vector<std::string> dictionaries; + dictionaries.reserve(languages.size()); + for (const auto &language : languages) + dictionaries.push_back(language.toStdString()); + dictionaries_pref.SetValue(dictionaries); } -QString BrowserContextQt::spellCheckLanguage() const +QStringList BrowserContextQt::spellCheckLanguages() const { - std::string dictionary; - m_prefService->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &dictionary); - return QString::fromStdString(dictionary); + QStringList spellcheck_dictionaries; + for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) { + std::string dictionary; + if (value->GetAsString(&dictionary)) + spellcheck_dictionaries.append(QString::fromStdString(dictionary)); + } + + return spellcheck_dictionaries; } void BrowserContextQt::setSpellCheckEnabled(bool enabled) |