11 #ifndef hifi_ContextAwareProfile_h
12 #define hifi_ContextAwareProfile_h
15 #include <QtCore/QHash>
16 #include <QtCore/QReadWriteLock>
17 #include <QtCore/QSet>
19 #if !defined(Q_OS_ANDROID)
20 #include <QtWebEngine/QQuickWebEngineProfile>
21 #include <QtWebEngineCore/QWebEngineUrlRequestInterceptor>
23 using ContextAwareProfileParent = QQuickWebEngineProfile;
24 using RequestInterceptorParent = QWebEngineUrlRequestInterceptor;
26 #include <QtCore/QObject>
28 using ContextAwareProfileParent = QObject;
29 using RequestInterceptorParent = QObject;
34 class ContextAwareProfile :
public ContextAwareProfileParent {
37 static void restrictContext(QQmlContext* context,
bool restrict =
true);
39 Q_INVOKABLE
bool isRestrictedGetProperty();
42 class RequestInterceptor :
public RequestInterceptorParent {
44 RequestInterceptor(ContextAwareProfile* parent) : RequestInterceptorParent(parent), _profile(parent) { }
45 bool isRestricted() {
return _profile->isRestricted(); }
47 ContextAwareProfile* _profile;
50 ContextAwareProfile(QQmlContext* parent);
51 ~ContextAwareProfile();
54 typedef QSet<ContextAwareProfile*> ContextAwareProfileSet;
55 typedef QHash<QQmlContext*, ContextAwareProfileSet> ContextMap;
57 QQmlContext* _context{
nullptr };
58 std::atomic<bool> _isRestricted{
false };
60 static QReadWriteLock _contextMapProtect;
61 static ContextMap _contextMap;