From c6c3c2e0a787eb7245fb807ab37b82a0076d215c Mon Sep 17 00:00:00 2001 From: Christophe Chapuis Date: Wed, 30 Sep 2015 23:37:44 +0200 Subject: [PATCH 05/18] Make properties for some settings for PalmBridgeService management Signed-off-by: Christophe Chapuis --- src/core/web_engine_settings.cpp | 19 +++++++++++++ src/core/web_engine_settings.h | 8 +++++- src/webengine/api/qquickwebenginesettings.cpp | 39 +++++++++++++++++++++++++++ src/webengine/api/qquickwebenginesettings_p.h | 12 +++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 0079e02..7d7af2d 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -228,6 +228,19 @@ QString WebEngineSettings::defaultTextEncoding() const return m_defaultEncoding.isEmpty()? parentSettings->defaultTextEncoding() : m_defaultEncoding; } +void WebEngineSettings::setLuneOSIdentifier(const QString &identifier) +{ + m_luneOSIdentifier = identifier; + scheduleApplyRecursively(); +} + +QString WebEngineSettings::luneOSIdentifier() const +{ + if (!parentSettings) + return m_luneOSIdentifier; + return m_luneOSIdentifier.isEmpty()? parentSettings->luneOSIdentifier() : m_luneOSIdentifier; +} + void WebEngineSettings::initDefaults(bool offTheRecord) { if (s_defaultAttributes.isEmpty()) { @@ -267,6 +280,8 @@ void WebEngineSettings::initDefaults(bool offTheRecord) s_defaultAttributes.insert(PrintElementBackgrounds, true); s_defaultAttributes.insert(AllowRunningInsecureContent, allowRunningInsecureContent); s_defaultAttributes.insert(AllowGeolocationOnInsecureOrigins, false); + s_defaultAttributes.insert(PalmServiceBridgeEnabled, false); + s_defaultAttributes.insert(LuneOSPrivileged, false); } if (offTheRecord) m_attributes.insert(LocalStorageEnabled, false); @@ -299,6 +314,8 @@ void WebEngineSettings::initDefaults(bool offTheRecord) s_defaultFontSizes.insert(DefaultFontSize, 16); } + m_luneOSIdentifier = ""; + m_defaultEncoding = QStringLiteral("ISO-8859-1"); } @@ -352,6 +369,8 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->should_print_backgrounds = testAttribute(PrintElementBackgrounds); prefs->allow_running_insecure_content = testAttribute(AllowRunningInsecureContent); prefs->allow_geolocation_on_insecure_origins = testAttribute(AllowGeolocationOnInsecureOrigins); + prefs->luneosPriviledged = testAttribute(LuneOSPrivileged); + prefs->luneosAppIdentifier = luneOSIdentifier().toStdString(); // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index 4b0ce7b..3a3a8d1 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -83,7 +83,9 @@ public: FocusOnNavigationEnabled, PrintElementBackgrounds, AllowRunningInsecureContent, - AllowGeolocationOnInsecureOrigins + AllowGeolocationOnInsecureOrigins, + PalmServiceBridgeEnabled, + LuneOSPrivileged }; // Must match the values from the public API in qwebenginesettings.h. @@ -127,6 +129,9 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; + void setLuneOSIdentifier(const QString &identifier); + QString luneOSIdentifier() const; + void initDefaults(bool offTheRecord = false); void scheduleApply(); @@ -142,6 +147,7 @@ private: QHash m_fontFamilies; QHash m_fontSizes; QString m_defaultEncoding; + QString m_luneOSIdentifier; QScopedPointer webPreferences; QScopedPointer m_batchTimer; diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index ff25413..bcc5326 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -376,6 +376,21 @@ QString QQuickWebEngineSettings::defaultTextEncoding() const return d_ptr->defaultTextEncoding(); } +bool QQuickWebEngineSettings::palmServiceBridgeEnabled() const +{ + return d_ptr->testAttribute(WebEngineSettings::PalmServiceBridgeEnabled); +} + +bool QQuickWebEngineSettings::luneOSPrivileged() const +{ + return d_ptr->testAttribute(WebEngineSettings::LuneOSPrivileged); +} + +QString QQuickWebEngineSettings::luneOSIdentifier() const +{ + return d_ptr->luneOSIdentifier(); +} + void QQuickWebEngineSettings::setAutoLoadImages(bool on) { bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadImages); @@ -564,6 +579,30 @@ void QQuickWebEngineSettings::setAllowGeolocationOnInsecureOrigins(bool on) Q_EMIT allowGeolocationOnInsecureOriginsChanged(); } +void QQuickWebEngineSettings::setPalmServiceBridgeEnabled(bool on) +{ + bool wasOn = d_ptr->testAttribute(WebEngineSettings::PalmServiceBridgeEnabled); + d_ptr->setAttribute(WebEngineSettings::PalmServiceBridgeEnabled, on); + if (wasOn != on) + Q_EMIT palmServiceBridgeEnabledChanged(); +} + +void QQuickWebEngineSettings::setLuneOSPrivileged(bool on) +{ + bool wasOn = d_ptr->testAttribute(WebEngineSettings::LuneOSPrivileged); + d_ptr->setAttribute(WebEngineSettings::LuneOSPrivileged, on); + if (wasOn != on) + Q_EMIT luneOSPrivilegedChanged(); +} + +void QQuickWebEngineSettings::setLuneOSIdentifier(QString identifier) +{ + const QString oldLuneOSIdentifier = d_ptr->luneOSIdentifier(); + d_ptr->setLuneOSIdentifier(identifier); + if (oldLuneOSIdentifier.compare(identifier)) + Q_EMIT luneOSIdentifierChanged(); +} + void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings) { d_ptr->setParentSettings(parentSettings->d_ptr.data()); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index 10217c6..4893b34 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -86,6 +86,9 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds NOTIFY printElementBackgroundsChanged REVISION 3 FINAL) Q_PROPERTY(bool allowRunningInsecureContent READ allowRunningInsecureContent WRITE setAllowRunningInsecureContent NOTIFY allowRunningInsecureContentChanged REVISION 3 FINAL) Q_PROPERTY(bool allowGeolocationOnInsecureOrigins READ allowGeolocationOnInsecureOrigins WRITE setAllowGeolocationOnInsecureOrigins NOTIFY allowGeolocationOnInsecureOriginsChanged REVISION 4 FINAL) + Q_PROPERTY(bool palmServiceBridgeEnabled READ palmServiceBridgeEnabled WRITE setPalmServiceBridgeEnabled NOTIFY palmServiceBridgeEnabledChanged) + Q_PROPERTY(bool luneOSPrivileged READ luneOSPrivileged WRITE setLuneOSPrivileged NOTIFY luneOSPrivilegedChanged) + Q_PROPERTY(QString luneOSIdentifier READ luneOSIdentifier WRITE setLuneOSIdentifier NOTIFY luneOSIdentifierChanged) public: ~QQuickWebEngineSettings(); @@ -113,6 +116,9 @@ public: bool printElementBackgrounds() const; bool allowRunningInsecureContent() const; bool allowGeolocationOnInsecureOrigins() const; + bool palmServiceBridgeEnabled() const; + bool luneOSPrivileged() const; + QString luneOSIdentifier() const; void setAutoLoadImages(bool on); void setJavascriptEnabled(bool on); @@ -137,6 +143,9 @@ public: void setPrintElementBackgrounds(bool on); void setAllowRunningInsecureContent(bool on); void setAllowGeolocationOnInsecureOrigins(bool on); + void setPalmServiceBridgeEnabled(bool on); + void setLuneOSPrivileged(bool on); + void setLuneOSIdentifier(QString identifier); signals: void autoLoadImagesChanged(); @@ -162,6 +171,9 @@ signals: Q_REVISION(3) void printElementBackgroundsChanged(); Q_REVISION(3) void allowRunningInsecureContentChanged(); Q_REVISION(4) void allowGeolocationOnInsecureOriginsChanged(); + void palmServiceBridgeEnabledChanged(); + void luneOSPrivilegedChanged(); + void luneOSIdentifierChanged(); private: explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0); -- 2.7.4