diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2022-03-10 18:11:49 +0100 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2022-09-12 18:01:24 +0200 |
commit | 0ca4eba9612fbcba988ca06c47f5738d4cb71fbd (patch) | |
tree | 2a7b609c44f7c5c9a5fd993e154d3b16f32e031b /src/core/profile_qt.cpp | |
parent | 74163a6511278fa8273ca931ffdf9b9b3a8daae6 (diff) | |
download | qtwebengine-0ca4eba9612fbcba988ca06c47f5738d4cb71fbd.tar.gz |
Enable Push Messaging
Use Chrome's implementation of PushMessagingService. This feature
relies on notification permissions, so it is not different from
Web Notification from end-users perspective.
We don't persist push subscriptions, because it seems these have
to be consistent with persisting notification permissions.
Make address of push service configurable by a profile setting.
It is empty by default - which means the feature is disabled until
the user sets the address of a push service.
Task-number: QTBUG-98904
Task-number: QTBUG-53457
Change-Id: If44f459fecf2da482c28fee5562f62fe40de103e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/profile_qt.cpp')
-rw-r--r-- | src/core/profile_qt.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 9820ca787..1355140e3 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -35,6 +35,9 @@ #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/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" #include "chrome/common/pref_names.h" #if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spellcheck_service.h" @@ -50,6 +53,10 @@ #include "extensions/extension_system_qt.h" #endif +#if defined(Q_OS_WIN) +#include "components/os_crypt/os_crypt.h" +#endif + namespace QtWebEngineCore { ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) @@ -59,8 +66,16 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) , m_extensionSystem(nullptr) #endif // BUILDFLAG(ENABLE_EXTENSIONS) { + profile_metrics::SetBrowserProfileType(this, IsOffTheRecord() + ? profile_metrics::BrowserProfileType::kIncognito + : profile_metrics::BrowserProfileType::kRegular); + setupPrefService(); +#if defined(Q_OS_WIN) + OSCrypt::Init(m_prefServiceAdapter.prefService()); +#endif + // Mark the context as live. This prevents the use-after-free DCHECK in // AssertBrowserContextWasntDestroyed from being triggered when a new // ProfileQt object is allocated at the same address as a previously @@ -78,12 +93,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(); @@ -139,9 +162,17 @@ storage::SpecialStoragePolicy *ProfileQt::GetSpecialStoragePolicy() return nullptr; } +std::string ProfileQt::GetPushMessagingEndpoint() const +{ + return m_profileAdapter->pushServiceEndpoint().toString().toStdString(); +} + content::PushMessagingService *ProfileQt::GetPushMessagingService() { - return nullptr; + if (!m_profileAdapter->pushServiceEndpoint().isEmpty()) + return PushMessagingServiceFactory::GetForProfile(this); + else + return nullptr; } content::SSLHostStateDelegate* ProfileQt::GetSSLHostStateDelegate() |