diff options
Diffstat (limited to 'src/core/web_contents_adapter.h')
-rw-r--r-- | src/core/web_contents_adapter.h | 122 |
1 files changed, 60 insertions, 62 deletions
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index acf65f4d5..24de7eb1b 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // // W A R N I N G @@ -51,24 +15,38 @@ #ifndef WEB_CONTENTS_ADAPTER_H #define WEB_CONTENTS_ADAPTER_H -#include "qtwebenginecoreglobal_p.h" -#include "qwebenginecontextmenurequest_p.h" -#include "web_contents_adapter_client.h" -#include <memory> +#include <QtCore/QSharedPointer> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QUrl> +#include <QtCore/QVariant> +#include <QtCore/QPointer> #include <QtGui/qtgui-config.h> +#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h> +#include <QtWebEngineCore/qwebenginecontextmenurequest.h> #include <QtWebEngineCore/qwebenginehttprequest.h> +#include <QtWebEngineCore/qwebengineframe.h> -#include <QScopedPointer> -#include <QSharedPointer> -#include <QString> -#include <QUrl> -#include <QPointer> +#include "web_contents_adapter_client.h" + +#include <functional> +#include <memory> +#include <optional> + +namespace blink { +namespace web_pref { +struct WebPreferences; +} +} + +namespace base { +class Value; +} namespace content { class WebContents; -struct WebPreferences; -struct OpenURLParams; class SiteInstance; +class RenderFrameHost; } QT_BEGIN_NAMESPACE @@ -78,7 +56,7 @@ class QDragMoveEvent; class QDropEvent; class QMimeData; class QPageLayout; -class QString; +class QPageRanges; class QTemporaryDir; class QWebChannel; class QWebEngineUrlRequestInterceptor; @@ -87,16 +65,18 @@ QT_END_NAMESPACE namespace QtWebEngineCore { class DevToolsFrontendQt; -class FaviconManager; class FindTextHelper; -class MessagePassingInterface; class ProfileQt; -class RenderViewObserverHostQt; +class WebEnginePageHost; class WebChannelIPCTransportHost; -class WebEngineContext; -class Q_WEBENGINECORE_PRIVATE_EXPORT WebContentsAdapter : public QEnableSharedFromThis<WebContentsAdapter> { +class Q_WEBENGINECORE_EXPORT WebContentsAdapter : public QEnableSharedFromThis<WebContentsAdapter> { public: + // Sentinel to indicate that a behavior should happen on the main frame + static constexpr quint64 kUseMainFrameId = -2; + // Sentinel to indicate a frame doesn't exist, for example with `findFrameByName` + static constexpr quint64 kInvalidFrameId = -3; + static QSharedPointer<WebContentsAdapter> createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient); WebContentsAdapter(); WebContentsAdapter(std::unique_ptr<content::WebContents> webContents); @@ -133,6 +113,7 @@ public: QString pageTitle() const; QString selectedText() const; QUrl iconUrl() const; + QIcon icon() const; void undo(); void redo(); @@ -158,11 +139,13 @@ public: void serializeNavigationHistory(QDataStream &output); void setZoomFactor(qreal); qreal currentZoomFactor() const; - void runJavaScript(const QString &javaScript, quint32 worldId); - quint64 runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId); + void runJavaScript(const QString &javaScript, quint32 worldId, quint64 frameId, + const std::function<void(const QVariant &)> &callback); + void didRunJavaScript(quint64 requestId, const base::Value &result); + void clearJavaScriptCallbacks(); quint64 fetchDocumentMarkup(); quint64 fetchDocumentInnerText(); - void updateWebPreferences(const content::WebPreferences &webPreferences); + void updateWebPreferences(const blink::web_pref::WebPreferences &webPreferences); void download(const QUrl &url, const QString &suggestedFileName, const QUrl &referrerUrl = QUrl(), ReferrerPolicy referrerPolicy = ReferrerPolicy::Default); @@ -193,6 +176,7 @@ public: void openDevToolsFrontend(QSharedPointer<WebContentsAdapter> devtoolsFrontend); void closeDevToolsFrontend(); void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend); + QString devToolsId(); void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags); void grantMouseLockPermission(const QUrl &securityOrigin, bool granted); @@ -206,8 +190,8 @@ public: #if QT_CONFIG(webengine_webchannel) QWebChannel *webChannel() const; void setWebChannel(QWebChannel *, uint worldId); + WebChannelIPCTransportHost *webChannelTransport() { return m_webChannelTransport.get(); } #endif - FaviconManager *faviconManager(); FindTextHelper *findTextHelper(); QPointF lastScrollOffset() const; @@ -222,8 +206,8 @@ public: void endDragging(QDropEvent *e, const QPointF &screenPos); void leaveDrag(); #endif // QT_CONFIG(draganddrop) - void printToPDF(const QPageLayout&, const QString&); - quint64 printToPDFCallbackResult(const QPageLayout &, + void printToPDF(const QPageLayout&, const QPageRanges &, const QString&); + quint64 printToPDFCallbackResult(const QPageLayout &, const QPageRanges &, bool colorMode = true, bool useCustomMargins = true); @@ -234,10 +218,22 @@ public: bool isFindTextInProgress() const; bool hasFocusedFrame() const; void resetSelection(); + void resetTouchSelectionController(); + void changeTextDirection(bool leftToRight); + + quint64 mainFrameId() const; + QString frameName(quint64 id) const; + QString frameHtmlName(quint64 id) const; + QList<quint64> frameChildren(quint64 id) const; + QUrl frameUrl(quint64 id) const; + QSizeF frameSize(quint64 id) const; + std::optional<quint64> findFrameIdByName(const QString &name) const; + bool hasFrame(quint64 id) const; // meant to be used within WebEngineCore only void initialize(content::SiteInstance *site); content::WebContents *webContents() const; + content::WebContents *guestWebContents() const; void updateRecommendedState(); void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); QWebEngineUrlRequestInterceptor* requestInterceptor() const; @@ -246,6 +242,7 @@ private: Q_DISABLE_COPY(WebContentsAdapter) void waitForUpdateDragActionCalled(); bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData); + content::RenderFrameHost *renderFrameHostFromFrameId(quint64 frameId) const; void wasShown(); void wasHidden(); @@ -262,7 +259,7 @@ private: ProfileAdapter *m_profileAdapter; std::unique_ptr<content::WebContents> m_webContents; std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate; - std::unique_ptr<RenderViewObserverHostQt> m_renderViewObserverHost; + std::unique_ptr<WebEnginePageHost> m_pageHost; #if QT_CONFIG(webengine_webchannel) std::unique_ptr<WebChannelIPCTransportHost> m_webChannelTransport; QWebChannel *m_webChannel; @@ -271,6 +268,7 @@ private: WebContentsAdapterClient *m_adapterClient; quint64 m_nextRequestId; QMap<QUrl, bool> m_pendingMouseLockPermissions; + QMap<quint64, std::function<void(const QVariant &)>> m_javaScriptCallbacks; std::unique_ptr<content::DropData> m_currentDropData; uint m_currentDropAction; bool m_updateDragActionCalled; |