diff options
Diffstat (limited to 'src/core/profile_qt.cpp')
-rw-r--r-- | src/core/profile_qt.cpp | 101 |
1 files changed, 94 insertions, 7 deletions
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 2387eba1b..5977a28a8 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -41,6 +41,7 @@ #include "profile_adapter.h" #include "browsing_data_remover_delegate_qt.h" +#include "command_line_pref_store_qt.h" #include "download_manager_delegate_qt.h" #include "net/ssl_host_state_delegate_qt.h" #include "net/url_request_context_getter_qt.h" @@ -48,9 +49,11 @@ #include "qtwebenginecoreglobal_p.h" #include "type_conversion.h" #include "web_engine_library_info.h" +#include "web_engine_context.h" #include "base/time/time.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/browser/storage_partition.h" #include "base/base_paths.h" @@ -62,22 +65,39 @@ #include "components/prefs/pref_service_factory.h" #include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" +#include "components/proxy_config/pref_proxy_config_tracker_impl.h" +#include "chrome/common/pref_names.h" #if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spellcheck_service.h" -#include "chrome/common/pref_names.h" #include "components/spellcheck/browser/pref_names.h" #endif +#if BUILDFLAG(ENABLE_EXTENSIONS) +#include "components/guest_view/browser/guest_view_manager.h" +#include "extensions/browser/extension_protocols.h" +#include "extensions/browser/pref_names.h" +#include "extensions/browser/process_manager.h" +#include "extensions/common/constants.h" + +#include "extensions/extension_system_qt.h" +#endif + namespace QtWebEngineCore { ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) - : m_profileIOData(new ProfileIODataQt(this)), - m_profileAdapter(profileAdapter) + : m_sharedCorsOriginAccessList(content::SharedCorsOriginAccessList::Create()) + , m_profileIOData(new ProfileIODataQt(this)) + , m_profileAdapter(profileAdapter) +#if BUILDFLAG(ENABLE_EXTENSIONS) + , m_extensionSystem(nullptr) +#endif // BUILDFLAG(ENABLE_EXTENSIONS) { PrefServiceFactory factory; factory.set_user_prefs(new InMemoryPrefStore); + factory.set_command_line_prefs(base::MakeRefCounted<CommandLinePrefStoreQt>( + WebEngineContext::commandLine())); PrefRegistrySimple *registry = new PrefRegistrySimple(); - + PrefProxyConfigTrackerImpl::RegisterPrefs(registry); #if QT_CONFIG(webengine_spellchecker) // Initial spellcheck settings registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); @@ -87,6 +107,24 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false); #endif // QT_CONFIG(webengine_spellchecker) + registry->RegisterBooleanPref(prefs::kShowInternalAccessibilityTree, false); + registry->RegisterIntegerPref(prefs::kNotificationNextPersistentId, 10000); + +#if BUILDFLAG(ENABLE_EXTENSIONS) + registry->RegisterDictionaryPref(extensions::pref_names::kExtensions); + registry->RegisterListPref(extensions::pref_names::kInstallAllowList); + registry->RegisterListPref(extensions::pref_names::kInstallDenyList); + registry->RegisterDictionaryPref(extensions::pref_names::kInstallForceList); + registry->RegisterDictionaryPref(extensions::pref_names::kInstallLoginScreenAppList); + registry->RegisterListPref(extensions::pref_names::kAllowedTypes); + registry->RegisterBooleanPref(extensions::pref_names::kStorageGarbageCollect, false); + registry->RegisterListPref(extensions::pref_names::kAllowedInstallSites); + registry->RegisterStringPref(extensions::pref_names::kLastChromeVersion, std::string()); + registry->RegisterListPref(extensions::pref_names::kNativeMessagingBlacklist); + registry->RegisterListPref(extensions::pref_names::kNativeMessagingWhitelist); + registry->RegisterBooleanPref(extensions::pref_names::kNativeMessagingUserLevelHosts, true); +#endif // BUILDFLAG(ENABLE_EXTENSIONS) + m_prefService = factory.Create(registry); user_prefs::UserPrefs::Set(this, m_prefService.get()); @@ -95,6 +133,11 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) // ProfileQt object is allocated at the same address as a previously // destroyed one. Needs to be called after WebEngineContext initialization. BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(this); + +#if BUILDFLAG(ENABLE_EXTENSIONS) + m_extensionSystem = static_cast<extensions::ExtensionSystemQt*>(extensions::ExtensionSystem::Get(this)); + m_extensionSystem->InitForRegularProfile(true); +#endif } ProfileQt::~ProfileQt() @@ -123,6 +166,11 @@ base::FilePath ProfileQt::GetPath() const return toFilePath(m_profileAdapter->dataPath()); } +base::FilePath ProfileQt::GetCachePath() const +{ + return toFilePath(m_profileAdapter->cachePath()); +} + bool ProfileQt::IsOffTheRecord() const { return m_profileAdapter->isOffTheRecord(); @@ -156,7 +204,11 @@ content::DownloadManagerDelegate *ProfileQt::GetDownloadManagerDelegate() content::BrowserPluginGuestManager *ProfileQt::GetGuestManager() { +#if BUILDFLAG(ENABLE_EXTENSIONS) + return guest_view::GuestViewManager::FromBrowserContext(this); +#else return nullptr; +#endif } storage::SpecialStoragePolicy *ProfileQt::GetSpecialStoragePolicy() @@ -212,6 +264,12 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContext( { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(!m_urlRequestContextGetter.get()); +#if BUILDFLAG(ENABLE_EXTENSIONS) + extensions::InfoMap* extension_info_map = GetExtensionSystem()->info_map(); + (*protocol_handlers)[extensions::kExtensionScheme] = + extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),extension_info_map); +#endif + m_profileIOData->setRequestContextData(protocol_handlers, std::move(request_interceptors)); m_profileIOData->updateStorageSettings(); m_urlRequestContextGetter = new URLRequestContextGetterQt(m_profileIOData.get()); @@ -227,12 +285,33 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContextForStoragePartition return nullptr; } +content::ClientHintsControllerDelegate *ProfileQt::GetClientHintsControllerDelegate() +{ + return nullptr; +} + +void ProfileQt::SetCorsOriginAccessListForOrigin(const url::Origin &source_origin, + std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns, + std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, + base::OnceClosure closure) +{ + m_sharedCorsOriginAccessList->SetForOrigin(source_origin, + std::move(allow_patterns), + std::move(block_patterns), + std::move(closure)); +} + +const content::SharedCorsOriginAccessList *ProfileQt::GetSharedCorsOriginAccessList() const +{ + return m_sharedCorsOriginAccessList.get(); +} + #if QT_CONFIG(webengine_spellchecker) void ProfileQt::FailedToLoadDictionary(const std::string &language) { 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()); + LOG(WARNING) << "Could not load dictionary for:" << language; + LOG(INFO) << "Make sure that correct bdic file is in:" << WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES); } void ProfileQt::setSpellCheckLanguages(const QStringList &languages) @@ -268,4 +347,12 @@ bool ProfileQt::isSpellCheckEnabled() const return m_prefService->GetBoolean(spellcheck::prefs::kSpellCheckEnable); } #endif // QT_CONFIG(webengine_spellchecker) + +#if BUILDFLAG(ENABLE_EXTENSIONS) +extensions::ExtensionSystemQt* ProfileQt::GetExtensionSystem() +{ + return m_extensionSystem; +} +#endif // BUILDFLAG(ENABLE_EXTENSIONS) + } // namespace QtWebEngineCore |