diff options
Diffstat (limited to 'src/core/profile_qt.cpp')
-rw-r--r-- | src/core/profile_qt.cpp | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 9820ca787..293e8d557 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -5,47 +5,36 @@ #include "profile_adapter.h" #include "browsing_data_remover_delegate_qt.h" +#include "client_hints.h" #include "download_manager_delegate_qt.h" #include "file_system_access/file_system_access_permission_context_factory_qt.h" #include "net/ssl_host_state_delegate_qt.h" #include "permission_manager_qt.h" +#include "profile_io_data_qt.h" #include "platform_notification_service_qt.h" #include "qtwebenginecoreglobal_p.h" #include "type_conversion.h" #include "web_engine_library_info.h" #include "web_engine_context.h" -#include "base/barrier_closure.h" -#include "base/time/time.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/cors_origin_pattern_setter.h" -#include "content/public/browser/shared_cors_origin_access_list.h" -#include "content/public/browser/storage_partition.h" - #include "base/base_paths.h" #include "base/files/file_util.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" -#include "components/prefs/pref_member.h" -#include "components/prefs/pref_service.h" -#include "components/prefs/in_memory_pref_store.h" -#include "components/prefs/json_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" #include "components/profile_metrics/browser_profile_type.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 "components/spellcheck/browser/pref_names.h" -#endif +#include "content/public/browser/browser_thread.h" +#include "chrome/browser/push_messaging/push_messaging_app_identifier.h" +#include "chrome/browser/push_messaging/push_messaging_service_factory.h" +#include "chrome/browser/push_messaging/push_messaging_service_impl.h" #if BUILDFLAG(ENABLE_EXTENSIONS) +#include "base/command_line.h" #include "components/guest_view/browser/guest_view_manager.h" -#include "extensions/browser/pref_names.h" -#include "extensions/browser/process_manager.h" -#include "extensions/common/constants.h" +#include "extensions/browser/extension_pref_value_map_factory.h" +#include "extensions/browser/extension_prefs.h" +#include "extensions/browser/extension_prefs_factory.h" +#include "extensions/browser/extensions_browser_client.h" #include "extensions/extension_system_qt.h" #endif @@ -55,10 +44,15 @@ namespace QtWebEngineCore { ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) : m_profileIOData(new ProfileIODataQt(this)) , m_profileAdapter(profileAdapter) + , m_userAgentMetadata(embedder_support::GetUserAgentMetadata()) #if BUILDFLAG(ENABLE_EXTENSIONS) , m_extensionSystem(nullptr) #endif // BUILDFLAG(ENABLE_EXTENSIONS) { + profile_metrics::SetBrowserProfileType(this, IsOffTheRecord() + ? profile_metrics::BrowserProfileType::kIncognito + : profile_metrics::BrowserProfileType::kRegular); + setupPrefService(); // Mark the context as live. This prevents the use-after-free DCHECK in @@ -78,12 +72,20 @@ ProfileQt::~ProfileQt() DCHECK_CURRENTLY_ON(content::BrowserThread::UI); m_prefServiceAdapter.commit(); BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(this); + // Remembering push subscriptions and not persisting notification permissions would + // confuse most of web applications. + PushMessagingAppIdentifier::DeleteAllFromPrefs(this); ShutdownStoragePartitions(); m_profileIOData->shutdownOnUIThread(); //Should be deleted by IO Thread m_profileIOData.release(); } +void ProfileQt::DoFinalInit() +{ + PushMessagingServiceImpl::InitializeForProfile(this); +} + PrefService* ProfileQt::GetPrefs() { return m_prefServiceAdapter.prefService(); @@ -141,7 +143,10 @@ storage::SpecialStoragePolicy *ProfileQt::GetSpecialStoragePolicy() content::PushMessagingService *ProfileQt::GetPushMessagingService() { - return nullptr; + if (m_profileAdapter->pushServiceEnabled()) + return PushMessagingServiceFactory::GetForProfile(this); + else + return nullptr; } content::SSLHostStateDelegate* ProfileQt::GetSSLHostStateDelegate() @@ -182,7 +187,7 @@ content::PermissionControllerDelegate *ProfileQt::GetPermissionControllerDelegat content::ClientHintsControllerDelegate *ProfileQt::GetClientHintsControllerDelegate() { - return nullptr; + return ClientHintsFactory::GetForBrowserContext(this); } content::StorageNotificationService *ProfileQt::GetStorageNotificationService() @@ -190,6 +195,11 @@ content::StorageNotificationService *ProfileQt::GetStorageNotificationService() return nullptr; } +content::ReduceAcceptLanguageControllerDelegate *ProfileQt::GetReduceAcceptLanguageControllerDelegate() +{ + return nullptr; +} + #if QT_CONFIG(webengine_spellchecker) void ProfileQt::FailedToLoadDictionary(const std::string &language) { @@ -218,6 +228,7 @@ content::FileSystemAccessPermissionContext *ProfileQt::GetFileSystemAccessPermis void ProfileQt::setupPrefService() { + const bool recreation = m_prefServiceAdapter.prefService() != nullptr; profile_metrics::SetBrowserProfileType(this, IsOffTheRecord() ? profile_metrics::BrowserProfileType::kIncognito @@ -225,12 +236,28 @@ void ProfileQt::setupPrefService() // Remove previous handler before we set a new one or we will assert // TODO: Remove in Qt6 - if (m_prefServiceAdapter.prefService() != nullptr) { + if (recreation) { user_prefs::UserPrefs::Remove(this); m_prefServiceAdapter.commit(); } m_prefServiceAdapter.setup(*m_profileAdapter); user_prefs::UserPrefs::Set(this, m_prefServiceAdapter.prefService()); + +#if BUILDFLAG(ENABLE_EXTENSIONS) + if (recreation) { + // Recreate ExtensionPrefs to update its pointer to the new PrefService + extensions::ExtensionsBrowserClient *client = extensions::ExtensionsBrowserClient::Get(); + std::vector<extensions::EarlyExtensionPrefsObserver *> prefsObservers; + client->GetEarlyExtensionPrefsObservers(this, &prefsObservers); + auto extensionPrefs = extensions::ExtensionPrefs::Create( + this, client->GetPrefServiceForContext(this), + this->GetPath().AppendASCII(extensions::kInstallDirectoryName), + ExtensionPrefValueMapFactory::GetForBrowserContext(this), + client->AreExtensionsDisabled(*base::CommandLine::ForCurrentProcess(), this), + prefsObservers); + extensions::ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting(this, std::move(extensionPrefs)); + } +#endif } PrefServiceAdapter &ProfileQt::prefServiceAdapter() @@ -243,6 +270,11 @@ const PrefServiceAdapter &ProfileQt::prefServiceAdapter() const return m_prefServiceAdapter; } +const blink::UserAgentMetadata &ProfileQt::userAgentMetadata() +{ + return m_userAgentMetadata; +} + content::PlatformNotificationService *ProfileQt::GetPlatformNotificationService() { if (!m_platformNotificationService) |