summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/webengine/quicknanobrowser/quickwindow.qml12
-rw-r--r--examples/webengine/quicknanobrowser/util.h2
-rw-r--r--examples/webenginewidgets/browser/webview.cpp34
-rw-r--r--examples/webenginewidgets/browser/webview.h4
-rw-r--r--qtwebengine.pro6
-rw-r--r--src/core/browser_context_adapter.cpp101
-rw-r--r--src/core/browser_context_adapter.h76
-rw-r--r--src/core/browser_context_qt.cpp29
-rw-r--r--src/core/browser_context_qt.h5
-rw-r--r--src/core/content_browser_client_qt.cpp23
-rw-r--r--src/core/content_browser_client_qt.h4
-rw-r--r--src/core/core_gyp_generator.pro2
-rw-r--r--src/core/delegated_frame_node.cpp25
-rw-r--r--src/core/web_contents_adapter.cpp22
-rw-r--r--src/core/web_contents_adapter.h3
-rw-r--r--src/core/web_contents_adapter_client.h3
-rw-r--r--src/core/web_contents_delegate_qt.cpp3
-rw-r--r--src/core/web_engine_context.cpp18
-rw-r--r--src/core/web_engine_context.h8
-rw-r--r--src/core/web_engine_visited_links_manager.cpp9
-rw-r--r--src/core/web_engine_visited_links_manager.h3
-rw-r--r--src/webengine/api/qquickwebengineview.cpp29
-rw-r--r--src/webengine/api/qquickwebengineview_p.h7
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h2
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp21
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h11
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h4
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc24
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp1
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp166
-rw-r--r--tests/quicktestbrowser/ZoomController.qml102
-rw-r--r--tests/quicktestbrowser/quickwindow.qml26
-rw-r--r--tests/quicktestbrowser/resources.qrc1
-rw-r--r--tests/quicktestbrowser/util.h2
34 files changed, 557 insertions, 231 deletions
diff --git a/examples/webengine/quicknanobrowser/quickwindow.qml b/examples/webengine/quicknanobrowser/quickwindow.qml
index 610144dca..b954629fb 100644
--- a/examples/webengine/quicknanobrowser/quickwindow.qml
+++ b/examples/webengine/quicknanobrowser/quickwindow.qml
@@ -93,6 +93,18 @@ ApplicationWindow {
tabs.removeTab(tabs.currentIndex)
}
}
+ Action {
+ shortcut: "Ctrl+0"
+ onTriggered: currentWebView.zoomFactor = 1.0;
+ }
+ Action {
+ shortcut: "Ctrl+-"
+ onTriggered: currentWebView.zoomFactor -= 0.1;
+ }
+ Action {
+ shortcut: "Ctrl+="
+ onTriggered: currentWebView.zoomFactor += 0.1;
+ }
toolBar: ToolBar {
id: navigationBar
diff --git a/examples/webengine/quicknanobrowser/util.h b/examples/webengine/quicknanobrowser/util.h
index bc1cf8beb..ca0f5f1d5 100644
--- a/examples/webengine/quicknanobrowser/util.h
+++ b/examples/webengine/quicknanobrowser/util.h
@@ -50,7 +50,7 @@ QUrl urlFromUserInput(const QString& userInput)
{
QFileInfo fileInfo(userInput);
if (fileInfo.exists())
- return QUrl(fileInfo.absoluteFilePath());
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
return QUrl::fromUserInput(userInput);
}
diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp
index 5ea273e3a..9b42f2ab2 100644
--- a/examples/webenginewidgets/browser/webview.cpp
+++ b/examples/webenginewidgets/browser/webview.cpp
@@ -97,37 +97,15 @@ BrowserMainWindow *WebPage::mainWindow()
return BrowserApplication::instance()->mainWindow();
}
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
-bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type)
+bool WebPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
- // ctrl open in new tab
- // ctrl-shift open in new tab and select
- // ctrl-alt open in new window
- if (type == QWebEnginePage::NavigationTypeLinkClicked
- && (m_keyboardModifiers & Qt::ControlModifier
- || m_pressedButtons == Qt::MidButton)) {
- bool newWindow = (m_keyboardModifiers & Qt::AltModifier);
- WebView *webView;
- if (newWindow) {
- BrowserApplication::instance()->newMainWindow();
- BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow();
- webView = newMainWindow->currentTab();
- newMainWindow->raise();
- newMainWindow->activateWindow();
- webView->setFocus();
- } else {
- bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier);
- webView = mainWindow()->tabWidget()->newTab(selectNewTab);
- }
- webView->load(request);
- m_keyboardModifiers = Qt::NoModifier;
- m_pressedButtons = Qt::NoButton;
- return false;
+ Q_UNUSED(type);
+ if (isMainFrame) {
+ m_loadingUrl = url;
+ emit loadingUrl(m_loadingUrl);
}
- m_loadingUrl = request.url();
- emit loadingUrl(m_loadingUrl);
+ return true;
}
-#endif
bool WebPage::certificateError(const QWebEngineCertificateError &error)
{
diff --git a/examples/webenginewidgets/browser/webview.h b/examples/webenginewidgets/browser/webview.h
index 2cedeb79b..5ed674f6a 100644
--- a/examples/webenginewidgets/browser/webview.h
+++ b/examples/webenginewidgets/browser/webview.h
@@ -65,9 +65,7 @@ public:
BrowserMainWindow *mainWindow();
protected:
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
- bool acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type);
-#endif
+ bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type);
#if !defined(QT_NO_UITOOLS)
QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
diff --git a/qtwebengine.pro b/qtwebengine.pro
index 366446c7a..5156e4620 100644
--- a/qtwebengine.pro
+++ b/qtwebengine.pro
@@ -1,8 +1,2 @@
load(qt_build_config)
-
-# As long as we are a module separate from the rest of Qt, we want to unconditionally build examples.
-# Once part of Qt 5, this should be removed and we should respect the Qt wide configuration.
-QTWEBENGINE_BUILD_PARTS = $$QT_BUILD_PARTS
-QTWEBENGINE_BUILD_PARTS *= examples
-
load(qt_parts)
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
new file mode 100644
index 000000000..b06515c2f
--- /dev/null
+++ b/src/core/browser_context_adapter.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "browser_context_adapter.h"
+
+#include "browser_context_qt.h"
+#include "web_engine_context.h"
+#include "web_engine_visited_links_manager.h"
+
+#include <QCoreApplication>
+#include <QDir>
+#include <QString>
+#include <QStringBuilder>
+#include <QStandardPaths>
+
+
+BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord)
+ : m_offTheRecord(offTheRecord)
+ , m_browserContext(new BrowserContextQt(this))
+ , m_visitedLinksManager(new WebEngineVisitedLinksManager(this))
+{
+}
+
+BrowserContextAdapter::~BrowserContextAdapter()
+{
+}
+
+BrowserContextQt *BrowserContextAdapter::browserContext()
+{
+ return m_browserContext.data();
+}
+
+WebEngineVisitedLinksManager *BrowserContextAdapter::visitedLinksManager()
+{
+ return m_visitedLinksManager.data();
+}
+
+BrowserContextAdapter* BrowserContextAdapter::defaultContext()
+{
+ return WebEngineContext::current()->defaultBrowserContext();
+}
+
+BrowserContextAdapter* BrowserContextAdapter::offTheRecordContext()
+{
+ return WebEngineContext::current()->offTheRecordBrowserContext();
+}
+
+QString BrowserContextAdapter::dataPath() const
+{
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ if (dataLocation.isEmpty())
+ dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
+
+ dataLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
+ dataLocation.append(QDir::separator() % QLatin1String("Default"));
+ return dataLocation;
+}
+
+QString BrowserContextAdapter::cachePath() const
+{
+ QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ if (cacheLocation.isEmpty())
+ cacheLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
+
+ cacheLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
+ cacheLocation.append(QDir::separator() % QLatin1String("Default"));
+ return cacheLocation;
+}
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
new file mode 100644
index 000000000..362ab79ee
--- /dev/null
+++ b/src/core/browser_context_adapter.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BROWSER_CONTEXT_ADAPTER_H
+#define BROWSER_CONTEXT_ADAPTER_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QScopedPointer>
+#include <QSharedData>
+
+class BrowserContextQt;
+class WebEngineVisitedLinksManager;
+
+// Make a QSharedData if we need to open arbitrary BrowserContextAdapter beyond the defaults.
+class QWEBENGINE_EXPORT BrowserContextAdapter // : public QSharedData
+{
+public:
+ virtual ~BrowserContextAdapter();
+
+ static BrowserContextAdapter* defaultContext();
+ static BrowserContextAdapter* offTheRecordContext();
+
+ WebEngineVisitedLinksManager *visitedLinksManager();
+
+ BrowserContextQt *browserContext();
+ bool isOffTheRecord() const { return m_offTheRecord; }
+ QString dataPath() const;
+ QString cachePath() const;
+
+protected:
+ explicit BrowserContextAdapter(bool offTheRecord = false);
+
+private:
+ bool m_offTheRecord;
+ QScopedPointer<BrowserContextQt> m_browserContext;
+ QScopedPointer<WebEngineVisitedLinksManager> m_visitedLinksManager;
+ friend class WebEngineContext;
+
+ Q_DISABLE_COPY(BrowserContextAdapter)
+};
+
+#endif // BROWSER_CONTEXT_ADAPTER_H
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp
index 44b6ca4ef..8dc4a3da2 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -36,6 +36,7 @@
#include "browser_context_qt.h"
+#include "browser_context_adapter.h"
#include "type_conversion.h"
#include "qtwebenginecoreglobal.h"
#include "resource_context_qt.h"
@@ -47,14 +48,8 @@
#include "content/public/browser/storage_partition.h"
#include "net/proxy/proxy_config_service.h"
-#include <QByteArray>
-#include <QCoreApplication>
-#include <QDir>
-#include <QStandardPaths>
-#include <QString>
-#include <QStringBuilder>
-
-BrowserContextQt::BrowserContextQt()
+BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
+ : m_adapter(adapter)
{
resourceContext.reset(new ResourceContextQt(this));
}
@@ -67,29 +62,17 @@ BrowserContextQt::~BrowserContextQt()
base::FilePath BrowserContextQt::GetPath() const
{
- QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
- if (dataLocation.isEmpty())
- dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
-
- dataLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
- dataLocation.append(QDir::separator() % QLatin1String("Default"));
- return base::FilePath(toFilePathString(dataLocation));
+ return base::FilePath(toFilePathString(m_adapter->dataPath()));
}
base::FilePath BrowserContextQt::GetCachePath() const
{
- QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- if (cacheLocation.isEmpty())
- cacheLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
-
- cacheLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
- cacheLocation.append(QDir::separator() % QLatin1String("Default"));
- return base::FilePath(toFilePathString(cacheLocation));
+ return base::FilePath(toFilePathString(m_adapter->cachePath()));
}
bool BrowserContextQt::IsOffTheRecord() const
{
- return false;
+ return m_adapter->isOffTheRecord();
}
net::URLRequestContextGetter *BrowserContextQt::GetRequestContext()
diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h
index 125c0fc46..634db6f3f 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/browser_context_qt.h
@@ -43,10 +43,12 @@
#include "net/url_request/url_request_context.h"
#include "download_manager_delegate_qt.h"
+class BrowserContextAdapter;
+
class BrowserContextQt : public content::BrowserContext
{
public:
- explicit BrowserContextQt();
+ explicit BrowserContextQt(BrowserContextAdapter *);
virtual ~BrowserContextQt();
@@ -70,6 +72,7 @@ private:
scoped_ptr<content::ResourceContext> resourceContext;
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
scoped_ptr<DownloadManagerDelegateQt> downloadManagerDelegate;
+ BrowserContextAdapter *m_adapter;
DISALLOW_COPY_AND_ASSIGN(BrowserContextQt);
};
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 3ead5314f..2aca88d6a 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -201,12 +201,10 @@ public:
void PreMainMessageLoopRun() Q_DECL_OVERRIDE
{
- m_browserContext.reset(new BrowserContextQt());
}
void PostMainMessageLoopRun()
{
- m_browserContext.reset();
}
int PreCreateThreads() Q_DECL_OVERRIDE
@@ -217,13 +215,7 @@ public:
return 0;
}
- BrowserContextQt* browser_context() const {
- return m_browserContext.get();
- }
-
private:
- scoped_ptr<BrowserContextQt> m_browserContext;
-
DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt);
};
@@ -347,22 +339,15 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, c
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();
-}
-
-net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* content_browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
+net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
{
- if (content_browser_context != browser_context())
- fprintf(stderr, "Warning: off the record browser context not implemented !\n");
- return static_cast<BrowserContextQt*>(browser_context())->CreateRequestContext(protocol_handlers);
+ return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers);
}
-void ContentBrowserClientQt::enableInspector(bool enable)
+void ContentBrowserClientQt::enableInspector(bool enable, content::BrowserContext* browser_context)
{
if (enable && !m_devtools) {
- m_devtools.reset(new DevToolsHttpHandlerDelegateQt(browser_context()));
+ m_devtools.reset(new DevToolsHttpHandlerDelegateQt(browser_context));
} else if (!enable && m_devtools) {
m_devtools.reset();
}
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index dd5d9f3a1..ed328d1bf 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -98,11 +98,9 @@ public:
base::Callback<void(bool)> result_callback,
base::Closure *cancel_callback) Q_DECL_OVERRIDE;
- BrowserContextQt* browser_context();
-
virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *content_browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE;
- void enableInspector(bool);
+ void enableInspector(bool enable, content::BrowserContext *browser_context);
private:
BrowserMainPartsQt* m_browserMainParts;
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index c50d56df4..c6144b344 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -35,6 +35,7 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] $$PWD
SOURCES = \
browser_accessibility_manager_qt.cpp \
browser_accessibility_qt.cpp \
+ browser_context_adapter.cpp \
browser_context_qt.cpp \
certificate_error_controller.cpp \
chromium_gpu_helper.cpp \
@@ -82,6 +83,7 @@ SOURCES = \
HEADERS = \
browser_accessibility_manager_qt.h \
browser_accessibility_qt.h \
+ browser_context_adapter.h \
browser_context_qt.h \
certificate_error_controller_p.h \
certificate_error_controller.h \
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 1a393a0c7..b086cd4f3 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -55,6 +55,7 @@
#include "base/bind.h"
#include "cc/output/delegated_frame_data.h"
#include "cc/quads/checkerboard_draw_quad.h"
+#include "cc/quads/debug_border_draw_quad.h"
#include "cc/quads/draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/solid_color_draw_quad.h"
@@ -601,6 +602,30 @@ void DelegatedFrameNode::commit(DelegatedFrameNodeData* data, cc::ReturnedResour
rectangleNode->setColor(toQt(scquad->color));
currentLayerChain->appendChildNode(rectangleNode);
break;
+ } case cc::DrawQuad::DEBUG_BORDER: {
+ const cc::DebugBorderDrawQuad *dbquad = cc::DebugBorderDrawQuad::MaterialCast(quad);
+ QSGGeometryNode *geometryNode = new QSGGeometryNode;
+
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
+ geometry->setDrawingMode(GL_LINE_LOOP);
+ geometry->setLineWidth(dbquad->width);
+ // QSGGeometry::updateRectGeometry would actually set the corners in the following order:
+ // top-left, bottom-left, top-right, bottom-right, leading to a nice criss cross, instead
+ // of having a closed loop.
+ const gfx::Rect &r(dbquad->rect);
+ geometry->vertexDataAsPoint2D()[0].set(r.x(), r.y());
+ geometry->vertexDataAsPoint2D()[1].set(r.x() + r.width(), r.y());
+ geometry->vertexDataAsPoint2D()[2].set(r.x() + r.width(), r.y() + r.height());
+ geometry->vertexDataAsPoint2D()[3].set(r.x(), r.y() + r.height());
+ geometryNode->setGeometry(geometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(toQt(dbquad->color));
+ geometryNode->setMaterial(material);
+
+ geometryNode->setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial);
+ currentLayerChain->appendChildNode(geometryNode);
+ break;
} case cc::DrawQuad::TILED_CONTENT: {
const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad);
QSharedPointer<MailboxTexture> &texture = findMailboxTexture(tquad->resource_id, m_data->mailboxTextures, mailboxTextureCandidates);
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 3f223f733..dd9f800db 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -41,6 +41,7 @@
#include "web_contents_adapter.h"
#include "web_contents_adapter_p.h"
+#include "browser_context_adapter.h"
#include "browser_context_qt.h"
#include "content_browser_client_qt.h"
#include "javascript_dialog_manager_qt.h"
@@ -175,9 +176,8 @@ static QStringList listRecursively(const QDir& dir) {
return ret;
}
-static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient)
+static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
{
- content::BrowserContext* browserContext = ContentBrowserClientQt::Get()->browser_context();
content::WebContents::CreateParams create_params(browserContext, NULL);
create_params.routing_id = MSG_ROUTING_NONE;
create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight);
@@ -222,7 +222,7 @@ static void serializeNavigationHistory(const content::NavigationController &cont
}
}
-void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<content::NavigationEntry*> *entries)
+void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<content::NavigationEntry*> *entries, content::BrowserContext *browserContext)
{
int version;
input >> version;
@@ -278,7 +278,7 @@ void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::ve
false,
// The extra headers are not sync'ed across sessions.
std::string(),
- ContentBrowserClientQt::Get()->browser_context());
+ browserContext);
entry->SetTitle(toString16(title));
entry->SetPageState(content::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size())));
@@ -308,13 +308,13 @@ QExplicitlySharedDataPointer<WebContentsAdapter> WebContentsAdapter::createFromS
{
int currentIndex;
std::vector<content::NavigationEntry*> entries;
- deserializeNavigationHistory(input, &currentIndex, &entries);
+ deserializeNavigationHistory(input, &currentIndex, &entries, adapterClient->browserContextAdapter()->browserContext());
if (currentIndex == -1)
return QExplicitlySharedDataPointer<WebContentsAdapter>();
// Unlike WebCore, Chromium only supports Restoring to a new WebContents instance.
- content::WebContents* newWebContents = createBlankWebContents(adapterClient);
+ content::WebContents* newWebContents = createBlankWebContents(adapterClient, adapterClient->browserContextAdapter()->browserContext());
content::NavigationController &controller = newWebContents->GetController();
controller.Restore(currentIndex, content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries);
@@ -350,7 +350,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
// Create our own if a WebContents wasn't provided at construction.
if (!d->webContents)
- d->webContents.reset(createBlankWebContents(adapterClient));
+ d->webContents.reset(createBlankWebContents(adapterClient, adapterClient->browserContextAdapter()->browserContext()));
// This might replace any adapter that has been initialized with this WebEngineSettings.
adapterClient->webEngineSettings()->setWebContentsAdapter(this);
@@ -625,7 +625,13 @@ qreal WebContentsAdapter::currentZoomFactor() const
void WebContentsAdapter::enableInspector(bool enable)
{
- ContentBrowserClientQt::Get()->enableInspector(enable);
+ ContentBrowserClientQt::Get()->enableInspector(enable, browserContext());
+}
+
+BrowserContextQt* WebContentsAdapter::browserContext()
+{
+ Q_D(WebContentsAdapter);
+ return static_cast<BrowserContextQt*>(d->webContents->GetBrowserContext());
}
QAccessibleInterface *WebContentsAdapter::browserAccessible()
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 6bec50316..6e17fc2f5 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -48,6 +48,7 @@
namespace content {
class WebContents;
}
+class BrowserContextQt;
class WebContentsAdapterPrivate;
struct WebPreferences;
@@ -111,11 +112,13 @@ public:
void dpiScaleChanged();
QAccessibleInterface *browserAccessible();
+ BrowserContextQt* browserContext();
private:
Q_DISABLE_COPY(WebContentsAdapter);
Q_DECLARE_PRIVATE(WebContentsAdapter);
QScopedPointer<WebContentsAdapterPrivate> d_ptr;
+
friend class WebContentsDelegateQt;
};
#endif // WEB_CONTENTS_ADAPTER_H
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 8fd401fe4..8fd988c7e 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -48,6 +48,7 @@
QT_FORWARD_DECLARE_CLASS(QVariant)
+class BrowserContextAdapter;
class CertificateErrorController;
class JavaScriptDialogController;
class RenderWidgetHostViewQt;
@@ -176,6 +177,8 @@ public:
virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController) = 0;
+ virtual BrowserContextAdapter* browserContextAdapter() = 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 c2cccfedb..f9dba67fe 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -40,6 +40,7 @@
#include "web_contents_delegate_qt.h"
+#include "browser_context_adapter.h"
#include "media_capture_devices_dispatcher.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
@@ -270,7 +271,7 @@ void WebContentsDelegateQt::DidNavigateAnyFrame(const content::LoadCommittedDeta
{
if (!params.should_update_history)
return;
- WebEngineContext::current()->visitedLinksManager()->addUrl(params.url);
+ m_viewClient->browserContextAdapter()->visitedLinksManager()->addUrl(params.url);
}
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 20bf3e051..d4659f0be 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -65,6 +65,7 @@
#include "content/public/app/startup_helper_win.h"
#endif // OS_WIN
+#include "browser_context_adapter.h"
#include "content_browser_client_qt.h"
#include "content_client_qt.h"
#include "content_main_delegate_qt.h"
@@ -73,7 +74,6 @@
#include "type_conversion.h"
#include "surface_factory_qt.h"
#include "web_engine_library_info.h"
-#include "web_engine_visited_links_manager.h"
#include <QGuiApplication>
#include <QOpenGLContext>
#include <QStringList>
@@ -107,9 +107,18 @@ scoped_refptr<WebEngineContext> WebEngineContext::current()
return sContext;
}
-WebEngineVisitedLinksManager *WebEngineContext::visitedLinksManager()
+BrowserContextAdapter* WebEngineContext::defaultBrowserContext()
{
- return m_visitedLinksManager.get();
+ if (!m_defaultBrowserContext)
+ m_defaultBrowserContext.reset(new BrowserContextAdapter());
+ return m_defaultBrowserContext.get();
+}
+
+BrowserContextAdapter* WebEngineContext::offTheRecordBrowserContext()
+{
+ if (!m_offTheRecordBrowserContext)
+ m_offTheRecordBrowserContext.reset(new BrowserContextAdapter(true));
+ return m_offTheRecordBrowserContext.get();
}
#ifndef CHROMIUM_VERSION
@@ -204,7 +213,4 @@ WebEngineContext::WebEngineContext()
// thread to avoid a thread check assertion in its constructor when it
// first gets referenced on the IO thread.
MediaCaptureDevicesDispatcher::GetInstance();
-
- // Ensure we have a VisitedLinksMaster instance up and running
- m_visitedLinksManager.reset(new WebEngineVisitedLinksManager);
}
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index d1cd9a7a5..0b3ad8678 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -49,15 +49,16 @@ class BrowserMainRunner;
class ContentMainRunner;
}
+class BrowserContextAdapter;
class ContentMainDelegateQt;
class SurfaceFactoryQt;
-class WebEngineVisitedLinksManager;
class WebEngineContext : public base::RefCounted<WebEngineContext> {
public:
static scoped_refptr<WebEngineContext> current();
- WebEngineVisitedLinksManager *visitedLinksManager();
+ BrowserContextAdapter *defaultBrowserContext();
+ BrowserContextAdapter *offTheRecordBrowserContext();
private:
friend class base::RefCounted<WebEngineContext>;
@@ -71,7 +72,8 @@ private:
#if defined(OS_ANDROID)
scoped_ptr<SurfaceFactoryQt> m_surfaceFactory;
#endif
- scoped_ptr<WebEngineVisitedLinksManager> m_visitedLinksManager;
+ scoped_ptr<BrowserContextAdapter> m_defaultBrowserContext;
+ scoped_ptr<BrowserContextAdapter> m_offTheRecordBrowserContext;
};
#endif // WEB_ENGINE_CONTEXT_H
diff --git a/src/core/web_engine_visited_links_manager.cpp b/src/core/web_engine_visited_links_manager.cpp
index 36467ca21..a2f6dbf9f 100644
--- a/src/core/web_engine_visited_links_manager.cpp
+++ b/src/core/web_engine_visited_links_manager.cpp
@@ -36,8 +36,9 @@
#include "web_engine_visited_links_manager.h"
-#include "content_browser_client_qt.h"
+#include "browser_context_adapter.h"
#include "browser_context_qt.h"
+#include "content_browser_client_qt.h"
#include "type_conversion.h"
#include "base/memory/scoped_ptr.h"
@@ -80,11 +81,11 @@ void WebEngineVisitedLinksManager::deleteVisitedLinkDataForUrls(const QList<QUrl
m_visitedLinkMaster->DeleteURLs(&iterator);
}
-WebEngineVisitedLinksManager::WebEngineVisitedLinksManager()
+WebEngineVisitedLinksManager::WebEngineVisitedLinksManager(BrowserContextAdapter *adapter)
: m_delegate(new VisitedLinkDelegateQt)
{
- Q_ASSERT(ContentBrowserClientQt::Get() && ContentBrowserClientQt::Get()->browser_context());
- BrowserContextQt *browserContext = ContentBrowserClientQt::Get()->browser_context();
+ Q_ASSERT(adapter && adapter->browserContext());
+ BrowserContextQt *browserContext = adapter->browserContext();
m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(browserContext, m_delegate.data(), /* persist to disk = */true));
m_visitedLinkMaster->Init();
}
diff --git a/src/core/web_engine_visited_links_manager.h b/src/core/web_engine_visited_links_manager.h
index aa44dd9cf..5b0286c51 100644
--- a/src/core/web_engine_visited_links_manager.h
+++ b/src/core/web_engine_visited_links_manager.h
@@ -49,6 +49,7 @@ namespace visitedlink {
class VisitedLinkMaster;
}
+class BrowserContextAdapter;
class VisitedLinkDelegateQt;
class GURL;
@@ -57,7 +58,7 @@ class QWEBENGINE_EXPORT WebEngineVisitedLinksManager {
public:
virtual~WebEngineVisitedLinksManager();
- WebEngineVisitedLinksManager();
+ WebEngineVisitedLinksManager(BrowserContextAdapter*);
void deleteAllVisitedLinkData();
void deleteVisitedLinkDataForUrls(const QList<QUrl> &);
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index ad850e84e..3a6b8cb21 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -37,6 +37,7 @@
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
+#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
#include "javascript_dialog_controller.h"
#include "qquickwebenginehistory_p.h"
@@ -343,9 +344,11 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten
switch (disposition) {
case WebContentsAdapterClient::NewForegroundTabDisposition:
- case WebContentsAdapterClient::NewBackgroundTabDisposition:
request.m_destination = QQuickWebEngineView::NewViewInTab;
break;
+ case WebContentsAdapterClient::NewBackgroundTabDisposition:
+ request.m_destination = QQuickWebEngineView::NewViewInBackgroundTab;
+ break;
case WebContentsAdapterClient::NewPopupDisposition:
request.m_destination = QQuickWebEngineView::NewViewInDialog;
break;
@@ -356,7 +359,7 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten
Q_UNREACHABLE();
}
- emit e->newViewRequested(&request);
+ Q_EMIT e->newViewRequested(&request);
}
void QQuickWebEngineViewPrivate::close()
@@ -401,6 +404,11 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
return q;
}
+BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter()
+{
+ return BrowserContextAdapter::defaultContext();
+}
+
WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
return m_settings->d_func()->coreSettings.data();
@@ -557,6 +565,17 @@ void QQuickWebEngineView::stop()
d->adapter->stop();
}
+void QQuickWebEngineView::setZoomFactor(qreal arg)
+{
+ Q_D(QQuickWebEngineView);
+ qreal oldFactor = d->adapter->currentZoomFactor();
+ d->adapter->setZoomFactor(arg);
+ if (qFuzzyCompare(oldFactor, d->adapter->currentZoomFactor()))
+ return;
+
+ emit zoomFactorChanged(arg);
+}
+
void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
Q_Q(QQuickWebEngineView);
@@ -620,6 +639,12 @@ QQuickWebEngineViewExperimental *QQuickWebEngineView::experimental() const
return d->e.data();
}
+qreal QQuickWebEngineView::zoomFactor() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->adapter->currentZoomFactor();
+}
+
bool QQuickWebEngineViewExperimental::inspectable() const
{
Q_D(const QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 22713ee22..9f6493022 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -56,6 +56,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged)
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_ENUMS(NavigationRequestAction);
Q_ENUMS(NavigationType);
Q_ENUMS(LoadStatus);
@@ -75,6 +76,7 @@ public:
QString title() const;
bool canGoBack() const;
bool canGoForward() const;
+ qreal zoomFactor() const;
QQuickWebEngineViewExperimental *experimental() const;
@@ -116,7 +118,8 @@ public:
enum NewViewDestination {
NewViewInWindow,
NewViewInTab,
- NewViewInDialog
+ NewViewInDialog,
+ NewViewInBackgroundTab
};
// must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel
@@ -133,6 +136,7 @@ public Q_SLOTS:
void goForward();
void reload();
void stop();
+ void setZoomFactor(qreal arg);
Q_SIGNALS:
void titleChanged();
@@ -143,6 +147,7 @@ Q_SIGNALS:
void linkHovered(const QUrl &hoveredUrl);
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
+ void zoomFactorChanged(qreal arg);
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 6662f1f02..c7ea6575e 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -179,6 +179,8 @@ public:
virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController);
+ virtual BrowserContextAdapter *browserContextAdapter() 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 72b16f28b..e3ab2ec0d 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -23,6 +23,7 @@
#include "qwebenginepage.h"
#include "qwebenginepage_p.h"
+#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
#include "javascript_dialog_controller.h"
#include "qwebenginehistory.h"
@@ -410,6 +411,11 @@ void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input)
}
}
+BrowserContextAdapter *QWebEnginePagePrivate::browserContextAdapter()
+{
+ return BrowserContextAdapter::defaultContext();
+}
+
QWebEnginePage::QWebEnginePage(QObject* parent)
: QObject(parent)
, d_ptr(new QWebEnginePagePrivate)
@@ -624,6 +630,13 @@ bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData
return true;
}
+void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
+{
+ Q_Q(QWebEnginePage);
+ bool accepted = q->acceptNavigationRequest(url, static_cast<QWebEnginePage::NavigationType>(navigationType), isMainFrame);
+ navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest;
+}
+
void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller)
{
Q_Q(QWebEnginePage);
@@ -945,6 +958,14 @@ bool QWebEnginePage::certificateError(const QWebEngineCertificateError &)
return false;
}
+bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
+{
+ Q_UNUSED(url);
+ Q_UNUSED(type);
+ Q_UNUSED(isMainFrame);
+ return true;
+}
+
QT_END_NAMESPACE
#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 7856b8243..afb62ceda 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -136,6 +136,16 @@ public:
PermissionDeniedByUser
};
+ // must match WebContentsAdapterClient::NavigationType
+ enum NavigationType {
+ NavigationTypeLinkClicked,
+ NavigationTypeTyped,
+ NavigationTypeFormSubmitted,
+ NavigationTypeBackForward,
+ NavigationTypeReload,
+ NavigationTypeOther
+ };
+
enum Feature {
#ifndef Q_QDOC
Notifications = 0,
@@ -248,6 +258,7 @@ protected:
virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString& msg, const QString& defaultValue, QString* result);
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID);
virtual bool certificateError(const QWebEngineCertificateError &certificateError);
+ virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
private:
Q_DECLARE_PRIVATE(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 54129229f..6424c3b0b 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -122,7 +122,7 @@ public:
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual bool contextMenuRequested(const WebEngineContextMenuData &data) Q_DECL_OVERRIDE;
- virtual void navigationRequested(int, const QUrl &, int &, bool) Q_DECL_OVERRIDE { }
+ virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
virtual void requestFullScreen(bool) Q_DECL_OVERRIDE { }
virtual bool isFullScreen() const Q_DECL_OVERRIDE { return false; }
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) Q_DECL_OVERRIDE;
@@ -139,6 +139,8 @@ public:
virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE;
+ virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE;
+
void updateAction(QWebEnginePage::WebAction) const;
void updateNavigationActions();
void _q_webActionTriggered(bool checked);
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index e89b10ab8..af435d170 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -147,6 +147,21 @@
*/
/*!
+ \enum QWebEnginePage::NavigationType
+
+ This enum describes the type of a navigation request.
+
+ \value NavigationTypeLinkClicked The navigation request resulted from a clicked link.
+ \value NavigationTypeTyped The navigation request resulted from an explicitly loaded url.
+ \value NavigationTypeFormSubmitted The navigation request resulted from a form submission.
+ \value NavigationTypeBackForward The navigation request resulted from a back/forward action.
+ \value NavigationTypeReload The navigation request resulted from a reload action.
+ \value NavigationTypeOther The navigation request was triggered by other means not covered by the above.
+
+ \sa acceptNavigationRequest()
+*/
+
+/*!
\enum QWebEnginePage::Feature
This enum describes the platform feature access categories that the user may be asked to grant or deny access to.
@@ -209,6 +224,15 @@
*/
/*!
+ \fn bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
+ This function is called whenever there is a request to navigate to a specified \a url by means of the specified navigation type \atype.
+ The \a isMainFrame argument marks if the request corresponds to the main frame, or a sub frame.
+ If the request is accepted Chromium will continue to load the page, else the request will be ignored.
+ The default implementation accepts the navigation request.
+*/
+
+
+/*!
\fn void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString& msg)
This function is called whenever a JavaScript program running in a frame affiliated with \a securityOrigin calls the alert() function with
the message \a msg.
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index f7cffb8b1..abb8d3d7b 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -90,6 +90,7 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.NewViewInWindow --> NewViewDestination"
<< "QQuickWebEngineView.NewViewInTab --> NewViewDestination"
<< "QQuickWebEngineView.NewViewInDialog --> NewViewDestination"
+ << "QQuickWebEngineView.NewViewInBackgroundTab --> NewViewDestination"
<< "QQuickWebEngineView.InfoMessageLevel --> JavaScriptConsoleMessageLevel"
<< "QQuickWebEngineView.WarningMessageLevel --> JavaScriptConsoleMessageLevel"
<< "QQuickWebEngineView.ErrorMessageLevel --> JavaScriptConsoleMessageLevel"
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 6fb46057d..85939a686 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -107,11 +107,11 @@ private Q_SLOTS:
void contextMenuCopy();
void contextMenuPopulatedOnce();
void acceptNavigationRequest();
+ void acceptNavigationRequestNavigationType();
void geolocationRequestJS();
void loadFinished();
void actionStates();
void popupFormSubmission();
- void acceptNavigationRequestWithNewWindow();
void userStyleSheet();
void userStyleSheetFromLocalFileUrl();
void userStyleSheetFromQrcUrl();
@@ -133,8 +133,6 @@ private Q_SLOTS:
void textEditing();
void backActionUpdate();
void frameAt();
- void requestCache();
- void loadCachedPage();
void protectBindingsRuntimeObjectsFromCollector();
void localURLSchemes();
void testOptionalJSObjects();
@@ -240,7 +238,6 @@ void tst_QWebEnginePage::cleanupTestCase()
cleanupFiles(); // Be nice
}
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
class NavigationRequestOverride : public QWebEnginePage
{
public:
@@ -248,21 +245,18 @@ public:
bool m_acceptNavigationRequest;
protected:
- virtual bool acceptNavigationRequest(QWebEngineFrame* frame, const QNetworkRequest &request, QWebEnginePage::NavigationType type) {
- Q_UNUSED(frame);
- Q_UNUSED(request);
+ virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
+ {
+ Q_UNUSED(url);
Q_UNUSED(type);
+ Q_UNUSED(isMainFrame);
return m_acceptNavigationRequest;
}
};
-#endif
void tst_QWebEnginePage::acceptNavigationRequest()
{
-#if !defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
- QSKIP("QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST");
-#else
QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
NavigationRequestOverride* newPage = new NavigationRequestOverride(m_view, false);
@@ -278,11 +272,10 @@ void tst_QWebEnginePage::acceptNavigationRequest()
evaluateJavaScriptSync(m_view->page(), "tstform.submit();");
QTRY_COMPARE(loadSpy.count(), 2);
- QCOMPARE(m_view->page()->toPlainText(), QString("foo?"));
+ QCOMPARE(toPlainTextSync(m_view->page()), QString("foo?"));
// Restore default page
m_view->setPage(0);
-#endif
}
#if defined(QWEBENGINEPAGE_SETFEATUREPERMISSION)
@@ -439,23 +432,22 @@ public:
connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
}
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
struct Navigation {
- QWebEngineFrame *frame;
- QNetworkRequest request;
NavigationType type;
+ QUrl url;
+ bool isMainFrame;
};
QList<Navigation> navigations;
- virtual bool acceptNavigationRequest(QWebEngineFrame* frame, const QNetworkRequest &request, NavigationType type) {
+ virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
+ {
Navigation n;
- n.frame = frame;
- n.request = request;
+ n.url = url;
n.type = type;
+ n.isMainFrame = isMainFrame;
navigations.append(n);
return true;
}
-#endif
QList<TestPage*> createdWindows;
virtual QWebEnginePage* createWindow(WebWindowType) {
@@ -471,6 +463,42 @@ private Q_SLOTS:
}
};
+void tst_QWebEnginePage::acceptNavigationRequestNavigationType()
+{
+
+ TestPage page;
+ QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
+
+ page.load(QUrl("qrc:///resources/script.html"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QTRY_COMPARE(page.navigations.count(), 1);
+
+ page.load(QUrl("qrc:///resources/content.html"));
+ QTRY_COMPARE(loadSpy.count(), 2);
+ QTRY_COMPARE(page.navigations.count(), 2);
+
+ page.triggerAction(QWebEnginePage::Stop);
+ QVERIFY(page.history()->canGoBack());
+ page.triggerAction(QWebEnginePage::Back);
+
+ QTRY_COMPARE(loadSpy.count(), 3);
+ QTRY_COMPARE(page.navigations.count(), 3);
+
+ page.triggerAction(QWebEnginePage::Reload);
+ QTRY_COMPARE(loadSpy.count(), 4);
+ QTRY_COMPARE(page.navigations.count(), 4);
+
+ QList<QWebEnginePage::NavigationType> expectedList;
+ expectedList << QWebEnginePage::NavigationTypeTyped
+ << QWebEnginePage::NavigationTypeTyped
+ << QWebEnginePage::NavigationTypeBackForward
+ << QWebEnginePage::NavigationTypeReload;
+ QVERIFY(expectedList.count() == page.navigations.count());
+ for (int i = 0; i < expectedList.count(); ++i) {
+ QCOMPARE(page.navigations[i].type, expectedList[i]);
+ }
+}
+
void tst_QWebEnginePage::popupFormSubmission()
{
TestPage page;
@@ -491,38 +519,6 @@ void tst_QWebEnginePage::popupFormSubmission()
QVERIFY(url.contains("?foo=bar"));
}
-void tst_QWebEnginePage::acceptNavigationRequestWithNewWindow()
-{
-#if !defined(QWEBENGINESETTINGS)
- QSKIP("QWEBENGINESETTINGS");
-#else
- TestPage* page = new TestPage(m_view);
- page->settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, true);
- m_page = page;
- m_view->setPage(m_page);
-
- m_view->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
- QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
-
- QFocusEvent fe(QEvent::FocusIn);
- m_page->event(&fe);
-
- QVERIFY(m_page->focusNextPrevChild(/*next*/ true));
-
- QKeyEvent keyEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
- m_page->event(&keyEnter);
-
- QCOMPARE(page->navigations.count(), 2);
-
- TestPage::Navigation n = page->navigations.at(1);
- QVERIFY(!n.frame);
- QCOMPARE(n.request.url().toString(), QString("data:text/html,Reached"));
- QVERIFY(n.type == QWebEnginePage::NavigationTypeLinkClicked);
-
- QCOMPARE(page->createdWindows.count(), 1);
-#endif
-}
-
class TestNetworkManager : public QNetworkAccessManager
{
public:
@@ -1606,72 +1602,6 @@ void tst_QWebEnginePage::textEditing()
#endif
}
-void tst_QWebEnginePage::requestCache()
-{
-#if !defined(ACCEPTNAVIGATIONREQUEST)
- QSKIP("ACCEPTNAVIGATIONREQUEST");
-#else
- TestPage page;
- QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
-
- page.setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
- QTRY_COMPARE(loadSpy.count(), 1);
- QTRY_COMPARE(page.navigations.count(), 1);
-
- page.setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me2</a>"));
- QTRY_COMPARE(loadSpy.count(), 2);
- QTRY_COMPARE(page.navigations.count(), 2);
-
- page.triggerAction(QWebEnginePage::Stop);
- QVERIFY(page.history()->canGoBack());
- page.triggerAction(QWebEnginePage::Back);
-
- QTRY_COMPARE(loadSpy.count(), 3);
- QTRY_COMPARE(page.navigations.count(), 3);
- QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
- (int)QNetworkRequest::PreferNetwork);
- QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
- (int)QNetworkRequest::PreferNetwork);
- QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
- (int)QNetworkRequest::PreferCache);
-#endif
-}
-
-void tst_QWebEnginePage::loadCachedPage()
-{
-#if !defined(QWEBENGINESETTINGS)
- QSKIP("QWEBENGINESETTINGS");
-#else
- TestPage page;
- QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
- page.settings()->setMaximumPagesInCache(3);
-
- page.load(QUrl("data:text/html,This is first page"));
-
- QTRY_COMPARE(loadSpy.count(), 1);
- QTRY_COMPARE(page.navigations.count(), 1);
-
- QUrl firstPageUrl = page.url();
- page.load(QUrl("data:text/html,This is second page"));
-
- QTRY_COMPARE(loadSpy.count(), 2);
- QTRY_COMPARE(page.navigations.count(), 2);
-
- page.triggerAction(QWebEnginePage::Stop);
- QVERIFY(page.history()->canGoBack());
-
- QSignalSpy urlSpy(&page, SIGNAL(urlChanged(QUrl)));
- QVERIFY(urlSpy.isValid());
-
- page.triggerAction(QWebEnginePage::Back);
- ::waitForSignal(&page, SIGNAL(urlChanged(QUrl)));
- QCOMPARE(urlSpy.size(), 1);
-
- QList<QVariant> arguments1 = urlSpy.takeFirst();
- QCOMPARE(arguments1.at(0).toUrl(), firstPageUrl);
-#endif
-}
-
void tst_QWebEnginePage::backActionUpdate()
{
QWebEngineView view;
diff --git a/tests/quicktestbrowser/ZoomController.qml b/tests/quicktestbrowser/ZoomController.qml
new file mode 100644
index 000000000..a714ed2a9
--- /dev/null
+++ b/tests/quicktestbrowser/ZoomController.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** 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:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+import QtQuick.Controls 1.2
+import QtQuick.Layouts 1.1
+
+Rectangle {
+ property alias zoomFactor: slider.value ;
+ function zoomIn() {
+ visible = true
+ visibilityTimer.restart()
+ zoomFactor = zoomFactor + 0.25;
+ }
+ function zoomOut() {
+ visible = true
+ visibilityTimer.restart()
+ zoomFactor = zoomFactor - 0.25;
+ }
+ function reset() { zoomFactor = 1.0 }
+
+ width: 220
+ height: 30
+ color: palette.window
+ visible: false
+ radius: 4
+
+ SystemPalette {
+ id: palette
+ }
+ Timer {
+ id: visibilityTimer
+ interval: 3000
+ repeat: false
+ onTriggered: zoomController.visible = false
+ }
+
+ RowLayout {
+ anchors.margins: 4
+ anchors.fill: parent
+ ToolButton {
+ id: plusButton
+ text: '+'
+ onClicked: zoomIn()
+ }
+ ToolButton {
+ text: '\u2014'
+ id: minusButton
+ onClicked: zoomOut()
+ }
+ Slider {
+ id: slider
+ maximumValue: 5.0
+ minimumValue: 0.25
+ Layout.fillWidth: true;
+ stepSize: 0.05
+ value: 1
+ onValueChanged: visibilityTimer.restart()
+ }
+ Button {
+ text: "Reset"
+ onClicked: reset()
+ }
+ }
+}
diff --git a/tests/quicktestbrowser/quickwindow.qml b/tests/quicktestbrowser/quickwindow.qml
index 6a5ef3187..b1be6db3e 100644
--- a/tests/quicktestbrowser/quickwindow.qml
+++ b/tests/quicktestbrowser/quickwindow.qml
@@ -122,6 +122,18 @@ ApplicationWindow {
browserWindow.showNormal()
}
}
+ Action {
+ shortcut: "Ctrl+0"
+ onTriggered: zoomController.reset()
+ }
+ Action {
+ shortcut: "Ctrl+-"
+ onTriggered: zoomController.zoomOut()
+ }
+ Action {
+ shortcut: "Ctrl+="
+ onTriggered: zoomController.zoomIn()
+ }
Menu {
id: backHistoryMenu
@@ -342,7 +354,7 @@ ApplicationWindow {
var tab = tabs.createEmptyTab()
request.openIn(tab.item.webView)
} else if (request.destination == WebEngineView.NewViewInDialog) {
- var dialog = dialogComponent.createObject()
+ var dialog = dialogComponent.createObject(webEngineView)
request.openIn(dialog.webView)
} else {
var component = Qt.createComponent("quickwindow.qml")
@@ -399,4 +411,16 @@ ApplicationWindow {
}
}
}
+ ZoomController {
+ id: zoomController
+ y: parent.mapFromItem(currentWebView, 0 , 0).y - 4
+ anchors.right: parent.right
+ width: (parent.width > 800) ? parent.width * 0.25 : 220
+ anchors.rightMargin: (parent.width > 400) ? 100 : 0
+ }
+ Binding {
+ target: currentWebView
+ property: "zoomFactor"
+ value: zoomController.zoomFactor
+ }
}
diff --git a/tests/quicktestbrowser/resources.qrc b/tests/quicktestbrowser/resources.qrc
index cdc3d2304..4880b3d65 100644
--- a/tests/quicktestbrowser/resources.qrc
+++ b/tests/quicktestbrowser/resources.qrc
@@ -4,6 +4,7 @@
<file>ContextMenuExtras.qml</file>
<file>FeaturePermissionBar.qml</file>
<file>ButtonWithMenu.qml</file>
+ <file>ZoomController.qml</file>
</qresource>
<qresource prefix="icons">
<!-- To the risk of this breaking more often, do not duplicate the resources since this application won't be deployed -->
diff --git a/tests/quicktestbrowser/util.h b/tests/quicktestbrowser/util.h
index bad41d6a7..85db8c25b 100644
--- a/tests/quicktestbrowser/util.h
+++ b/tests/quicktestbrowser/util.h
@@ -50,7 +50,7 @@ QUrl urlFromUserInput(const QString& userInput)
{
QFileInfo fileInfo(userInput);
if (fileInfo.exists())
- return QUrl(fileInfo.absoluteFilePath());
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
return QUrl::fromUserInput(userInput);
}