summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/content_browser_client_qt.cpp7
-rw-r--r--src/core/content_browser_client_qt.h1
-rw-r--r--src/core/core_gyp_generator.pro2
-rw-r--r--src/core/web_contents_adapter.cpp9
-rw-r--r--src/core/web_contents_adapter.h2
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp7
-rw-r--r--src/core/web_contents_delegate_qt.h3
-rw-r--r--src/core/web_engine_settings.cpp292
-rw-r--r--src/core/web_engine_settings.h141
-rw-r--r--src/webengine/api/qquickwebengineview.cpp26
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp25
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
14 files changed, 519 insertions, 0 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index e8fc3adda..47b51e706 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -327,6 +327,13 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver()
return MediaCaptureDevicesDispatcher::GetInstance();
}
+void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, const GURL &url, WebPreferences *web_prefs)
+{
+ Q_UNUSED(url);
+ if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents())
+ static_cast<WebContentsDelegateQt*>(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs);
+}
+
BrowserContextQt* ContentBrowserClientQt::browser_context() {
Q_ASSERT(m_browserMainParts);
return static_cast<BrowserMainPartsQt*>(m_browserMainParts)->browser_context();
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 64e14343b..f550dcdc8 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -84,6 +84,7 @@ public:
virtual void ResourceDispatcherHostCreated() Q_DECL_OVERRIDE;
virtual gfx::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
virtual content::MediaObserver* GetMediaObserver();
+ virtual void OverrideWebkitPrefs(content::RenderViewHost *, const GURL &, WebPreferences *) Q_DECL_OVERRIDE;
BrowserContextQt* browser_context();
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index 8d8298e99..2c3767ad4 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -76,6 +76,7 @@ SOURCES = \
web_engine_context.cpp \
web_engine_error.cpp \
web_engine_library_info.cpp \
+ web_engine_settings.cpp \
web_engine_visited_links_manager.cpp \
web_event_factory.cpp \
yuv_video_node.cpp
@@ -123,6 +124,7 @@ HEADERS = \
web_engine_context.h \
web_engine_error.h \
web_engine_library_info.h \
+ web_engine_settings.h \
web_engine_visited_links_manager.h \
web_event_factory.h \
yuv_video_node.h
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 3dcef4ba4..258feb92b 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -55,6 +55,8 @@
#include "web_contents_delegate_qt.h"
#include "web_contents_view_qt.h"
#include "web_engine_context.h"
+#include "web_engine_settings.h"
+#include "web_engine_visited_links_manager.h"
#include "base/values.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
@@ -69,6 +71,7 @@
#include "content/public/common/url_constants.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
+#include "webkit/common/webpreferences.h"
#include <QDir>
#include <QGuiApplication>
@@ -686,6 +689,12 @@ void WebContentsAdapter::stopFinding()
d->webContents->GetRenderViewHost()->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
}
+void WebContentsAdapter::updateWebPreferences(const WebPreferences & webPreferences)
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences);
+}
+
void WebContentsAdapter::wasShown()
{
Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index a20d55959..155c54024 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -53,6 +53,7 @@ namespace content {
class WebContents;
}
class WebContentsAdapterPrivate;
+struct WebPreferences;
QT_FORWARD_DECLARE_CLASS(QAccessibleInterface);
@@ -106,6 +107,7 @@ public:
quint64 fetchDocumentInnerText();
quint64 findText(const QString &subString, bool caseSensitively, bool findBackward);
void stopFinding();
+ void updateWebPreferences(const WebPreferences &webPreferences);
void wasShown();
void wasHidden();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 2dffb8fb5..e0ff25124 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -58,6 +58,7 @@ class RenderWidgetHostViewQtDelegate;
class RenderWidgetHostViewQtDelegateClient;
class WebContentsAdapter;
class WebContentsDelegateQt;
+class WebEngineSettings;
// FIXME: make this ref-counted and implicitely shared and expose as public API maybe ?
class WebEngineContextMenuData {
@@ -175,6 +176,7 @@ public:
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0;
virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0;
+ virtual WebEngineSettings *webEngineSettings() const = 0;
};
#endif // WEB_CONTENTS_ADAPTER_CLIENT_H
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 1de3ce160..d706923c8 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -50,6 +50,7 @@
#include "web_contents_adapter.h"
#include "web_contents_adapter_client.h"
#include "web_engine_context.h"
+#include "web_engine_settings.h"
#include "web_engine_visited_links_manager.h"
#include "content/public/browser/favicon_status.h"
@@ -60,6 +61,7 @@
#include "content/public/common/favicon_url.h"
#include "content/public/common/file_chooser_params.h"
#include "content/public/common/frame_navigate_params.h"
+#include "webkit/common/webpreferences.h"
// Maps the LogSeverity defines in base/logging.h to the web engines message levels.
@@ -259,3 +261,8 @@ void WebContentsDelegateQt::DidNavigateAnyFrame(const content::LoadCommittedDeta
return;
WebEngineContext::current()->visitedLinksManager()->addUrl(params.url);
}
+
+void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *, WebPreferences *webPreferences)
+{
+ m_viewClient->webEngineSettings()->overrideWebPreferences(webPreferences);
+}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 44be77190..ebdee4cde 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -55,6 +55,7 @@ namespace content {
class JavaScriptDialogManager;
class WebContents;
}
+struct WebPreferences;
class WebContentsAdapterClient;
class WebContentsDelegateQt : public content::WebContentsDelegate
@@ -86,6 +87,8 @@ public:
virtual void UpdateTargetURL(content::WebContents *source, int32 page_id, const GURL &url) Q_DECL_OVERRIDE;
virtual void DidNavigateAnyFrame(const content::LoadCommittedDetails&, const content::FrameNavigateParams& params) Q_DECL_OVERRIDE;
+ void overrideWebPreferences(content::WebContents *, WebPreferences*);
+
private:
WebContentsAdapterClient *m_viewClient;
QString m_lastSearchedString;
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
new file mode 100644
index 000000000..bdbd25155
--- /dev/null
+++ b/src/core/web_engine_settings.cpp
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "web_engine_settings.h"
+#include "web_contents_adapter.h"
+#include "type_conversion.h"
+
+#include "webkit/common/webpreferences.h"
+
+#include <QFont>
+#include <QTimer>
+
+static const int batchTimerTimeout = 100;
+
+class BatchTimer : public QTimer {
+ Q_OBJECT
+public:
+ BatchTimer(WebEngineSettings *settings)
+ : m_settings(settings)
+ {
+ setSingleShot(true);
+ setInterval(batchTimerTimeout);
+ connect(this, SIGNAL(timeout()), SLOT(onTimeout()));
+ }
+
+private Q_SLOTS:
+ void onTimeout()
+ {
+ m_settings->doApply();
+ }
+
+private:
+ WebEngineSettings *m_settings;
+};
+
+#include "web_engine_settings.moc"
+
+
+WebEngineSettings::WebEngineSettings(WebEngineSettingsDelegate *delegate)
+ : m_adapter(0)
+ , m_delegate(delegate)
+ , m_batchTimer(new BatchTimer(this))
+{
+ Q_ASSERT(delegate);
+}
+
+WebEngineSettings::WebEngineSettings(WebEngineSettingsDelegate *delegate, WebContentsAdapter *adapter)
+ : m_adapter(adapter)
+ , m_delegate(delegate)
+ , m_batchTimer(new BatchTimer(this))
+{
+ Q_ASSERT(delegate);
+}
+
+WebEngineSettings::~WebEngineSettings()
+{
+}
+
+void WebEngineSettings::overrideWebPreferences(WebPreferences *prefs)
+{
+ // Apply our settings on top of those.
+ applySettingsToWebPreferences(prefs);
+ // Store the current webPreferences in use if this is the first time we get here
+ // as the host process already overides some of the default WebPreferences values
+ // before we get here (e.g. number_of_cpu_cores).
+ if (webPreferences.isNull())
+ webPreferences.reset(new WebPreferences(*prefs));
+}
+
+void WebEngineSettings::setAttribute(WebEngineSettings::Attribute attr, bool on)
+{
+ m_attributes.insert(attr, on);
+ m_delegate->apply();
+}
+
+bool WebEngineSettings::testAttribute(WebEngineSettings::Attribute attr) const
+{
+ WebEngineSettings *fallback = m_delegate->fallbackSettings();
+ Q_ASSERT(fallback);
+ if (this == fallback) {
+ Q_ASSERT(m_attributes.contains(attr));
+ return m_attributes.value(attr);
+ }
+ return m_attributes.value(attr, fallback->testAttribute(attr));
+}
+
+void WebEngineSettings::resetAttribute(WebEngineSettings::Attribute attr)
+{
+ if (this == m_delegate->fallbackSettings())
+ return;
+ m_attributes.remove(attr);
+ m_delegate->apply();
+}
+
+void WebEngineSettings::setFontFamily(WebEngineSettings::FontFamily which, const QString &family)
+{
+ m_fontFamilies.insert(which, family);
+ m_delegate->apply();
+}
+
+QString WebEngineSettings::fontFamily(WebEngineSettings::FontFamily which)
+{
+ WebEngineSettings *fallback = m_delegate->fallbackSettings();
+ Q_ASSERT(fallback);
+ if (this == fallback) {
+ Q_ASSERT(m_fontFamilies.contains(which));
+ return m_fontFamilies.value(which);
+ }
+ return m_fontFamilies.value(which, fallback->fontFamily(which));
+}
+
+void WebEngineSettings::resetFontFamily(WebEngineSettings::FontFamily which)
+{
+ if (this == m_delegate->fallbackSettings())
+ return;
+ m_fontFamilies.remove(which);
+ m_delegate->apply();
+}
+
+void WebEngineSettings::setFontSize(WebEngineSettings::FontSize type, int size)
+{
+ m_fontSizes.insert(type, size);
+ m_delegate->apply();
+}
+
+int WebEngineSettings::fontSize(WebEngineSettings::FontSize type) const
+{
+ WebEngineSettings *fallback = m_delegate->fallbackSettings();
+ Q_ASSERT(fallback);
+ if (this == fallback) {
+ Q_ASSERT(m_fontSizes.contains(type));
+ return m_fontSizes.value(type);
+ }
+ return m_fontSizes.value(type, fallback->fontSize(type));
+}
+
+void WebEngineSettings::resetFontSize(WebEngineSettings::FontSize type)
+{
+ if (this == m_delegate->fallbackSettings())
+ return;
+ m_fontSizes.remove(type);
+ m_delegate->apply();
+}
+
+void WebEngineSettings::setDefaultTextEncoding(const QString &encoding)
+{
+ m_defaultEncoding = encoding;
+ m_delegate->apply();
+}
+
+QString WebEngineSettings::defaultTextEncoding() const
+{
+ WebEngineSettings *fallback = m_delegate->fallbackSettings();
+ Q_ASSERT(fallback);
+ if (this == fallback)
+ return m_defaultEncoding;
+ return m_defaultEncoding.isEmpty()? fallback->defaultTextEncoding() : m_defaultEncoding;
+}
+
+void WebEngineSettings::initDefaults()
+{
+ // Initialize the default settings.
+
+ m_attributes.insert(AutoLoadImages, true);
+ m_attributes.insert(JavascriptEnabled, true);
+ m_attributes.insert(JavascriptCanOpenWindows, false);
+ m_attributes.insert(JavascriptCanAccessClipboard, false);
+ m_attributes.insert(LinksIncludedInFocusChain, true);
+ m_attributes.insert(LocalStorageEnabled, false);
+ m_attributes.insert(LocalContentCanAccessRemoteUrls, false);
+ m_attributes.insert(XSSAuditingEnabled, false);
+ m_attributes.insert(SpatialNavigationEnabled, false);
+ m_attributes.insert(LocalContentCanAccessFileUrls, true);
+ m_attributes.insert(HyperlinkAuditingEnabled, false);
+ m_attributes.insert(ScrollAnimatorEnabled, false);
+
+ // Default fonts
+ QFont defaultFont;
+ defaultFont.setStyleHint(QFont::Serif);
+ m_fontFamilies.insert(StandardFont, defaultFont.defaultFamily());
+ m_fontFamilies.insert(SerifFont, defaultFont.defaultFamily());
+
+ defaultFont.setStyleHint(QFont::Fantasy);
+ m_fontFamilies.insert(FantasyFont, defaultFont.defaultFamily());
+
+ defaultFont.setStyleHint(QFont::Cursive);
+ m_fontFamilies.insert(CursiveFont, defaultFont.defaultFamily());
+
+ defaultFont.setStyleHint(QFont::SansSerif);
+ m_fontFamilies.insert(SansSerifFont, defaultFont.defaultFamily());
+
+ defaultFont.setStyleHint(QFont::Monospace);
+ m_fontFamilies.insert(FixedFont, defaultFont.defaultFamily());
+
+ m_fontSizes.insert(MinimumFontSize, 0);
+ m_fontSizes.insert(MinimumLogicalFontSize, 6);
+ m_fontSizes.insert(DefaultFixedFontSize, 13);
+ m_fontSizes.insert(DefaultFontSize, 16);
+
+ m_defaultEncoding = QStringLiteral("ISO-8859-1");
+}
+
+void WebEngineSettings::scheduleApply()
+{
+ if (!m_batchTimer->isActive())
+ m_batchTimer->start();
+}
+
+void WebEngineSettings::doApply()
+{
+ if (webPreferences.isNull())
+ return;
+ // Override with our settings when applicable
+ // FIXME: batch sequential calls to apply?
+ applySettingsToWebPreferences(webPreferences.data());
+
+ if (m_adapter)
+ m_adapter->updateWebPreferences(*webPreferences.data());
+}
+
+void WebEngineSettings::applySettingsToWebPreferences(WebPreferences *prefs)
+{
+ Q_ASSERT(prefs->accelerated_compositing_enabled);
+ // Override for now
+ prefs->java_enabled = false;
+
+ // Attributes mapping.
+ prefs->loads_images_automatically = testAttribute(AutoLoadImages);
+ prefs->javascript_enabled = testAttribute(JavascriptEnabled);
+ prefs->javascript_can_open_windows_automatically = testAttribute(JavascriptCanOpenWindows);
+ prefs->javascript_can_access_clipboard = testAttribute(JavascriptCanAccessClipboard);
+ prefs->tabs_to_links = testAttribute(LinksIncludedInFocusChain);
+ prefs->local_storage_enabled = testAttribute(LocalStorageEnabled);
+ prefs->allow_universal_access_from_file_urls = testAttribute(LocalContentCanAccessRemoteUrls);
+ prefs->xss_auditor_enabled = testAttribute(XSSAuditingEnabled);
+ prefs->spatial_navigation_enabled = testAttribute(SpatialNavigationEnabled);
+ prefs->allow_file_access_from_file_urls = testAttribute(LocalContentCanAccessFileUrls);
+ prefs->hyperlink_auditing_enabled = testAttribute(HyperlinkAuditingEnabled);
+ prefs->enable_scroll_animator = testAttribute(ScrollAnimatorEnabled);
+
+ // Fonts settings.
+ prefs->standard_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(StandardFont));
+ prefs->fixed_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(FixedFont));
+ prefs->serif_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(SerifFont));
+ prefs->sans_serif_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(SansSerifFont));
+ prefs->cursive_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(CursiveFont));
+ prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily(FantasyFont));
+ // FIXME: add pictograph?
+ // prefs.pictograph_font_family_map[webkit_glue::kCommonScript] = toString16(fontFamily());
+ prefs->default_font_size = fontSize(DefaultFontSize);
+ prefs->default_fixed_font_size = fontSize(DefaultFixedFontSize);
+ prefs->minimum_font_size = fontSize(MinimumFontSize);
+ prefs->minimum_logical_font_size = fontSize(MinimumLogicalFontSize);
+}
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
new file mode 100644
index 000000000..5e19c242d
--- /dev/null
+++ b/src/core/web_engine_settings.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WEB_ENGINE_SETTINGS_H
+#define WEB_ENGINE_SETTINGS_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QExplicitlySharedDataPointer>
+#include <QScopedPointer>
+#include <QHash>
+#include <QUrl>
+
+class BatchTimer;
+class WebContentsAdapter;
+class WebEngineSettings;
+struct WebPreferences;
+
+class QWEBENGINE_EXPORT WebEngineSettingsDelegate {
+public:
+ virtual ~WebEngineSettingsDelegate() {}
+ virtual void apply() = 0;
+ // Needs to be a valid pointer, the last available fallback (ex: global settings) should return itself.
+ virtual WebEngineSettings *fallbackSettings() const = 0;
+};
+
+class QWEBENGINE_EXPORT WebEngineSettings {
+public:
+ // Attributes. Names match the ones from the public widgets API.
+ enum Attribute {
+ UnsupportedInCoreSettings = -1,
+ AutoLoadImages,
+ JavascriptEnabled,
+ JavascriptCanOpenWindows,
+ JavascriptCanAccessClipboard,
+ LinksIncludedInFocusChain,
+ LocalStorageEnabled,
+ LocalContentCanAccessRemoteUrls,
+ XSSAuditingEnabled,
+ SpatialNavigationEnabled,
+ LocalContentCanAccessFileUrls,
+ HyperlinkAuditingEnabled,
+ ScrollAnimatorEnabled,
+ };
+
+ // Must match the values from the public API in qwebenginesettings.h.
+ enum FontFamily {
+ StandardFont,
+ FixedFont,
+ SerifFont,
+ SansSerifFont,
+ CursiveFont,
+ FantasyFont
+ };
+
+ // Must match the values from the public API in qwebenginesettings.h.
+ enum FontSize {
+ MinimumFontSize,
+ MinimumLogicalFontSize,
+ DefaultFontSize,
+ DefaultFixedFontSize
+ };
+
+ WebEngineSettings(WebEngineSettingsDelegate*);
+ WebEngineSettings(WebEngineSettingsDelegate *,WebContentsAdapter *);
+ virtual ~WebEngineSettings();
+
+ void overrideWebPreferences(WebPreferences *prefs);
+
+ void setAttribute(Attribute, bool on);
+ bool testAttribute(Attribute) const;
+ void resetAttribute(Attribute);
+
+ void setFontFamily(FontFamily, const QString &);
+ QString fontFamily(FontFamily);
+ void resetFontFamily(FontFamily);
+
+ void setFontSize(FontSize type, int size);
+ int fontSize(FontSize type) const;
+ void resetFontSize(FontSize type);
+
+ void setDefaultTextEncoding(const QString &encoding);
+ QString defaultTextEncoding() const;
+
+ void initDefaults();
+ void scheduleApply();
+
+private:
+ void doApply();
+ void applySettingsToWebPreferences(WebPreferences *);
+
+ WebContentsAdapter* m_adapter;
+ WebEngineSettingsDelegate* m_delegate;
+ QHash<Attribute, bool> m_attributes;
+ QHash<FontFamily, QString> m_fontFamilies;
+ QHash<FontSize, int> m_fontSizes;
+ QString m_defaultEncoding;
+ QScopedPointer<WebPreferences> webPreferences;
+ QScopedPointer<BatchTimer> m_batchTimer;
+
+ friend class BatchTimer;
+};
+
+#endif // WEB_ENGINE_SETTINGS_H
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 352c3dcf2..e9c5232ab 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -52,6 +52,8 @@
#include "ui_delegates_manager.h"
#include "web_contents_adapter.h"
#include "web_engine_error.h"
+#include "web_engine_settings.h"
+#include "web_engine_visited_links_manager.h"
#include <QGuiApplication>
#include <QQmlComponent>
@@ -396,6 +398,30 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
return q;
}
+namespace {
+class DummySettingsDelegate : public WebEngineSettingsDelegate {
+public:
+ DummySettingsDelegate()
+ : settings(0) {}
+ void apply() { }
+ WebEngineSettings* fallbackSettings() const { return settings; }
+ WebEngineSettings *settings;
+};
+
+}// anonymous namespace
+
+WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
+{
+ static WebEngineSettings *dummySettings = 0;
+ if (!dummySettings) {
+ DummySettingsDelegate *dummyDelegate = new DummySettingsDelegate;
+ dummySettings = new WebEngineSettings(dummyDelegate);
+ dummyDelegate->settings = dummySettings;
+ dummySettings->initDefaults();
+ }
+ return dummySettings;
+}
+
void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
{
Q_Q(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 831e91a0b..332d9e280 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -179,6 +179,7 @@ public:
virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
+ virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
void setDevicePixelRatio(qreal);
void adoptWebContents(WebContentsAdapter *webContents);
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 10e3dcda5..851ca8aea 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -30,6 +30,7 @@
#include "qwebengineview_p.h"
#include "render_widget_host_view_qt_delegate_widget.h"
#include "web_contents_adapter.h"
+#include "web_engine_settings.h"
#include <QAction>
#include <QApplication>
@@ -342,6 +343,30 @@ QObject *QWebEnginePagePrivate::accessibilityParentObject()
return view;
}
+namespace {
+class DummySettingsDelegate : public WebEngineSettingsDelegate {
+public:
+ DummySettingsDelegate()
+ : settings(0) {}
+ void apply() { }
+ WebEngineSettings* fallbackSettings() const { return settings; }
+ WebEngineSettings *settings;
+};
+
+}// anonymous namespace
+
+WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
+{
+ static WebEngineSettings *dummySettings = 0;
+ if (!dummySettings) {
+ DummySettingsDelegate *dummyDelegate = new DummySettingsDelegate;
+ dummySettings = new WebEngineSettings(dummyDelegate);
+ dummyDelegate->settings = dummySettings;
+ dummySettings->initDefaults();
+ }
+ return dummySettings;
+}
+
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 1a5e1ae3c..f90c49216 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -141,6 +141,7 @@ public:
virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
+ virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
void updateAction(QWebEnginePage::WebAction) const;
void updateNavigationActions();