diff options
170 files changed, 1634 insertions, 294 deletions
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index 3465e0da6..f61bce268 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -52,12 +52,26 @@ ApplicationWindow { id: browserWindow property QtObject applicationRoot property Item currentWebView: tabs.currentIndex < tabs.count ? tabs.getTab(tabs.currentIndex).item : null + property int previousVisibility: Window.Windowed + + property bool isFullScreen: visibility == Window.FullScreen + onIsFullScreenChanged: { + // This is for the case where the system forces us to leave fullscreen. + if (currentWebView && !isFullScreen) { + currentWebView.state = "" + if (currentWebView.isFullScreen) + currentWebView.fullScreenCancelled() + } + } width: 1300 height: 900 visible: true title: currentWebView && currentWebView.title + // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. + Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint + // Create a styleItem to determine the platform. // When using style "mac", ToolButtons are not supposed to accept focus. StyleItem { id: styleItem } @@ -124,6 +138,13 @@ ApplicationWindow { } } Action { + shortcut: "Escape" + onTriggered: { + if (browserWindow.isFullScreen) + browserWindow.visibility = browserWindow.previousVisibility + } + } + Action { shortcut: "Ctrl+0" onTriggered: currentWebView.zoomFactor = 1.0; } @@ -289,11 +310,24 @@ ApplicationWindow { } } + states: [ + State { + name: "FullScreen" + PropertyChanges { + target: tabs + frameVisible: false + tabsVisible: false + } + PropertyChanges { + target: navigationBar + visible: false + } + } + ] + onCertificateError: { - sslDialog.certError = error - sslDialog.text = "Certificate Error: " + error.description - sslDialog.visible = true error.defer() + sslDialog.enqueue(error) } onNewViewRequested: { @@ -310,20 +344,51 @@ ApplicationWindow { request.openIn(window.currentWebView) } } + + onFullScreenRequested: { + if (request.toggleOn) { + webEngineView.state = "FullScreen" + browserWindow.previousVisibility = browserWindow.visibility + browserWindow.showFullScreen() + } else { + webEngineView.state = "" + browserWindow.visibility = browserWindow.previousVisibility + } + request.accept() + } } } } MessageDialog { id: sslDialog - property var certError - - standardButtons: StandardButton.Cancel | StandardButton.Ok - visible: false - title: "Do you want to accept this certificate?" + property var certErrors: [] + icon: StandardIcon.Warning + standardButtons: StandardButton.No | StandardButton.Yes + title: "Server's certificate not trusted" + text: "Do you wish to continue?" + detailedText: "If you wish so, you may continue with an unverified certificate. " + + "Accepting an unverified certificate means " + + "you may not be connected with the host you tried to connect to.\n" + + "Do you wish to override the security check and continue?" + onYes: { + certErrors.shift().ignoreCertificateError() + presentError() + } + onNo: reject() + onRejected: reject() - onAccepted: certError.ignoreCertificateError() - onRejected: certError.rejectCertificate() + function reject(){ + certErrors.shift().rejectCertificate() + presentError() + } + function enqueue(error){ + certErrors.push(error) + presentError() + } + function presentError(){ + visible = certErrors.length > 0 + } } DownloadView { id: downloadView diff --git a/examples/webenginewidgets/browser/Info_mac.plist b/examples/webenginewidgets/browser/Info_mac.plist index 2731c105d..ccd4b3f28 100644 --- a/examples/webenginewidgets/browser/Info_mac.plist +++ b/examples/webenginewidgets/browser/Info_mac.plist @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> -<plist version="0.9"> +<plist version="1.0"> <dict> + <key>NSPrincipalClass</key> + <string>NSApplication</string> <key>CFBundleIconFile</key> <string>@ICON@</string> <key>CFBundlePackageType</key> diff --git a/examples/webenginewidgets/browser/browser.pro b/examples/webenginewidgets/browser/browser.pro index c9bf1a9e0..f54186856 100644 --- a/examples/webenginewidgets/browser/browser.pro +++ b/examples/webenginewidgets/browser/browser.pro @@ -2,8 +2,6 @@ TEMPLATE = app TARGET = browser QT += webenginewidgets network widgets printsupport -macx: CONFIG -= app_bundle - qtHaveModule(uitools):!embedded: QT += uitools else: DEFINES += QT_NO_UITOOLS @@ -82,20 +80,6 @@ mac { ICON = browser.icns QMAKE_INFO_PLIST = Info_mac.plist TARGET = Browser - - # No 64-bit Flash on Mac, so build the browser 32-bit - contains(QT_CONFIG, x86) { - CONFIG -= x86_64 - CONFIG += x86 - } - contains(QT_CONFIG, ppc) { - CONFIG -= ppc64 - CONFIG += ppc - } -} - -wince*: { - DEPLOYMENT_PLUGIN += qjpeg qgif } EXAMPLE_FILES = Info_mac.plist browser.icns browser.ico browser.rc diff --git a/examples/webenginewidgets/browser/data/defaultbookmarks.xbel b/examples/webenginewidgets/browser/data/defaultbookmarks.xbel index a981d2de2..65b0b8415 100644 --- a/examples/webenginewidgets/browser/data/defaultbookmarks.xbel +++ b/examples/webenginewidgets/browser/data/defaultbookmarks.xbel @@ -18,7 +18,7 @@ <bookmark href="http://qt-apps.org/"> <title>Qt-Apps.org</title> </bookmark> - <bookmark href="http://qt-project.org/wiki/OnlineCommunities/"> + <bookmark href="http://wiki.qt.io/?title=OnlineCommunities"> <title>Online Communities</title> </bookmark> <bookmark href="http://www.chromium.org/"> diff --git a/examples/webenginewidgets/fancybrowser/fancybrowser.pro b/examples/webenginewidgets/fancybrowser/fancybrowser.pro index 5f2db6ee3..e5dcd9678 100644 --- a/examples/webenginewidgets/fancybrowser/fancybrowser.pro +++ b/examples/webenginewidgets/fancybrowser/fancybrowser.pro @@ -1,7 +1,5 @@ QT += webenginewidgets -macx: CONFIG -= app_bundle - HEADERS = mainwindow.h SOURCES = main.cpp \ mainwindow.cpp diff --git a/src/3rdparty b/src/3rdparty -Subproject 888ff83e022e24a7f150116c9e5049847a091d3 +Subproject f3092dd031cffe3a6b5c41b868cad537df0f391 diff --git a/src/core/access_token_store_qt.cpp b/src/core/access_token_store_qt.cpp index b0bfd6ea2..b657a633a 100644 --- a/src/core/access_token_store_qt.cpp +++ b/src/core/access_token_store_qt.cpp @@ -50,6 +50,8 @@ #include "content_browser_client_qt.h" #include "web_engine_context.h" +namespace QtWebEngineCore { + using content::AccessTokenStore; using content::BrowserThread; @@ -84,3 +86,5 @@ void AccessTokenStoreQt::SaveAccessToken(const GURL& serverUrl, const base::stri { m_accessTokenSet[serverUrl] = accessToken; } + +} // namespace QtWebEngineCore diff --git a/src/core/access_token_store_qt.h b/src/core/access_token_store_qt.h index 2b47e8b03..6b8cfa2a2 100644 --- a/src/core/access_token_store_qt.h +++ b/src/core/access_token_store_qt.h @@ -48,6 +48,8 @@ namespace net { class URLRequestContextGetter; } +namespace QtWebEngineCore { + class AccessTokenStoreQt : public content::AccessTokenStore { public: AccessTokenStoreQt(); @@ -67,4 +69,6 @@ private: DISALLOW_COPY_AND_ASSIGN(AccessTokenStoreQt); }; +} // namespace QtWebEngineCore + #endif // ACCESS_TOKEN_STORE_QT_H diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index dfebbadfc..5b787b67d 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -38,8 +38,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef QT_NO_ACCESSIBILITY #include "browser_accessibility_qt.h" +#ifndef QT_NO_ACCESSIBILITY #include "third_party/WebKit/public/web/WebAXEnums.h" #include "ui/accessibility/ax_node_data.h" @@ -49,6 +49,7 @@ #include "type_conversion.h" using namespace blink; +using QtWebEngineCore::toQt; namespace content { diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h index 1311c1bf0..7d58f515e 100644 --- a/src/core/browser_accessibility_qt.h +++ b/src/core/browser_accessibility_qt.h @@ -36,9 +36,9 @@ #ifndef BROWSER_ACCESSIBILITY_QT_H #define BROWSER_ACCESSIBILITY_QT_H -#ifndef QT_NO_ACCESSIBILITY #include <QtGui/qaccessible.h> +#ifndef QT_NO_ACCESSIBILITY #include "content/browser/accessibility/browser_accessibility.h" namespace content { diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index f89e671c7..cb606a8b5 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -64,6 +64,8 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const } } +namespace QtWebEngineCore { + BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord) : m_offTheRecord(offTheRecord) , m_browserContext(new BrowserContextQt(this)) @@ -333,3 +335,5 @@ UserScriptControllerHost *BrowserContextAdapter::userScriptController() m_userScriptController.reset(new UserScriptControllerHost); return m_userScriptController.data(); } + +} // namespace QtWebEngineCore diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index 2a7c3465f..0e5a3605d 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -44,7 +44,10 @@ #include <QString> #include <QVector> +namespace QtWebEngineCore { + class BrowserContextAdapterClient; + class BrowserContextQt; class CustomUrlSchemeHandler; class DownloadManagerDelegateQt; @@ -147,4 +150,6 @@ private: Q_DISABLE_COPY(BrowserContextAdapter) }; +} // namespace QtWebEngineCore + #endif // BROWSER_CONTEXT_ADAPTER_H diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h index 1c61a3c6e..4a57b75c4 100644 --- a/src/core/browser_context_adapter_client.h +++ b/src/core/browser_context_adapter_client.h @@ -41,6 +41,8 @@ #include <QString> #include <QUrl> +namespace QtWebEngineCore { + class QWEBENGINE_EXPORT BrowserContextAdapterClient { public: @@ -73,4 +75,6 @@ public: virtual void downloadUpdated(const DownloadItemInfo &info) = 0; }; +} // namespace + #endif // BROWSER_CONTEXT_ADAPTER_CLIENT_H diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 13c23190c..3fa0f672d 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -48,6 +48,8 @@ #include "content/public/browser/storage_partition.h" #include "net/proxy/proxy_config_service.h" +namespace QtWebEngineCore { + BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) : m_adapter(adapter) { @@ -138,3 +140,5 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::Pr static_cast<ResourceContextQt*>(GetResourceContext())->set_url_request_context_getter(url_request_getter_.get()); return url_request_getter_.get(); } + +} // namespace QtWebEngineCore diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h index fb94ddf06..af36b55ab 100644 --- a/src/core/browser_context_qt.h +++ b/src/core/browser_context_qt.h @@ -44,6 +44,8 @@ #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE +namespace QtWebEngineCore { + class BrowserContextAdapter; class URLRequestContextGetterQt; @@ -83,4 +85,6 @@ private: DISALLOW_COPY_AND_ASSIGN(BrowserContextQt); }; +} // namespace QtWebEngineCore + #endif // BROWSER_CONTEXT_QT_H diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp index 4b89de043..3a95458ea 100644 --- a/src/core/certificate_error_controller.cpp +++ b/src/core/certificate_error_controller.cpp @@ -43,6 +43,10 @@ #include "chrome/grit/generated_resources.h" #include "type_conversion.h" +QT_BEGIN_NAMESPACE + +using namespace QtWebEngineCore; + void CertificateErrorControllerPrivate::accept(bool accepted) { callback.Run(accepted); @@ -154,3 +158,5 @@ QString CertificateErrorController::errorString() const return getQStringForMessageId(IDS_CERT_ERROR_UNKNOWN_ERROR_DESCRIPTION); } + +QT_END_NAMESPACE diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index a098fb0ad..bd76025ea 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -63,6 +63,7 @@ #include "ui/gfx/platform_font.h" #endif +namespace QtWebEngineCore { void GetScreenInfoFromNativeWindow(QWindow* window, blink::WebScreenInfo* results) { QScreen* screen = window->screen(); @@ -80,6 +81,8 @@ void GetScreenInfoFromNativeWindow(QWindow* window, blink::WebScreenInfo* result *results = r; } +} // namespace QtWebEngineCore + #if defined(USE_X11) XDisplay* GetQtXDisplay() { @@ -97,7 +100,7 @@ WebContentsView* CreateWebContentsView(WebContentsImpl *web_contents, WebContentsViewDelegate *, RenderViewHostDelegateView **render_view_host_delegate_view) { - WebContentsViewQt* rv = new WebContentsViewQt(web_contents); + QtWebEngineCore::WebContentsViewQt* rv = new QtWebEngineCore::WebContentsViewQt(web_contents); *render_view_host_delegate_view = rv; return rv; } @@ -105,10 +108,10 @@ WebContentsView* CreateWebContentsView(WebContentsImpl *web_contents, // static void RenderWidgetHostViewBase::GetDefaultScreenInfo(blink::WebScreenInfo* results) { QWindow dummy; - GetScreenInfoFromNativeWindow(&dummy, results); + QtWebEngineCore::GetScreenInfoFromNativeWindow(&dummy, results); } -} +} // namespace content #if defined(USE_AURA) && !defined(USE_OZONE) namespace content { diff --git a/src/core/chromium_overrides.h b/src/core/chromium_overrides.h index 9df4b1450..6787729ac 100644 --- a/src/core/chromium_overrides.h +++ b/src/core/chromium_overrides.h @@ -44,6 +44,8 @@ QT_BEGIN_NAMESPACE class QWindow; QT_END_NAMESPACE +namespace QtWebEngineCore { void GetScreenInfoFromNativeWindow(QWindow* window, blink::WebScreenInfo* results); +} #endif diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index 21ea457ce..f7ca9764d 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -51,6 +51,8 @@ #include <QImage> #include <QMimeData> +namespace QtWebEngineCore { + Q_GLOBAL_STATIC(ClipboardChangeObserver, clipboardChangeObserver) ClipboardChangeObserver::ClipboardChangeObserver() @@ -63,6 +65,10 @@ void ClipboardChangeObserver::trackChange(QClipboard::Mode mode) ++sequenceNumber[mode]; } +} // namespace QtWebEngineCore + +using namespace QtWebEngineCore; + namespace { const char kMimeTypeBitmap[] = "image/bmp"; @@ -188,6 +194,8 @@ bool Clipboard::FormatType::operator<(const FormatType& other) const } // namespace ui +namespace QtWebEngineCore { + void ClipboardQt::WriteObjects(ui::ClipboardType type, const ObjectMap& objects) { DCHECK(CalledOnValidThread()); @@ -358,4 +366,4 @@ uint64 ClipboardQt::GetSequenceNumber(ui::ClipboardType type) return clipboardChangeObserver()->getSequenceNumber(type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection); } - +} // namespace QtWebEngineCore diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index 0421f84fd..4c7e6ab59 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -43,6 +43,8 @@ #include <QMap> #include <QObject> +namespace QtWebEngineCore { + class ClipboardChangeObserver : public QObject { Q_OBJECT public: @@ -88,4 +90,6 @@ protected: virtual void WriteData(const FormatType& format, const char* data_data, size_t data_len) Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri index 500e04448..041b094a1 100644 --- a/src/core/config/desktop_linux.pri +++ b/src/core/config/desktop_linux.pri @@ -16,4 +16,6 @@ GYP_CONFIG += \ host_clang=0 \ clang=0 \ +contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1 + !contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0 diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 8d2541495..b0badde99 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -80,6 +80,8 @@ QT_BEGIN_NAMESPACE Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); QT_END_NAMESPACE +namespace QtWebEngineCore { + namespace { ContentBrowserClientQt* gBrowserClient = 0; // Owned by ContentMainDelegateQt. @@ -205,7 +207,7 @@ public: void PreMainMessageLoopStart() Q_DECL_OVERRIDE { - base::MessageLoop::InitMessagePumpForUIFactory(::messagePumpFactory); + base::MessageLoop::InitMessagePumpForUIFactory(messagePumpFactory); } void PreMainMessageLoopRun() Q_DECL_OVERRIDE @@ -447,3 +449,5 @@ content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDele { return new DevToolsManagerDelegateQt; } + +} // namespace QtWebEngineCore diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 77e3dbdb2..bce8f70e9 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -64,6 +64,7 @@ namespace gfx { class GLShareGroup; } +namespace QtWebEngineCore { class BrowserContextQt; class BrowserMainPartsQt; class ResourceDispatcherHostDelegateQt; @@ -120,4 +121,6 @@ private: scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick; }; +} // namespace QtWebEngineCore + #endif // CONTENT_BROWSER_CLIENT_QT_H diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 964de0086..20a8df75e 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -42,15 +42,17 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include <QCoreApplication> +#include <QStringBuilder> + +namespace QtWebEngineCore { + std::string ContentClientQt::getUserAgent() { // Mention the Chromium version we're based on to get passed stupid UA-string-based feature detection (several WebRTC demos need this) return content::BuildUserAgentFromProduct("QtWebEngine/" QTWEBENGINECORE_VERSION_STR " Chrome/" CHROMIUM_VERSION); } -#include <QCoreApplication> -#include <QStringBuilder> - base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const { return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor); } @@ -65,3 +67,5 @@ std::string ContentClientQt::GetProduct() const QString productName(qApp->applicationName() % '/' % qApp->applicationVersion()); return productName.toStdString(); } + +} // namespace QtWebEngineCore diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h index 041a829a9..f68282dcf 100644 --- a/src/core/content_client_qt.h +++ b/src/core/content_client_qt.h @@ -42,6 +42,8 @@ #include "ui/base/layout.h" #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE +namespace QtWebEngineCore { + class ContentClientQt : public content::ContentClient { public: static std::string getUserAgent(); @@ -52,4 +54,6 @@ public: virtual std::string GetProduct() const Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif // CONTENT_CLIENT_QT_H diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index f05229b81..b8e40a448 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -54,6 +54,8 @@ #include <QLocale> +namespace QtWebEngineCore { + static base::StringPiece PlatformResourceProvider(int key) { if (key == IDR_DIR_HEADER_HTML) { base::StringPiece html_data = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML); @@ -103,3 +105,4 @@ bool ContentMainDelegateQt::BasicStartupComplete(int *exit_code) return false; } +} // namespace QtWebEngineCore diff --git a/src/core/content_main_delegate_qt.h b/src/core/content_main_delegate_qt.h index cae21c0b5..f2f13d351 100644 --- a/src/core/content_main_delegate_qt.h +++ b/src/core/content_main_delegate_qt.h @@ -44,6 +44,7 @@ #include "content_browser_client_qt.h" +namespace QtWebEngineCore { class ContentMainDelegateQt : public content::ContentMainDelegate { @@ -62,4 +63,6 @@ private: scoped_ptr<ContentBrowserClientQt> m_browserClient; }; +} // namespace QtWebEngineCore + #endif // CONTENT_MAIN_DELEGATE_QT_H diff --git a/src/core/custom_protocol_handler.cpp b/src/core/custom_protocol_handler.cpp index fd8cebb9e..5deadf185 100644 --- a/src/core/custom_protocol_handler.cpp +++ b/src/core/custom_protocol_handler.cpp @@ -41,6 +41,8 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_error_job.h" +namespace QtWebEngineCore { + CustomProtocolHandler::CustomProtocolHandler(CustomUrlSchemeHandler *schemeHandler) : m_schemeHandler(schemeHandler) { @@ -53,3 +55,5 @@ net::URLRequestJob *CustomProtocolHandler::MaybeCreateJob(net::URLRequest *reque return new URLRequestCustomJob(request, networkDelegate, m_schemeHandler); } + +} // namespace diff --git a/src/core/custom_protocol_handler.h b/src/core/custom_protocol_handler.h index 4b29a82b7..923cac79d 100644 --- a/src/core/custom_protocol_handler.h +++ b/src/core/custom_protocol_handler.h @@ -44,9 +44,6 @@ #include <QtCore/QObject> #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE -class BrowserContextAdapter; -class CustomUrlSchemeHandler; - QT_FORWARD_DECLARE_CLASS(QIODevice) namespace net { @@ -54,6 +51,11 @@ class NetworkDelegate; class URLRequestJob; } // namespace +namespace QtWebEngineCore { + +class BrowserContextAdapter; +class CustomUrlSchemeHandler; + // Implements a ProtocolHandler for custom URL schemes. // If |network_delegate_| is NULL then all file requests will fail with ERR_ACCESS_DENIED. class QWEBENGINE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { @@ -68,4 +70,6 @@ private: CustomUrlSchemeHandler *m_schemeHandler; }; +} // namespace + #endif // CUSTOM_PROTOCOL_HANDLER_H_ diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp index edc8000c9..591cad32e 100644 --- a/src/core/custom_url_scheme_handler.cpp +++ b/src/core/custom_url_scheme_handler.cpp @@ -37,6 +37,8 @@ #include "custom_url_scheme_handler.h" #include "custom_protocol_handler.h" +namespace QtWebEngineCore { + CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme) : m_scheme(scheme) { @@ -61,3 +63,5 @@ CustomProtocolHandler *CustomUrlSchemeHandler::createProtocolHandler() // Will be owned by the JobFactory. return new CustomProtocolHandler(this); } + +} // namespace diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h index dbcdf2a60..0079095d8 100644 --- a/src/core/custom_url_scheme_handler.h +++ b/src/core/custom_url_scheme_handler.h @@ -42,12 +42,14 @@ #include <QtCore/QByteArray> #include <QtCore/QScopedPointer> +QT_FORWARD_DECLARE_CLASS(QIODevice) + +namespace QtWebEngineCore { + class BrowserContextAdapter; class CustomProtocolHandler; class URLRequestCustomJobDelegate; -QT_FORWARD_DECLARE_CLASS(QIODevice) - class QWEBENGINE_EXPORT CustomUrlSchemeHandler { public: explicit CustomUrlSchemeHandler(const QByteArray &); @@ -63,4 +65,7 @@ private: QByteArray m_scheme; }; + +} // namespace + #endif // CUSTOM_URL_SCHEME_HANDLER_H_ diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 6731a6a0d..6f79d4952 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -76,6 +76,8 @@ #include <EGL/eglext.h> #endif +namespace QtWebEngineCore { + class MailboxTexture : public QSGTexture, protected QOpenGLFunctions { public: MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QSize textureSize); @@ -708,3 +710,4 @@ void DelegatedFrameNode::syncPointRetired(DelegatedFrameNode *frameNode, QList<M base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::fetchTexturesAndUnlockQt, frameNode, mailboxesToFetch)); } +} // namespace QtWebEngineCore diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h index 5b361e99d..60a1535d2 100644 --- a/src/core/delegated_frame_node.h +++ b/src/core/delegated_frame_node.h @@ -57,6 +57,8 @@ namespace cc { class DelegatedFrameData; } +namespace QtWebEngineCore { + class MailboxTexture; class ResourceHolder; @@ -98,4 +100,6 @@ private: QMutex m_mutex; }; +} // namespace QtWebEngineCore + #endif // DELEGATED_FRAME_NODE_H diff --git a/src/core/desktop_screen_qt.cpp b/src/core/desktop_screen_qt.cpp index fa1835afb..6469ad8c2 100644 --- a/src/core/desktop_screen_qt.cpp +++ b/src/core/desktop_screen_qt.cpp @@ -36,6 +36,8 @@ #include "desktop_screen_qt.h" +namespace QtWebEngineCore { + gfx::Point DesktopScreenQt::GetCursorScreenPoint() { Q_UNREACHABLE(); @@ -98,3 +100,5 @@ void DesktopScreenQt::RemoveObserver(gfx::DisplayObserver* observer) { Q_UNREACHABLE(); } + +} // namespace QtWebEngineCore diff --git a/src/core/desktop_screen_qt.h b/src/core/desktop_screen_qt.h index 84397f998..c9768d940 100644 --- a/src/core/desktop_screen_qt.h +++ b/src/core/desktop_screen_qt.h @@ -41,6 +41,8 @@ #include <QtGlobal> +namespace QtWebEngineCore { + class DesktopScreenQt : public gfx::Screen { public: // Overridden from gfx::Screen: @@ -57,4 +59,6 @@ public: virtual void RemoveObserver(gfx::DisplayObserver* observer) Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif // DESKTOP_SCREEN_QT_H diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp index 8a70c3e10..964d6ad38 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/dev_tools_http_handler_delegate_qt.cpp @@ -143,6 +143,8 @@ bool Target::Close() const { } // namespace +namespace QtWebEngineCore { + DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt() : m_devtoolsHttpHandler(0) , m_bindAddress(QLatin1String("127.0.0.1")) @@ -238,3 +240,5 @@ void DevToolsManagerDelegateQt::EnumerateTargets(TargetCallback callback) } callback.Run(targets); } + +} //namespace QtWebEngineCore diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h index ec934ce35..902e99507 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ b/src/core/dev_tools_http_handler_delegate_qt.h @@ -53,6 +53,8 @@ class DevToolsHttpHandler; class RenderViewHost; } +namespace QtWebEngineCore { + class DevToolsHttpHandlerDelegateQt : public content::DevToolsHttpHandlerDelegate { public: @@ -84,4 +86,6 @@ public: std::string GetPageThumbnailData(const GURL &url) Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif // DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 40b17da76..e84ca5f2c 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -53,6 +53,8 @@ #include "type_conversion.h" #include "qtwebenginecoreglobal.h" +namespace QtWebEngineCore { + ASSERT_ENUMS_MATCH(content::DownloadItem::IN_PROGRESS, BrowserContextAdapterClient::DownloadInProgress) ASSERT_ENUMS_MATCH(content::DownloadItem::COMPLETE, BrowserContextAdapterClient::DownloadCompleted) ASSERT_ENUMS_MATCH(content::DownloadItem::CANCELLED, BrowserContextAdapterClient::DownloadCancelled) @@ -190,3 +192,5 @@ void DownloadManagerDelegateQt::OnDownloadDestroyed(content::DownloadItem *downl download->RemoveObserver(this); download->Cancel(/* user_cancel */ false); } + +} // namespace QtWebEngineCore diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h index a2511fce7..fea965749 100644 --- a/src/core/download_manager_delegate_qt.h +++ b/src/core/download_manager_delegate_qt.h @@ -51,8 +51,11 @@ class DownloadItem; class WebContents; } +namespace QtWebEngineCore { class BrowserContextAdapter; class DownloadManagerDelegateInstance; +class DownloadTargetHelper; + class DownloadManagerDelegateQt : public content::DownloadManagerDelegate , public content::DownloadItem::Observer @@ -86,4 +89,6 @@ private: DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt); }; +} // namespace QtWebEngineCore + #endif //DOWNLOAD_MANAGER_DELEGATE_QT_H diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index df09c2101..0fe6afdcf 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -44,6 +44,8 @@ #include <QVariant> #include <QStringList> +namespace QtWebEngineCore { + FilePickerController::FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject *parent) : QObject(parent) , m_acceptedMimeTypes(acceptedMimeTypes) @@ -116,3 +118,5 @@ QString FilePickerController::defaultFileName() { return m_defaultFileName; } + +} // namespace diff --git a/src/core/file_picker_controller.h b/src/core/file_picker_controller.h index 045134b30..851dec174 100644 --- a/src/core/file_picker_controller.h +++ b/src/core/file_picker_controller.h @@ -37,12 +37,14 @@ #ifndef FILE_PICKER_CONTROLLER_H #define FILE_PICKER_CONTROLLER_H +#include "qtwebenginecoreglobal.h" +#include <QObject> + namespace content { class WebContents; } -#include "qtwebenginecoreglobal.h" -#include <QObject> +namespace QtWebEngineCore { class QWEBENGINE_EXPORT FilePickerController : public QObject { Q_OBJECT @@ -74,4 +76,6 @@ private: }; +} // namespace + #endif // FILE_PICKER_CONTROLLER_H diff --git a/src/core/javascript_dialog_controller.cpp b/src/core/javascript_dialog_controller.cpp index 43ed262b5..c87a61405 100644 --- a/src/core/javascript_dialog_controller.cpp +++ b/src/core/javascript_dialog_controller.cpp @@ -40,6 +40,8 @@ #include"javascript_dialog_manager_qt.h" #include "type_conversion.h" +namespace QtWebEngineCore { + void JavaScriptDialogControllerPrivate::dialogFinished(bool accepted, const base::string16 &promptValue) { // Clear the queue first as this could result in the engine asking us to run another dialog, @@ -111,3 +113,5 @@ JavaScriptDialogController::JavaScriptDialogController(JavaScriptDialogControlle Q_ASSERT(dd); d.reset(dd); } + +} // namespace QtWebEngineCore diff --git a/src/core/javascript_dialog_controller.h b/src/core/javascript_dialog_controller.h index c7eab8f2a..8e1f86cd1 100644 --- a/src/core/javascript_dialog_controller.h +++ b/src/core/javascript_dialog_controller.h @@ -41,6 +41,8 @@ QT_FORWARD_DECLARE_CLASS(QString) +namespace QtWebEngineCore { + class JavaScriptDialogControllerPrivate; class QWEBENGINE_EXPORT JavaScriptDialogController : public QObject { @@ -68,4 +70,6 @@ private: friend class JavaScriptDialogManagerQt; }; +} // namespace QtWebEngineCore + #endif // JAVASCRIPT_DIALOG_CONTROLLER_H diff --git a/src/core/javascript_dialog_controller_p.h b/src/core/javascript_dialog_controller_p.h index 670aeaa12..504c5783e 100644 --- a/src/core/javascript_dialog_controller_p.h +++ b/src/core/javascript_dialog_controller_p.h @@ -45,6 +45,8 @@ namespace content { class WebContents; } +namespace QtWebEngineCore { + class JavaScriptDialogControllerPrivate { public: @@ -63,4 +65,6 @@ public: content::WebContents *contents; }; +} // namespace QtWebEngineCore + #endif // JAVASCRIPT_DIALOG_CONTROLLER_P_H diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp index 603dae90f..fdcd7bdbc 100644 --- a/src/core/javascript_dialog_manager_qt.cpp +++ b/src/core/javascript_dialog_manager_qt.cpp @@ -43,6 +43,8 @@ #include "base/memory/singleton.h" +namespace QtWebEngineCore { + Q_STATIC_ASSERT_X(static_cast<int>(content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) == static_cast<int>(WebContentsAdapterClient::PromptDialog), "These enums should be in sync."); JavaScriptDialogManagerQt *JavaScriptDialogManagerQt::GetInstance() @@ -101,3 +103,5 @@ QSharedPointer<JavaScriptDialogController> JavaScriptDialogManagerQt::takeDialog Q_EMIT dialog->dialogCloseRequested(); return dialog; } + +} // namespace QtWebEngineCore diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h index e9b72d212..4682ce5b8 100644 --- a/src/core/javascript_dialog_manager_qt.h +++ b/src/core/javascript_dialog_manager_qt.h @@ -45,11 +45,13 @@ #include <QMap> #include <QSharedPointer> -class JavaScriptDialogController; namespace content { class WebContents; } +namespace QtWebEngineCore { +class JavaScriptDialogController; + class JavaScriptDialogManagerQt : public content::JavaScriptDialogManager { public: @@ -76,5 +78,7 @@ private: }; +} // namespace QtWebEngineCore + #endif // JAVASCRIPT_DIALOG_MANAGER_QT_H diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp index a19ffa644..e33179412 100644 --- a/src/core/location_provider_qt.cpp +++ b/src/core/location_provider_qt.cpp @@ -50,6 +50,8 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/geolocation_provider.h" +namespace QtWebEngineCore { + using content::BrowserThread; class QtPositioningHelper : public QObject { @@ -189,8 +191,6 @@ inline void QtPositioningHelper::postToLocationProvider(const base::Closure &tas LocationProviderQt::messageLoop()->PostTask(FROM_HERE, task); } -#include "location_provider_qt.moc" - LocationProviderQt::LocationProviderQt() : m_positioningHelper(0) { @@ -246,3 +246,7 @@ base::MessageLoop *LocationProviderQt::messageLoop() { return static_cast<content::GeolocationProviderImpl*>(content::GeolocationProvider::GetInstance())->message_loop(); } + +} // namespace QtWebEngineCore + +#include "location_provider_qt.moc" diff --git a/src/core/location_provider_qt.h b/src/core/location_provider_qt.h index facf4b769..15b2e0520 100644 --- a/src/core/location_provider_qt.h +++ b/src/core/location_provider_qt.h @@ -43,12 +43,14 @@ #include "content/public/common/geoposition.h" QT_FORWARD_DECLARE_CLASS(QThread) -class QtPositioningHelper; namespace base { class MessageLoop; } +namespace QtWebEngineCore { +class QtPositioningHelper; + class LocationProviderQt : public content::LocationProviderBase { public: @@ -73,4 +75,6 @@ private: }; //#define QT_USE_POSITIONING 1 +} // namespace QtWebEngineCore + #endif // LOCATION_PROVIDER_QT_H diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 55dd9a996..6866afc41 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -58,6 +58,8 @@ #include "media/audio/audio_manager_base.h" #include "ui/base/l10n/l10n_util.h" +namespace QtWebEngineCore { + using content::BrowserThread; using content::MediaStreamDevices; @@ -455,3 +457,5 @@ void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render } } } + +} // namespace QtWebEngineCore diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h index d91c646f1..500fe7644 100644 --- a/src/core/media_capture_devices_dispatcher.h +++ b/src/core/media_capture_devices_dispatcher.h @@ -57,6 +57,8 @@ class DesktopStreamsRegistry; +namespace QtWebEngineCore { + // This singleton is used to receive updates about media events from the content // layer. Based on Chrome's implementation. class MediaCaptureDevicesDispatcher : public content::MediaObserver, @@ -131,4 +133,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver, DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); }; +} // namespace QtWebEngineCore + #endif // MEDIA_CAPTURE_DEVICES_DISPATCHER_H diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp index 3ea8bd286..4e726fec8 100644 --- a/src/core/network_delegate_qt.cpp +++ b/src/core/network_delegate_qt.cpp @@ -47,7 +47,7 @@ #include "web_contents_adapter_client.h" #include "web_contents_view_qt.h" -namespace { +namespace QtWebEngineCore { int pageTransitionToNavigationType(ui::PageTransition transition) { @@ -72,8 +72,6 @@ int pageTransitionToNavigationType(ui::PageTransition transition) } } -} - int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::CompletionCallback &callback, GURL *) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); @@ -173,3 +171,5 @@ void NetworkDelegateQt::NotifyNavigationRequestedOnUIThread(net::URLRequest *req callback) ); } + +} // namespace QtWebEngineCore diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h index bda905025..4f4097fd3 100644 --- a/src/core/network_delegate_qt.h +++ b/src/core/network_delegate_qt.h @@ -44,6 +44,8 @@ #include <QSet> #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE +namespace QtWebEngineCore { + class NetworkDelegateQt : public net::NetworkDelegate { public: NetworkDelegateQt() {} @@ -73,4 +75,6 @@ public: QSet<net::URLRequest *> m_activeRequests; }; +} // namespace QtWebEngineCore + #endif // NETWORK_DELEGATE_QT_H diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp index f646ac2a6..43a3e4a11 100644 --- a/src/core/ozone_platform_eglfs.cpp +++ b/src/core/ozone_platform_eglfs.cpp @@ -175,7 +175,7 @@ void OzonePlatformEglfs::InitializeUI() { } void OzonePlatformEglfs::InitializeGPU() { - surface_factory_ozone_.reset(new SurfaceFactoryQt()); + surface_factory_ozone_.reset(new QtWebEngineCore::SurfaceFactoryQt()); gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); } diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h index 2371bb1e8..6954595dd 100644 --- a/src/core/ozone_platform_eglfs.h +++ b/src/core/ozone_platform_eglfs.h @@ -68,7 +68,7 @@ class OzonePlatformEglfs : public OzonePlatform { virtual void InitializeGPU() override; scoped_ptr<DeviceManager> device_manager_; - scoped_ptr<SurfaceFactoryQt> surface_factory_ozone_; + scoped_ptr<QtWebEngineCore::SurfaceFactoryQt> surface_factory_ozone_; scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; scoped_ptr<EventFactoryEvdev> event_factory_ozone_; diff --git a/src/core/process_main.cpp b/src/core/process_main.cpp index 457d7d838..1a67417fb 100644 --- a/src/core/process_main.cpp +++ b/src/core/process_main.cpp @@ -47,7 +47,7 @@ namespace QtWebEngine { int processMain(int argc, const char **argv) { - ContentMainDelegateQt delegate; + QtWebEngineCore::ContentMainDelegateQt delegate; content::ContentMainParams params(&delegate); #if defined(OS_WIN) @@ -64,4 +64,4 @@ int processMain(int argc, const char **argv) return content::ContentMain(params); } -} +} // namespace diff --git a/src/core/process_main.h b/src/core/process_main.h index 0ab823bd6..507d4a844 100644 --- a/src/core/process_main.h +++ b/src/core/process_main.h @@ -40,4 +40,4 @@ namespace QtWebEngine { QWEBENGINE_EXPORT int processMain(int argc, const char **argv); -} +} // namespace diff --git a/src/core/qrc_protocol_handler_qt.cpp b/src/core/qrc_protocol_handler_qt.cpp index d9e191fdb..d1c1ee4b2 100644 --- a/src/core/qrc_protocol_handler_qt.cpp +++ b/src/core/qrc_protocol_handler_qt.cpp @@ -41,16 +41,18 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_error_job.h" -using namespace net; +namespace QtWebEngineCore { QrcProtocolHandlerQt::QrcProtocolHandlerQt() { } -URLRequestJob *QrcProtocolHandlerQt::MaybeCreateJob(URLRequest *request, NetworkDelegate *networkDelegate) const +net::URLRequestJob *QrcProtocolHandlerQt::MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const { if (!networkDelegate) - return new URLRequestErrorJob(request, Q_NULLPTR, ERR_ACCESS_DENIED); + return new net::URLRequestErrorJob(request, Q_NULLPTR, net::ERR_ACCESS_DENIED); return new URLRequestQrcJobQt(request, networkDelegate); } + +} // namespace QtWebEngineCore diff --git a/src/core/qrc_protocol_handler_qt.h b/src/core/qrc_protocol_handler_qt.h index 3d33ee277..ff44bd970 100644 --- a/src/core/qrc_protocol_handler_qt.h +++ b/src/core/qrc_protocol_handler_qt.h @@ -48,6 +48,8 @@ class URLRequestJob; } // namespace +namespace QtWebEngineCore { + // Implements a ProtocolHandler for qrc file jobs. If |network_delegate_| is NULL, // then all file requests will fail with ERR_ACCESS_DENIED. class QrcProtocolHandlerQt : public net::URLRequestJobFactory::ProtocolHandler { @@ -60,4 +62,6 @@ private: DISALLOW_COPY_AND_ASSIGN(QrcProtocolHandlerQt); }; +} // namespace QtWebEngineCore + #endif // QRC_PROTOCOL_HANDLER_QT_H_ diff --git a/src/core/qt_render_view_observer_host.cpp b/src/core/qt_render_view_observer_host.cpp index 741bd4037..97d001ed6 100644 --- a/src/core/qt_render_view_observer_host.cpp +++ b/src/core/qt_render_view_observer_host.cpp @@ -42,6 +42,8 @@ #include "type_conversion.h" #include "web_contents_adapter_client.h" +namespace QtWebEngineCore { + QtRenderViewObserverHost::QtRenderViewObserverHost(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) : content::WebContentsObserver(webContents) , m_adapterClient(adapterClient) @@ -90,3 +92,5 @@ void QtRenderViewObserverHost::onDidFirstVisuallyNonEmptyLayout() if (rwhv) rwhv->didFirstVisuallyNonEmptyLayout(); } + +} // namespace QtWebEngineCore diff --git a/src/core/qt_render_view_observer_host.h b/src/core/qt_render_view_observer_host.h index 203cfcf61..148fcb9da 100644 --- a/src/core/qt_render_view_observer_host.h +++ b/src/core/qt_render_view_observer_host.h @@ -45,6 +45,8 @@ namespace content { class WebContents; } +namespace QtWebEngineCore { + class WebContentsAdapterClient; class QtRenderViewObserverHost : public content::WebContentsObserver @@ -63,4 +65,6 @@ private: WebContentsAdapterClient *m_adapterClient; }; +} // namespace QtWebEngineCore + #endif // QT_RENDER_VIEW_OBSERVER_HOST_H diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 8be7c5d42..78fcce2d5 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -79,6 +79,8 @@ #include <QWindow> #include <QtGui/qaccessible.h> +namespace QtWebEngineCore { + static inline ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) { ui::LatencyInfo latency_info; // The latency number should only be added if the timestamp is valid. @@ -1050,3 +1052,5 @@ void RenderWidgetHostViewQt::didFirstVisuallyNonEmptyLayout() { m_didFirstVisuallyNonEmptyLayout = true; } + +} // namespace QtWebEngineCore diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index ba2dcb557..19b551b71 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -73,6 +73,8 @@ namespace content { class RenderWidgetHostImpl; } +namespace QtWebEngineCore { + struct MultipleMouseClickHelper { QPoint lastPressPosition; @@ -240,4 +242,6 @@ private: gfx::Vector2dF m_lastScrollOffset; }; +} // namespace QtWebEngineCore + #endif // RENDER_WIDGET_HOST_VIEW_QT_H diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h index 1aae6bed8..a12f3055e 100644 --- a/src/core/render_widget_host_view_qt_delegate.h +++ b/src/core/render_widget_host_view_qt_delegate.h @@ -55,6 +55,8 @@ class QWindow; class QInputMethodEvent; QT_END_NAMESPACE +namespace QtWebEngineCore { + class WebContentsAdapterClient; class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegateClient { @@ -94,4 +96,6 @@ public: virtual void setTooltip(const QString &) = 0; }; +} // namespace QtWebEngineCore + #endif // RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 242c8ef6d..e1333144a 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -56,6 +56,8 @@ #include "grit/renderer_resources.h" +namespace QtWebEngineCore { + static const char kHttpErrorDomain[] = "http"; ContentRendererClientQt::ContentRendererClientQt() @@ -139,3 +141,5 @@ bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash) { return m_visitedLinkSlave->IsVisited(linkHash); } + +} // namespace diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index 0a89e050d..dcb4e7fcb 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -45,6 +45,8 @@ namespace visitedlink { class VisitedLinkSlave; } +namespace QtWebEngineCore { + class ContentRendererClientQt : public content::ContentRendererClient { public: ContentRendererClientQt(); @@ -64,4 +66,6 @@ private: QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; }; +} // namespace + #endif // CONTENT_RENDERER_CLIENT_QT_H diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index ebebb01e9..3d844bf0d 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -48,6 +48,8 @@ #include <QJsonDocument> +namespace QtWebEngineCore { + static const char kWebChannelTransportExtensionName[] = "v8/WebChannelTransport"; static const char kWebChannelTransportApi[] = @@ -173,3 +175,5 @@ bool WebChannelIPCTransport::OnMessageReceived(const IPC::Message &message) IPC_END_MESSAGE_MAP() return handled; } + +} // namespace diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h index 8074c2302..69a02f7ea 100644 --- a/src/core/renderer/web_channel_ipc_transport.h +++ b/src/core/renderer/web_channel_ipc_transport.h @@ -45,6 +45,8 @@ namespace v8 { class Extension; } +namespace QtWebEngineCore { + class WebChannelIPCTransport : public content::RenderViewObserver { public: static v8::Extension* getV8Extension(); @@ -56,4 +58,6 @@ private: virtual bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE; }; +} // namespace + #endif // WEB_CHANNEL_IPC_TRANSPORT diff --git a/src/core/resource_context_qt.cpp b/src/core/resource_context_qt.cpp index 04ab4715a..acd8ba4b9 100644 --- a/src/core/resource_context_qt.cpp +++ b/src/core/resource_context_qt.cpp @@ -40,6 +40,8 @@ #include "browser_context_qt.h" +namespace QtWebEngineCore { + net::HostResolver *ResourceContextQt::GetHostResolver() { CHECK(getter_); @@ -57,3 +59,5 @@ void ResourceContextQt::set_url_request_context_getter(net::URLRequestContextGet { getter_ = getter; } + +} // namespace QtWebEngineCore diff --git a/src/core/resource_context_qt.h b/src/core/resource_context_qt.h index c0bbbe4c4..48dc3d583 100644 --- a/src/core/resource_context_qt.h +++ b/src/core/resource_context_qt.h @@ -45,9 +45,11 @@ namespace net { class URLRequestContextGetter; } -class BrowserContextQt; class GURL; +namespace QtWebEngineCore { +class BrowserContextQt; + class ResourceContextQt : public content::ResourceContext { public: @@ -69,4 +71,6 @@ private: DISALLOW_COPY_AND_ASSIGN(ResourceContextQt); }; +} // namespace QtWebEngineCore + #endif // RESOURCE_CONTEXT_QT_H diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp index fe7df996a..faed58954 100644 --- a/src/core/resource_dispatcher_host_delegate_qt.cpp +++ b/src/core/resource_dispatcher_host_delegate_qt.cpp @@ -49,6 +49,8 @@ #include "type_conversion.h" #include "web_contents_view_qt.h" +namespace QtWebEngineCore { + ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request) : m_request(request) { @@ -116,3 +118,5 @@ content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt:: // ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest. return new ResourceDispatcherHostLoginDelegateQt(authInfo, request); } + +} // namespace QtWebEngineCore diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h index 7395ec351..2cba210d3 100644 --- a/src/core/resource_dispatcher_host_delegate_qt.h +++ b/src/core/resource_dispatcher_host_delegate_qt.h @@ -42,6 +42,8 @@ #include "web_contents_adapter_client.h" +namespace QtWebEngineCore { + class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate { public: ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request); @@ -72,4 +74,6 @@ public: virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif // RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp index 14e46b946..963f7b517 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/surface_factory_qt.cpp @@ -55,6 +55,8 @@ #define QT_LIBDIR_GLES2 QT_LIBDIR_EGL #endif +namespace QtWebEngineCore { + base::NativeLibrary LoadLibrary(const base::FilePath& filename) { base::NativeLibraryLoadError error; base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); @@ -73,13 +75,13 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library, Q_UNREACHABLE(); return false; #else - base::FilePath libEGLPath = toFilePath(QT_LIBDIR_EGL); + base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL); libEGLPath = libEGLPath.Append("libEGL.so"); base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath); if (!eglLibrary) return false; - base::FilePath libGLES2Path = toFilePath(QT_LIBDIR_GLES2); + base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2); libGLES2Path = libGLES2Path.Append("libGLESv2.so"); base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path); if (!gles2Library) @@ -110,5 +112,7 @@ intptr_t SurfaceFactoryQt::GetNativeDisplay() return reinterpret_cast<intptr_t>(EGL_DEFAULT_DISPLAY); } +} // namespace QtWebEngineCore + #endif // defined(USE_OZONE) || defined(OS_ANDROID) diff --git a/src/core/surface_factory_qt.h b/src/core/surface_factory_qt.h index bd4eba3c9..7d6f0435e 100644 --- a/src/core/surface_factory_qt.h +++ b/src/core/surface_factory_qt.h @@ -43,6 +43,8 @@ #include <QtGlobal> +namespace QtWebEngineCore { + class SurfaceFactoryQt : public ui::SurfaceFactoryOzone { @@ -50,6 +52,8 @@ class SurfaceFactoryQt virtual intptr_t GetNativeDisplay() Q_DECL_OVERRIDE; }; +} // namespace QtWebEngineCore + #endif // defined(USE_OZONE) || defined(OS_ANDROID) #endif // SURFACE_FACTORY_QT diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index 0e34c68e6..66fcd4dd0 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -52,6 +52,8 @@ #include "ui/gfx/rect.h" #include "url/gurl.h" +namespace QtWebEngineCore { + inline QString toQt(const base::string16 &string) { #if defined(OS_WIN) @@ -191,4 +193,6 @@ inline std::vector<T> toVector(const QStringList &fileList) return selectedFiles; } +} // namespace QtWebEngineCore + #endif // TYPE_CONVERSION_H diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 2536e9ddb..dec6b4dbb 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -69,6 +69,8 @@ #include "qrc_protocol_handler_qt.h" #include "type_conversion.h" +namespace QtWebEngineCore { + static const char kQrcSchemeQt[] = "qrc"; using content::BrowserThread; @@ -295,3 +297,5 @@ scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetterQt::GetNetwor { return content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO); } + +} // namespace QtWebEngineCore diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index 8e8d91596..d08836714 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -57,6 +57,8 @@ class NetworkDelegate; class ProxyConfigService; } +namespace QtWebEngineCore { + class BrowserContextAdapter; class URLRequestContextGetterQt : public net::URLRequestContextGetter { @@ -95,4 +97,6 @@ private: scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory; }; +} // namespace QtWebEngineCore + #endif // URL_REQUEST_CONTEXT_GETTER_QT_H diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp index f206955f1..105f90746 100644 --- a/src/core/url_request_custom_job.cpp +++ b/src/core/url_request_custom_job.cpp @@ -51,6 +51,8 @@ using namespace net; +namespace QtWebEngineCore { + URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, CustomUrlSchemeHandler *schemeHandler) : URLRequestJob(request, networkDelegate) , m_device(0) @@ -141,3 +143,5 @@ void URLRequestCustomJob::startAsync() m_delegate.reset(new URLRequestCustomJobDelegate(this)); m_schemeHandler->handleJob(m_delegate.get()); } + +} // namespace diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h index c47358e71..448bfe6af 100644 --- a/src/core/url_request_custom_job.h +++ b/src/core/url_request_custom_job.h @@ -44,6 +44,8 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) +namespace QtWebEngineCore { + class CustomUrlSchemeHandler; class URLRequestCustomJobDelegate; @@ -77,4 +79,6 @@ private: DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob); }; +} // namespace QtWebEngineCore + #endif // URL_REQUEST_CUSTOM_JOB_H_ diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp index fcb2220bc..d324da347 100644 --- a/src/core/url_request_custom_job_delegate.cpp +++ b/src/core/url_request_custom_job_delegate.cpp @@ -41,6 +41,8 @@ #include <QByteArray> +namespace QtWebEngineCore { + URLRequestCustomJobDelegate::URLRequestCustomJobDelegate(URLRequestCustomJob *job) : m_job(job) { @@ -61,3 +63,4 @@ void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODev m_job->setReplyDevice(device); } +} // namespace diff --git a/src/core/url_request_custom_job_delegate.h b/src/core/url_request_custom_job_delegate.h index e82debdf2..e0b802897 100644 --- a/src/core/url_request_custom_job_delegate.h +++ b/src/core/url_request_custom_job_delegate.h @@ -44,6 +44,8 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) +namespace QtWebEngineCore { + class URLRequestCustomJob; class QWEBENGINE_EXPORT URLRequestCustomJobDelegate : public QObject { @@ -62,4 +64,6 @@ private: URLRequestCustomJob *m_job; }; +} // namespace + #endif // URL_REQUEST_CUSTOM_JOB_DELEGATE_H_ diff --git a/src/core/url_request_qrc_job_qt.cpp b/src/core/url_request_qrc_job_qt.cpp index bd6875895..617b894ea 100644 --- a/src/core/url_request_qrc_job_qt.cpp +++ b/src/core/url_request_qrc_job_qt.cpp @@ -47,6 +47,7 @@ #include <QMimeType> using namespace net; +namespace QtWebEngineCore { URLRequestQrcJobQt::URLRequestQrcJobQt(URLRequest *request, NetworkDelegate *networkDelegate) : URLRequestJob(request, networkDelegate) @@ -127,3 +128,5 @@ void URLRequestQrcJobQt::startGetHead() NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, ERR_INVALID_URL)); } } + +} // namespace QtWebEngineCore diff --git a/src/core/url_request_qrc_job_qt.h b/src/core/url_request_qrc_job_qt.h index 973b7731a..cd8362574 100644 --- a/src/core/url_request_qrc_job_qt.h +++ b/src/core/url_request_qrc_job_qt.h @@ -43,6 +43,8 @@ #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE #include <QFile> +namespace QtWebEngineCore { + // A request job that handles reading qrc file URLs class URLRequestQrcJobQt : public net::URLRequestJob { @@ -67,4 +69,6 @@ private: DISALLOW_COPY_AND_ASSIGN(URLRequestQrcJobQt); }; +} // namespace QtWebEngineCore + #endif // URL_REQUEST_QRC_JOB_QT_H_ diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp index 7e88f9223..39da059d7 100644 --- a/src/core/user_script.cpp +++ b/src/core/user_script.cpp @@ -39,6 +39,8 @@ #include "user_script_controller_host.h" #include "type_conversion.h" +namespace QtWebEngineCore { + ASSERT_ENUMS_MATCH(UserScript::AfterLoad, UserScriptData::AfterLoad) ASSERT_ENUMS_MATCH(UserScript::DocumentLoadFinished, UserScriptData::DocumentLoadFinished) ASSERT_ENUMS_MATCH(UserScript::DocumentElementCreation, UserScriptData::DocumentElementCreation) @@ -95,14 +97,14 @@ void UserScript::setName(const QString &name) scriptData->url = GURL(QStringLiteral("userScript:%1").arg(name).toStdString()); } -QString UserScript::source() const +QString UserScript::sourceCode() const { if (isNull()) return QString(); return toQt(scriptData->source); } -void UserScript::setSource(const QString &source) +void UserScript::setSourceCode(const QString &source) { initData(); scriptData->source = source.toStdString(); @@ -156,7 +158,7 @@ bool UserScript::operator==(const UserScript &other) const return worldId() == other.worldId() && runsOnSubFrames() == other.runsOnSubFrames() && injectionPoint() == other.injectionPoint() - && name() == other.name() && source() == other.source(); + && name() == other.name() && sourceCode() == other.sourceCode(); } void UserScript::initData() @@ -175,11 +177,15 @@ UserScriptData &UserScript::data() const return *(scriptData.data()); } -uint qHash(const UserScript &script, uint seed) +} // namespace QtWebEngineCore + +QT_BEGIN_NAMESPACE +uint qHash(const QtWebEngineCore::UserScript &script, uint seed) { if (script.isNull()) return 0; - return qHash(script.source(), seed) ^ qHash(script.name(), seed) + return qHash(script.sourceCode(), seed) ^ qHash(script.name(), seed) ^ (script.injectionPoint() | (script.runsOnSubFrames() << 4)) ^ script.worldId(); } +QT_END_NAMESPACE diff --git a/src/core/user_script.h b/src/core/user_script.h index 17de212ea..7aeba9131 100644 --- a/src/core/user_script.h +++ b/src/core/user_script.h @@ -44,9 +44,12 @@ #include <QtCore/QSharedData> #include <QtCore/QString> -class UserScriptControllerHost; struct UserScriptData; +namespace QtWebEngineCore { + +class UserScriptControllerHost; + class QWEBENGINE_EXPORT UserScript : public QSharedData { public: enum InjectionPoint { @@ -65,8 +68,8 @@ public: QString name() const; void setName(const QString &); - QString source() const; - void setSource(const QString &); + QString sourceCode() const; + void setSourceCode(const QString &); InjectionPoint injectionPoint() const; void setInjectionPoint(InjectionPoint); @@ -88,6 +91,10 @@ private: QString m_name; }; -uint qHash(const UserScript &, uint seed = 0); +} // namespace QtWebEngineCore + +QT_BEGIN_NAMESPACE +uint qHash(const QtWebEngineCore::UserScript &, uint seed = 0); +QT_END_NAMESPACE #endif // USER_SCRIPT_H diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp index bf1248577..69284dbe1 100644 --- a/src/core/user_script_controller_host.cpp +++ b/src/core/user_script_controller_host.cpp @@ -47,6 +47,8 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" +namespace QtWebEngineCore { + class UserScriptControllerHost::WebContentsObserverHelper : public content::WebContentsObserver { public: WebContentsObserverHelper(UserScriptControllerHost *, content::WebContents *); @@ -206,3 +208,5 @@ UserScriptControllerHost::UserScriptControllerHost() UserScriptControllerHost::~UserScriptControllerHost() { } + +} // namespace diff --git a/src/core/user_script_controller_host.h b/src/core/user_script_controller_host.h index 790d40912..293b5d2dd 100644 --- a/src/core/user_script_controller_host.h +++ b/src/core/user_script_controller_host.h @@ -43,12 +43,15 @@ #include <QtCore/QScopedPointer> #include "user_script.h" -class WebContentsAdapterPrivate; namespace content { class RenderProcessHost; class WebContents; } + +namespace QtWebEngineCore { + class WebContentsAdapter; +class WebContentsAdapterPrivate; class QWEBENGINE_EXPORT UserScriptControllerHost { @@ -79,4 +82,6 @@ private: QScopedPointer<RenderProcessObserverHelper> m_renderProcessObserver; }; +} // namespace + #endif // USER_SCRIPT_CONTROLLER_HOST_H diff --git a/src/core/web_channel_ipc_transport_host.cpp b/src/core/web_channel_ipc_transport_host.cpp index ce673494c..ecc49ab5f 100644 --- a/src/core/web_channel_ipc_transport_host.cpp +++ b/src/core/web_channel_ipc_transport_host.cpp @@ -44,6 +44,8 @@ #include <QJsonDocument> #include <QJsonObject> +namespace QtWebEngineCore { + WebChannelIPCTransportHost::WebChannelIPCTransportHost(content::WebContents *contents, QObject *parent) : QWebChannelAbstractTransport(parent) , content::WebContentsObserver(contents) @@ -78,3 +80,5 @@ bool WebChannelIPCTransportHost::OnMessageReceived(const IPC::Message &message) IPC_END_MESSAGE_MAP() return handled; } + +} // namespace diff --git a/src/core/web_channel_ipc_transport_host.h b/src/core/web_channel_ipc_transport_host.h index a30cab088..9c21116f1 100644 --- a/src/core/web_channel_ipc_transport_host.h +++ b/src/core/web_channel_ipc_transport_host.h @@ -44,9 +44,10 @@ #include "qtwebenginecoreglobal.h" #include <QtCore/QObject> - QT_FORWARD_DECLARE_CLASS(QString) +namespace QtWebEngineCore { + class WebChannelIPCTransportHost : public QWebChannelAbstractTransport , public content::WebContentsObserver { @@ -62,4 +63,6 @@ private: void onWebChannelMessage(const std::vector<char> &message); }; +} // namespace + #endif // WEB_CHANNEL_IPC_TRANSPORT_H diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 01b41fbe8..9f1000910 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -79,6 +79,8 @@ #include <QtGui/qaccessible.h> #include <QtWebChannel/QWebChannel> +namespace QtWebEngineCore { + static const int kTestWindowWidth = 800; static const int kTestWindowHeight = 600; static const int kHistoryStreamVersion = 3; @@ -639,7 +641,7 @@ void WebContentsAdapter::clearNavigationHistory() void WebContentsAdapter::serializeNavigationHistory(QDataStream &output) { Q_D(WebContentsAdapter); - ::serializeNavigationHistory(d->webContents->GetController(), output); + QtWebEngineCore::serializeNavigationHistory(d->webContents->GetController(), output); } void WebContentsAdapter::setZoomFactor(qreal factor) @@ -829,3 +831,5 @@ void WebContentsAdapter::setWebChannel(QWebChannel *channel) } channel->connectTo(d->webChannelTransport.get()); } + +} // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 0f8fbf947..2973f9948 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -49,15 +49,18 @@ namespace content { class WebContents; struct WebPreferences; } -class BrowserContextQt; -class MessagePassingInterface; -class WebContentsAdapterPrivate; QT_BEGIN_NAMESPACE class QAccessibleInterface; class QWebChannel; QT_END_NAMESPACE +namespace QtWebEngineCore { + +class BrowserContextQt; +class MessagePassingInterface; +class WebContentsAdapterPrivate; + class QWEBENGINE_EXPORT WebContentsAdapter : public QSharedData { public: static QExplicitlySharedDataPointer<WebContentsAdapter> createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient); @@ -125,9 +128,12 @@ public: content::WebContents *webContents() const; private: - Q_DISABLE_COPY(WebContentsAdapter); - Q_DECLARE_PRIVATE(WebContentsAdapter); + Q_DISABLE_COPY(WebContentsAdapter) + Q_DECLARE_PRIVATE(WebContentsAdapter) QScopedPointer<WebContentsAdapterPrivate> d_ptr; }; + +} // namespace QtWebEngineCore + #endif // WEB_CONTENTS_ADAPTER_H diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index a230d7fb3..9455572da 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -50,6 +50,8 @@ QT_FORWARD_DECLARE_CLASS(QKeyEvent) QT_FORWARD_DECLARE_CLASS(QVariant) QT_FORWARD_DECLARE_CLASS(CertificateErrorController) +namespace QtWebEngineCore { + class BrowserContextAdapter; class FilePickerController; class JavaScriptDialogController; @@ -143,10 +145,10 @@ public: virtual void selectionChanged() = 0; virtual QRectF viewportRect() const = 0; virtual qreal dpiScale() const = 0; - virtual void loadStarted(const QUrl &provisionalUrl) = 0; + virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) = 0; virtual void loadCommitted() = 0; virtual void loadVisuallyCommitted() = 0; - virtual void loadFinished(bool success, const QUrl &url, int errorCode = 0, const QString &errorDescription = QString()) = 0; + virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) = 0; virtual void focusContainer() = 0; virtual void unhandledKeyEvent(QKeyEvent *event) = 0; virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry) = 0; @@ -180,4 +182,6 @@ public: }; +} // namespace QtWebEngineCore + #endif // WEB_CONTENTS_ADAPTER_CLIENT_H diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h index 6ddff47a5..52bade3a5 100644 --- a/src/core/web_contents_adapter_p.h +++ b/src/core/web_contents_adapter_p.h @@ -44,14 +44,18 @@ #include <QExplicitlySharedDataPointer> +QT_FORWARD_DECLARE_CLASS(QWebChannel) + +class WebEngineContext; + +namespace QtWebEngineCore { + class BrowserContextAdapter; class QtRenderViewObserverHost; class UserScriptControllerHost; class WebChannelIPCTransportHost; class WebContentsAdapterClient; class WebContentsDelegateQt; -class WebEngineContext; -QT_FORWARD_DECLARE_CLASS(QWebChannel) class WebContentsAdapterPrivate { public: @@ -69,4 +73,6 @@ public: int lastFindRequestId; }; +} // namespace QtWebEngineCore + #endif // WEB_CONTENTS_ADAPTER_P_H diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 1d63997f0..a2e6f192a 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -62,6 +62,8 @@ #include "content/public/common/url_constants.h" #include "content/public/common/web_preferences.h" +namespace QtWebEngineCore { + // Maps the LogSeverity defines in base/logging.h to the web engines message levels. static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32 messageLevel) { if (messageLevel < 1) @@ -143,6 +145,11 @@ void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(content::RenderFrame { if (is_error_page) { m_loadingErrorFrameList.append(render_frame_host->GetRoutingID()); + + // Trigger LoadStarted signal for main frame's error page only. + if (!render_frame_host->GetParent()) + m_viewClient->loadStarted(toQt(validated_url), true); + return; } @@ -172,7 +179,7 @@ void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_h if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()) || render_frame_host->GetParent()) return; - m_viewClient->loadFinished(false, toQt(validated_url), error_code, toQt(error_description)); + m_viewClient->loadFinished(false /* success */ , toQt(validated_url), false /* isErrorPage */, error_code, toQt(error_description)); m_viewClient->loadProgressChanged(0); } @@ -181,6 +188,11 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID())) { Q_ASSERT(validated_url.is_valid() && validated_url.spec() == content::kUnreachableWebDataURL); m_viewClient->iconChanged(QUrl()); + + // Trigger LoadFinished signal for main frame's error page only. + if (!render_frame_host->GetParent()) + m_viewClient->loadFinished(true /* success */, toQt(validated_url), true /* isErrorPage */); + return; } @@ -344,3 +356,5 @@ void WebContentsDelegateQt::geolocationPermissionReply(const QUrl &origin, bool m_geolocationPermissionRequests.remove(origin); } } + +} // namespace QtWebEngineCore diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 868d3e514..a200ca4df 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -56,6 +56,8 @@ namespace content { struct WebPreferences; } +namespace QtWebEngineCore { + class WebContentsAdapterClient; class WebContentsDelegateQt : public content::WebContentsDelegate @@ -111,4 +113,6 @@ private: QList<int64> m_loadingErrorFrameList; }; +} // namespace QtWebEngineCore + #endif // WEB_CONTENTS_DELEGATE_QT_H diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index 41417d205..932170634 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -45,6 +45,8 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/public/common/context_menu_params.h" +namespace QtWebEngineCore { + void WebContentsViewQt::initialize(WebContentsAdapterClient* client) { m_client = client; @@ -139,3 +141,5 @@ void WebContentsViewQt::TakeFocus(bool reverse) { m_client->passOnFocus(reverse); } + +} // namespace QtWebEngineCore diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index 3a0376a51..896955f7d 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -48,6 +48,8 @@ #include "web_contents_delegate_qt.h" #include "web_engine_context.h" +namespace QtWebEngineCore { + class WebContentsViewQt : public content::WebContentsView , public content::RenderViewHostDelegateView @@ -123,4 +125,6 @@ private: bool m_allowOtherViews; }; +} // namespace QtWebEngineCore + #endif // WEB_CONTENTS_VIEW_QT_H diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 2e6abd697..5d8fe79e6 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -83,6 +83,8 @@ #include <QVector> #include <qpa/qplatformnativeinterface.h> +using namespace QtWebEngineCore; + namespace { scoped_refptr<WebEngineContext> sContext; diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index fc9478a97..5f45aad98 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -51,17 +51,19 @@ class BrowserMainRunner; class ContentMainRunner; } +namespace QtWebEngineCore { class BrowserContextAdapter; class ContentMainDelegateQt; class DevToolsHttpHandlerDelegateQt; class SurfaceFactoryQt; +} class WebEngineContext : public base::RefCounted<WebEngineContext> { public: static scoped_refptr<WebEngineContext> current(); - BrowserContextAdapter *defaultBrowserContext(); - BrowserContextAdapter *offTheRecordBrowserContext(); + QtWebEngineCore::BrowserContextAdapter *defaultBrowserContext(); + QtWebEngineCore::BrowserContextAdapter *offTheRecordBrowserContext(); private: friend class base::RefCounted<WebEngineContext>; @@ -69,15 +71,15 @@ private: ~WebEngineContext(); scoped_ptr<base::RunLoop> m_runLoop; - scoped_ptr<ContentMainDelegateQt> m_mainDelegate; + scoped_ptr<QtWebEngineCore::ContentMainDelegateQt> m_mainDelegate; scoped_ptr<content::ContentMainRunner> m_contentRunner; scoped_ptr<content::BrowserMainRunner> m_browserRunner; #if defined(OS_ANDROID) - scoped_ptr<SurfaceFactoryQt> m_surfaceFactory; + scoped_ptr<QtWebEngineCore::SurfaceFactoryQt> m_surfaceFactory; #endif - QExplicitlySharedDataPointer<BrowserContextAdapter> m_defaultBrowserContext; - QExplicitlySharedDataPointer<BrowserContextAdapter> m_offTheRecordBrowserContext; - scoped_ptr<DevToolsHttpHandlerDelegateQt> m_devtools; + QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_defaultBrowserContext; + QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_offTheRecordBrowserContext; + scoped_ptr<QtWebEngineCore::DevToolsHttpHandlerDelegateQt> m_devtools; }; #endif // WEB_ENGINE_CONTEXT_H diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 07c97ef79..ce862aae6 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -56,6 +56,7 @@ #error "No name defined for QtWebEngine's process" #endif +using namespace QtWebEngineCore; namespace { diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 3c2975758..74c60b778 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -44,6 +44,8 @@ #include <QTimer> #include <QTouchDevice> +namespace QtWebEngineCore { + static const int batchTimerTimeout = 0; class BatchTimer : public QTimer { @@ -67,7 +69,6 @@ private: WebEngineSettings *m_settings; }; - static inline bool isTouchScreenAvailable() { static bool initialized = false; static bool touchScreenAvailable = false; @@ -310,4 +311,6 @@ void WebEngineSettings::setParentSettings(WebEngineSettings *_parentSettings) parentSettings->childSettings.insert(this); } +} // namespace QtWebEngineCore + #include "web_engine_settings.moc" diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index bffb5b2fe..e9d8010a8 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -45,13 +45,13 @@ #include <QUrl> #include <QSet> -class BatchTimer; -class WebContentsAdapter; -class WebEngineSettings; - namespace content { struct WebPreferences; } +namespace QtWebEngineCore { + +class BatchTimer; +class WebContentsAdapter; class QWEBENGINE_EXPORT WebEngineSettings { public: @@ -138,4 +138,6 @@ private: friend class WebContentsAdapter; }; +} // namespace QtWebEngineCore + #endif // WEB_ENGINE_SETTINGS_H diff --git a/src/core/web_engine_visited_links_manager.cpp b/src/core/web_engine_visited_links_manager.cpp index 85c8b1e13..deee26523 100644 --- a/src/core/web_engine_visited_links_manager.cpp +++ b/src/core/web_engine_visited_links_manager.cpp @@ -45,6 +45,8 @@ #include "components/visitedlink/browser/visitedlink_delegate.h" #include "components/visitedlink/browser/visitedlink_master.h" +namespace QtWebEngineCore { + namespace { class BasicUrlIterator : public visitedlink::VisitedLinkMaster::URLIterator { public: @@ -104,3 +106,5 @@ void WebEngineVisitedLinksManager::addUrl(const GURL &urlToAdd) Q_ASSERT(m_visitedLinkMaster); m_visitedLinkMaster->AddURL(urlToAdd); } + +} // namespace QtWebEngineCore diff --git a/src/core/web_engine_visited_links_manager.h b/src/core/web_engine_visited_links_manager.h index f64237773..afbc414a3 100644 --- a/src/core/web_engine_visited_links_manager.h +++ b/src/core/web_engine_visited_links_manager.h @@ -49,11 +49,13 @@ namespace visitedlink { class VisitedLinkMaster; } +class GURL; + +namespace QtWebEngineCore { + class BrowserContextAdapter; class VisitedLinkDelegateQt; -class GURL; - class QWEBENGINE_EXPORT WebEngineVisitedLinksManager { public: @@ -73,4 +75,6 @@ private: QScopedPointer<VisitedLinkDelegateQt> m_delegate; }; +} // namespace QtWebEngineCore + #endif // WEB_ENGINE_VISITED_LINKS_MANAGER_H diff --git a/src/src.pro b/src/src.pro index ed402c582..2effb70ed 100644 --- a/src/src.pro +++ b/src/src.pro @@ -10,13 +10,20 @@ webengine_experimental_plugin.subdir = webengine/plugin/experimental webengine_experimental_plugin.target = sub-webengine-experimental-plugin webengine_experimental_plugin.depends = webengine - SUBDIRS += core \ process \ webengine \ webengine_plugin \ webengine_experimental_plugin + +isQMLTestSupportApiEnabled() { + webengine_testsupport_plugin.subdir = webengine/plugin/testsupport + webengine_testsupport_plugin.target = sub-webengine-testsupport-plugin + webengine_testsupport_plugin.depends = webengine + SUBDIRS += webengine_testsupport_plugin +} + # FIXME: We probably want a bit more control over config options to tweak what to build/ship or not. # Another example of where this could be necessary is to make it easy to build proprietery codecs support. !contains(WEBENGINE_CONFIG, no_ui_delegates): SUBDIRS += webengine/ui diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp index ba22bf1f0..a39bbfb84 100644 --- a/src/webengine/api/qquickwebenginecertificateerror.cpp +++ b/src/webengine/api/qquickwebenginecertificateerror.cpp @@ -45,7 +45,8 @@ public: error(static_cast<QQuickWebEngineCertificateError::Error>(static_cast<int>(controller->error()))), description(controller->errorString()), overridable(controller->overridable()), - async(false) + async(false), + answered(false) { } @@ -54,6 +55,7 @@ public: QString description; bool overridable; bool async; + bool answered; }; @@ -102,7 +104,9 @@ void QQuickWebEngineCertificateError::defer() */ void QQuickWebEngineCertificateError::ignoreCertificateError() { - Q_D(const QQuickWebEngineCertificateError); + Q_D(QQuickWebEngineCertificateError); + + d->answered = true; QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef(); if (strongRefCert) @@ -116,7 +120,9 @@ void QQuickWebEngineCertificateError::ignoreCertificateError() */ void QQuickWebEngineCertificateError::rejectCertificate() { - Q_D(const QQuickWebEngineCertificateError); + Q_D(QQuickWebEngineCertificateError); + + d->answered = true; QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef(); if (strongRefCert) @@ -169,5 +175,11 @@ bool QQuickWebEngineCertificateError::deferred() const return d->async; } +bool QQuickWebEngineCertificateError::answered() const +{ + Q_D(const QQuickWebEngineCertificateError); + return d->answered; +} + QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h index 08ebc83b6..18a1f90e5 100644 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ b/src/webengine/api/qquickwebenginecertificateerror_p.h @@ -83,6 +83,7 @@ public: QString description() const; bool overridable() const; bool deferred() const; + bool answered() const; private: Q_DISABLE_COPY(QQuickWebEngineCertificateError) diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index c1eaaadb1..c38f5ea1c 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -36,6 +36,9 @@ #include "qquickwebenginedownloaditem_p.h" #include "qquickwebenginedownloaditem_p_p.h" +#include "qquickwebengineprofile_p_p.h" + +using QtWebEngineCore::BrowserContextAdapterClient; QT_BEGIN_NAMESPACE diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 9d054f5e0..fe45ca2a3 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -37,12 +37,13 @@ #ifndef QQUICKWEBENGINEDOWNLOADITEM_P_P_H #define QQUICKWEBENGINEDOWNLOADITEM_P_P_H +#include "browser_context_adapter_client.h" #include "qquickwebenginedownloaditem_p.h" -#include "qquickwebengineprofile_p_p.h" #include <private/qtwebengineglobal_p.h> #include <QString> QT_BEGIN_NAMESPACE +class QQuickWebEngineProfilePrivate; class QQuickWebEngineDownloadItemPrivate { QQuickWebEngineDownloadItem *q_ptr; @@ -59,7 +60,7 @@ public: qint64 receivedBytes; QString downloadPath; - void update(const BrowserContextAdapterClient::DownloadItemInfo &info); + void update(const QtWebEngineCore::BrowserContextAdapterClient::DownloadItemInfo &info); void updateState(QQuickWebEngineDownloadItem::DownloadState newState); }; diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index 3b6d7bb2f..9a737fbbe 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -68,7 +68,7 @@ int QQuickWebEngineHistoryListModelPrivate::offsetForIndex(int index) const return index - adapter()->currentNavigationEntryIndex(); } -WebContentsAdapter *QQuickWebEngineHistoryListModelPrivate::adapter() const +QtWebEngineCore::WebContentsAdapter *QQuickWebEngineHistoryListModelPrivate::adapter() const { return view->adapter.data(); } diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h index 02f29b35b..cb6aff2bc 100644 --- a/src/webengine/api/qquickwebenginehistory_p.h +++ b/src/webengine/api/qquickwebenginehistory_p.h @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -class WebEngineHistory; -class WebEngineHistoryItem; class QQuickWebEngineHistory; class QQuickWebEngineHistoryPrivate; class QQuickWebEngineHistoryListModelPrivate; diff --git a/src/webengine/api/qquickwebenginehistory_p_p.h b/src/webengine/api/qquickwebenginehistory_p_p.h index 2ad2af26f..0d714b1b6 100644 --- a/src/webengine/api/qquickwebenginehistory_p_p.h +++ b/src/webengine/api/qquickwebenginehistory_p_p.h @@ -37,11 +37,13 @@ #ifndef QQUICKWEBENGINEHISTORY_P_P_H #define QQUICKWEBENGINEHISTORY_P_P_H +namespace QtWebEngineCore { class WebContentsAdapter; -class QQuickWebEngineHistoryListModel; -class QQuickWebEngineViewPrivate; +} QT_BEGIN_NAMESPACE +class QQuickWebEngineHistoryListModel; +class QQuickWebEngineViewPrivate; class QQuickWebEngineHistoryListModelPrivate { public: @@ -52,7 +54,7 @@ public: virtual int index(int) const; virtual int offsetForIndex(int) const; - WebContentsAdapter *adapter() const; + QtWebEngineCore::WebContentsAdapter *adapter() const; QQuickWebEngineViewPrivate *view; }; diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h index a24ce3b79..062a2fa33 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest_p.h +++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h @@ -40,7 +40,9 @@ #include "qtwebengineglobal_p.h" #include "qquickwebengineview_p.h" +namespace QtWebEngineCore { class WebContentsAdapter; +} QT_BEGIN_NAMESPACE @@ -59,7 +61,7 @@ private: QQuickWebEngineNewViewRequest(); QQuickWebEngineView::NewViewDestination m_destination; bool m_isUserInitiated; - QExplicitlySharedDataPointer<WebContentsAdapter> m_adapter; + QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> m_adapter; friend class QQuickWebEngineViewPrivate; }; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 36992ca9f..718007c35 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -46,6 +46,8 @@ #include "browser_context_adapter.h" #include "web_engine_settings.h" +using QtWebEngineCore::BrowserContextAdapter; + QT_BEGIN_NAMESPACE QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext) diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index a18d81be4..ee91d7728 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -43,6 +43,10 @@ #include <QScopedPointer> #include <QString> +namespace QtWebEngineCore { +class BrowserContextAdapter; +} + QT_BEGIN_NAMESPACE class QQuickWebEngineDownloadItem; diff --git a/src/webengine/api/qquickwebengineprofile_p_p.h b/src/webengine/api/qquickwebengineprofile_p_p.h index 4810cec77..0cf11acec 100644 --- a/src/webengine/api/qquickwebengineprofile_p_p.h +++ b/src/webengine/api/qquickwebengineprofile_p_p.h @@ -37,8 +37,6 @@ #ifndef QQUICKWEBENGINEPROFILE_P_P_H #define QQUICKWEBENGINEPROFILE_P_P_H -class BrowserContextAdapter; - #include "browser_context_adapter_client.h" #include "qquickwebengineprofile_p.h" @@ -51,13 +49,13 @@ QT_BEGIN_NAMESPACE class QQuickWebEngineDownloadItem; class QQuickWebEngineSettings; -class QQuickWebEngineProfilePrivate : public BrowserContextAdapterClient { +class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext); + QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext, bool ownsContext); ~QQuickWebEngineProfilePrivate(); - BrowserContextAdapter *browserContext() const { return m_browserContext; } + QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContext; } QQuickWebEngineSettings *settings() const { return m_settings.data(); } void cancelDownload(quint32 downloadId); @@ -70,8 +68,8 @@ private: friend class QQuickWebEngineViewPrivate; QQuickWebEngineProfile *q_ptr; QScopedPointer<QQuickWebEngineSettings> m_settings; - BrowserContextAdapter *m_browserContext; - QExplicitlySharedDataPointer<BrowserContextAdapter> m_browserContextRef; + QtWebEngineCore::BrowserContextAdapter *m_browserContext; + QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; }; diff --git a/src/webengine/api/qquickwebenginescript.cpp b/src/webengine/api/qquickwebenginescript.cpp index 872ba1533..6ea6d01bc 100644 --- a/src/webengine/api/qquickwebenginescript.cpp +++ b/src/webengine/api/qquickwebenginescript.cpp @@ -41,6 +41,8 @@ #include <QtCore/QTimerEvent> #include "user_script_controller_host.h" +using QtWebEngineCore::UserScript; + QQuickWebEngineScript::QQuickWebEngineScript() : d_ptr(new QQuickWebEngineScriptPrivate) { @@ -70,7 +72,7 @@ QString QQuickWebEngineScript::toString() const } ret.append(QString::number(d->coreScript.worldId()) % QStringLiteral(", ") % (d->coreScript.runsOnSubFrames() ? QStringLiteral("true") : QStringLiteral("false")) - % QStringLiteral(", ") % d->coreScript.source() % QLatin1Char(')')); + % QStringLiteral(", ") % d->coreScript.sourceCode() % QLatin1Char(')')); return ret; } @@ -81,10 +83,10 @@ QString QQuickWebEngineScript::name() const } -QString QQuickWebEngineScript::source() const +QString QQuickWebEngineScript::sourceCode() const { Q_D(const QQuickWebEngineScript); - return d->coreScript.source(); + return d->coreScript.sourceCode(); } ASSERT_ENUMS_MATCH(QQuickWebEngineScript::Deferred, UserScript::AfterLoad) @@ -122,17 +124,16 @@ void QQuickWebEngineScript::setName(QString arg) Q_EMIT nameChanged(arg); } -void QQuickWebEngineScript::setSource(QString arg) +void QQuickWebEngineScript::setSourceCode(QString arg) { Q_D(QQuickWebEngineScript); - if (arg == source()) + if (arg == sourceCode()) return; d->aboutToUpdateUnderlyingScript(); - d->coreScript.setSource(arg); - Q_EMIT sourceChanged(arg); + d->coreScript.setSourceCode(arg); + Q_EMIT sourceCodeChanged(arg); } - void QQuickWebEngineScript::setInjectionPoint(QQuickWebEngineScript::InjectionPoint arg) { Q_D(QQuickWebEngineScript); @@ -178,7 +179,7 @@ void QQuickWebEngineScript::timerEvent(QTimerEvent *e) d->m_controllerHost->addUserScript(d->coreScript, d->m_adapter); } -void QQuickWebEngineScriptPrivate::bind(UserScriptControllerHost *scriptController, WebContentsAdapter *adapter) +void QQuickWebEngineScriptPrivate::bind(QtWebEngineCore::UserScriptControllerHost *scriptController, QtWebEngineCore::WebContentsAdapter *adapter) { aboutToUpdateUnderlyingScript(); m_adapter = adapter; diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h index a42aed41b..55f0c782d 100644 --- a/src/webengine/api/qquickwebenginescript_p.h +++ b/src/webengine/api/qquickwebenginescript_p.h @@ -40,9 +40,6 @@ #include <private/qtwebengineglobal_p.h> #include <QtCore/QObject> -class UserScriptControllerHost; -class WebContentsAdapter; - QT_BEGIN_NAMESPACE class QQuickWebEngineScriptPrivate; class QQuickWebEngineView; @@ -53,7 +50,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineScript : public QObject Q_ENUMS(InjectionPoint) Q_ENUMS(ScriptWorldId) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged) Q_PROPERTY(InjectionPoint injectionPoint READ injectionPoint WRITE setInjectionPoint NOTIFY injectionPointChanged) Q_PROPERTY(ScriptWorldId worldId READ worldId WRITE setWorldId NOTIFY worldIdChanged) Q_PROPERTY(bool runOnSubframes READ runOnSubframes WRITE setRunOnSubframes NOTIFY runOnSubframesChanged) @@ -77,21 +74,21 @@ public: Q_INVOKABLE QString toString() const; QString name() const; - QString source() const; + QString sourceCode() const; InjectionPoint injectionPoint() const; ScriptWorldId worldId() const; bool runOnSubframes() const; public Q_SLOTS: void setName(QString arg); - void setSource(QString arg); + void setSourceCode(QString arg); void setInjectionPoint(InjectionPoint arg); void setWorldId(ScriptWorldId arg); void setRunOnSubframes(bool arg); Q_SIGNALS: void nameChanged(QString arg); - void sourceChanged(QString arg); + void sourceCodeChanged(QString arg); void injectionPointChanged(InjectionPoint arg); void worldIdChanged(ScriptWorldId arg); void runOnSubframesChanged(bool arg); @@ -101,7 +98,7 @@ protected: private: friend class QQuickWebEngineViewPrivate; - Q_DECLARE_PRIVATE(QQuickWebEngineScript); + Q_DECLARE_PRIVATE(QQuickWebEngineScript) QScopedPointer<QQuickWebEngineScriptPrivate> d_ptr; }; QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginescript_p_p.h b/src/webengine/api/qquickwebenginescript_p_p.h index 962a04cb2..7b5626fd1 100644 --- a/src/webengine/api/qquickwebenginescript_p_p.h +++ b/src/webengine/api/qquickwebenginescript_p_p.h @@ -43,6 +43,10 @@ #include "user_script.h" #include "web_contents_adapter.h" +namespace QtWebEngineCore { +class UserScriptControllerHost; +class WebContentsAdapter; +} // namespace QT_BEGIN_NAMESPACE @@ -51,12 +55,12 @@ public: Q_DECLARE_PUBLIC(QQuickWebEngineScript) QQuickWebEngineScriptPrivate(); void aboutToUpdateUnderlyingScript(); - void bind(UserScriptControllerHost *, WebContentsAdapter * = 0); + void bind(QtWebEngineCore::UserScriptControllerHost *, QtWebEngineCore::WebContentsAdapter * = 0); - UserScript coreScript; + QtWebEngineCore::UserScript coreScript; QBasicTimer m_basicTimer; - UserScriptControllerHost *m_controllerHost; - WebContentsAdapter *m_adapter; + QtWebEngineCore::UserScriptControllerHost *m_controllerHost; + QtWebEngineCore::WebContentsAdapter *m_adapter; private: QQuickWebEngineScript *q_ptr; diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 343ffef0e..70a9d4b59 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE +using QtWebEngineCore::WebEngineSettings; + QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings) : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : 0)) { } diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index 40d04fdf8..68c85ea7f 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -41,7 +41,9 @@ #include <QObject> #include <QScopedPointer> +namespace QtWebEngineCore { class WebEngineSettings; +} QT_BEGIN_NAMESPACE @@ -111,7 +113,7 @@ private: void setParentSettings(QQuickWebEngineSettings *parentSettings); - QScopedPointer<WebEngineSettings> d_ptr; + QScopedPointer<QtWebEngineCore::WebEngineSettings> d_ptr; }; QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webengine/api/qquickwebenginetestsupport.cpp new file mode 100644 index 000000000..0bb16ae14 --- /dev/null +++ b/src/webengine/api/qquickwebenginetestsupport.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 "qquickwebenginetestsupport_p.h" + +#include "qquickwebengineloadrequest_p.h" + +QT_BEGIN_NAMESPACE +using namespace QtWebEngineCore; + +QQuickWebEngineJavaScriptDialog::QQuickWebEngineJavaScriptDialog(QSharedPointer<JavaScriptDialogController> controller) +{ + m_dialogController = controller; +} + +QString QQuickWebEngineJavaScriptDialog::message() const +{ + return m_dialogController->message(); +} + +QString QQuickWebEngineJavaScriptDialog::defaultValue() const +{ + return m_dialogController->defaultPrompt(); +} + +void QQuickWebEngineJavaScriptDialog::reject() +{ + QMetaObject::invokeMethod(m_dialogController.data(), "reject"); +} + +void QQuickWebEngineJavaScriptDialog::accept(const QString &input) +{ + if (!input.isNull()) + QMetaObject::invokeMethod(m_dialogController.data(), "textProvided", Q_ARG(QString, input)); + QMetaObject::invokeMethod(m_dialogController.data(), "accept"); +} + +QQuickWebEngineErrorPage::QQuickWebEngineErrorPage() +{ +} + +void QQuickWebEngineErrorPage::loadFinished(bool success, const QUrl &url) +{ + // Loading of the error page should not fail. + Q_ASSERT(success); + + QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus); + Q_EMIT loadingChanged(&loadRequest); + return; +} + +void QQuickWebEngineErrorPage::loadStarted(const QUrl &provisionalUrl) +{ + QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); + Q_EMIT loadingChanged(&loadRequest); +} + +QQuickWebEngineTestSupport::QQuickWebEngineTestSupport() + : m_errorPage(new QQuickWebEngineErrorPage()) +{ +} + +QQuickWebEngineErrorPage *QQuickWebEngineTestSupport::errorPage() const +{ + return m_errorPage.data(); +} + +void QQuickWebEngineTestSupport::testDialog(QSharedPointer<JavaScriptDialogController> dialogController) +{ + Q_ASSERT(!dialogController.isNull()); + + QQuickWebEngineJavaScriptDialog dialog(dialogController); + switch (dialogController->type()) { + case WebContentsAdapterClient::AlertDialog: + Q_EMIT alertDialog(&dialog); + break; + case WebContentsAdapterClient::ConfirmDialog: + Q_EMIT confirmDialog(&dialog); + break; + case WebContentsAdapterClient::PromptDialog: + Q_EMIT promptDialog(&dialog); + break; + case WebContentsAdapterClient::InternalAuthorizationDialog: + break; + default: + Q_UNREACHABLE(); + } +} + +QT_END_NAMESPACE + +#include "moc_qquickwebenginetestsupport_p.cpp" diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h new file mode 100644 index 000000000..06950e416 --- /dev/null +++ b/src/webengine/api/qquickwebenginetestsupport_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 QQUICKWEBENGINETESTSUPPORT_P_H +#define QQUICKWEBENGINETESTSUPPORT_P_H + +#include <private/qtwebengineglobal_p.h> + +#include "javascript_dialog_controller.h" +#include <QObject> +#include <QUrl> + +QT_BEGIN_NAMESPACE + +class QQuickWebEngineLoadRequest; + +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineJavaScriptDialog : public QObject { + Q_OBJECT + Q_PROPERTY(QString message READ message CONSTANT) + Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT) + +public: + QQuickWebEngineJavaScriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>); + QString message() const; + QString defaultValue() const; + +public Q_SLOTS: + void reject(); + void accept(const QString &input = QString()); + +private: + QSharedPointer<QtWebEngineCore::JavaScriptDialogController> m_dialogController; +}; + +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineErrorPage : public QObject { + Q_OBJECT + +public: + QQuickWebEngineErrorPage(); + + void loadFinished(bool success, const QUrl &url); + void loadStarted(const QUrl &provisionalUrl); + +Q_SIGNALS: + void loadingChanged(QQuickWebEngineLoadRequest *loadRequest); +}; + +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestSupport : public QObject { + Q_OBJECT + Q_PROPERTY(QQuickWebEngineErrorPage *errorPage READ errorPage) + +public: + QQuickWebEngineTestSupport(); + QQuickWebEngineErrorPage *errorPage() const; + void testDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController> dialog); + +Q_SIGNALS: + void alertDialog(QQuickWebEngineJavaScriptDialog *dialog); + void confirmDialog(QQuickWebEngineJavaScriptDialog *dialog); + void promptDialog(QQuickWebEngineJavaScriptDialog *dialog); + +private: + QScopedPointer<QQuickWebEngineErrorPage> m_errorPage; +}; + +QT_END_NAMESPACE + +#endif // QQUICKWEBENGINETESTSUPPORT_P_H diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 48d741d20..9a64b9ac6 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -50,6 +50,11 @@ #include "qquickwebengineprofile_p_p.h" #include "qquickwebenginesettings_p.h" #include "qquickwebenginescript_p_p.h" + +#ifdef ENABLE_QML_TESTSUPPORT_API +#include "qquickwebenginetestsupport_p.h" +#endif + #include "render_widget_host_view_qt_delegate_quick.h" #include "render_widget_host_view_qt_delegate_quickwindow.h" #include "ui_delegates_manager.h" @@ -73,6 +78,7 @@ #endif // QT_NO_ACCESSIBILITY QT_BEGIN_NAMESPACE +using namespace QtWebEngineCore; #ifndef QT_NO_ACCESSIBILITY static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object) @@ -90,6 +96,9 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() , m_history(new QQuickWebEngineHistory(this)) , m_profile(QQuickWebEngineProfile::defaultProfile()) , m_settings(new QQuickWebEngineSettings(m_profile->settings())) +#ifdef ENABLE_QML_TESTSUPPORT_API + , m_testSupport(0) +#endif , contextMenuExtraItems(0) , loadProgress(0) , m_isFullScreen(false) @@ -221,6 +230,12 @@ void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const Q void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> dialog) { +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) { + m_testSupport->testDialog(dialog); + return; + } +#endif ui()->showDialog(dialog); } @@ -228,12 +243,13 @@ void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<Cert { Q_Q(QQuickWebEngineView); - m_certificateErrorController = errorController; QQuickWebEngineCertificateError *quickController = new QQuickWebEngineCertificateError(errorController); QQmlEngine::setObjectOwnership(quickController, QQmlEngine::JavaScriptOwnership); Q_EMIT q->certificateError(quickController); - if (!quickController->deferred()) + if (!quickController->deferred() && !quickController->answered()) quickController->rejectCertificate(); + else + m_certificateErrorControllers.append(errorController); } void QQuickWebEngineViewPrivate::runGeolocationPermissionRequest(const QUrl &url) @@ -300,11 +316,20 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const return m_dpiScale; } -void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl) +void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage) { Q_Q(QQuickWebEngineView); + if (isErrorPage) { +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) + m_testSupport->errorPage()->loadStarted(provisionalUrl); +#endif + return; + } + isLoading = true; m_history->reset(); + m_certificateErrorControllers.clear(); QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); Q_EMIT q->loadingChanged(&loadRequest); } @@ -323,9 +348,18 @@ Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<i Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == static_cast<int>(QQuickWebEngineView::CertificateErrorDomain)); Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(QQuickWebEngineView::DnsErrorDomain)); -void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, int errorCode, const QString &errorDescription) +void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) { Q_Q(QQuickWebEngineView); + + if (isErrorPage) { +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) + m_testSupport->errorPage()->loadFinished(success, url); +#endif + return; + } + isLoading = false; m_history->reset(); if (errorCode == WebEngineError::UserAbortedError) { @@ -400,12 +434,14 @@ void QQuickWebEngineViewPrivate::close() void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen) { - Q_EMIT e->fullScreenRequested(fullScreen); + Q_Q(QQuickWebEngineView); + QQuickWebEngineFullScreenRequest request(this, fullScreen); + Q_EMIT q->fullScreenRequested(request); } bool QQuickWebEngineViewPrivate::isFullScreen() const { - return e->isFullScreen(); + return m_isFullScreen; } void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) @@ -701,6 +737,20 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile) } } +#ifdef ENABLE_QML_TESTSUPPORT_API +QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const +{ + Q_D(const QQuickWebEngineView); + return d->m_testSupport; +} + +void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport) +{ + Q_D(QQuickWebEngineView); + d->m_testSupport = testSupport; +} +#endif + void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result) { Q_Q(QQuickWebEngineView); @@ -780,15 +830,11 @@ qreal QQuickWebEngineView::zoomFactor() const return d->adapter->currentZoomFactor(); } -void QQuickWebEngineViewExperimental::setIsFullScreen(bool fullscreen) -{ - d_ptr->m_isFullScreen = fullscreen; - emit isFullScreenChanged(); -} -bool QQuickWebEngineViewExperimental::isFullScreen() const +bool QQuickWebEngineView::isFullScreen() const { - return d_ptr->m_isFullScreen; + Q_D(const QQuickWebEngineView); + return d->m_isFullScreen; } void QQuickWebEngineViewExperimental::setExtraContextMenuEntriesComponent(QQmlComponent *contextMenuExtras) @@ -804,7 +850,7 @@ QQmlComponent *QQuickWebEngineViewExperimental::extraContextMenuEntriesComponent return d_ptr->contextMenuExtraItems; } -void QQuickWebEngineViewExperimental::findText(const QString &subString, FindFlags options, const QJSValue &callback) +void QQuickWebEngineView::findText(const QString &subString, FindFlags options, const QJSValue &callback) { Q_D(QQuickWebEngineView); if (!d->adapter) @@ -906,6 +952,15 @@ void QQuickWebEngineView::goBackOrForward(int offset) d->adapter->navigateToIndex(index); } +void QQuickWebEngineView::fullScreenCancelled() +{ + Q_D(QQuickWebEngineView); + if (d->m_isFullScreen) { + d->m_isFullScreen = false; + Q_EMIT isFullScreenChanged(); + } +} + void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { QQuickItem::geometryChanged(newGeometry, oldGeometry); @@ -969,6 +1024,26 @@ void QQuickWebEngineView::componentComplete() d->ensureContentsAdapter(); } +QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest() + : viewPrivate(0) + , m_toggleOn(false) +{ +} + +QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn) + : viewPrivate(viewPrivate) + , m_toggleOn(toggleOn) +{ +} + +void QQuickWebEngineFullScreenRequest::accept() +{ + if (viewPrivate && viewPrivate->m_isFullScreen != m_toggleOn) { + viewPrivate->m_isFullScreen = m_toggleOn; + Q_EMIT viewPrivate->q_ptr->isFullScreenChanged(); + } +} + QQuickWebEngineViewExperimental::QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate *viewPrivate) : q_ptr(0) , d_ptr(viewPrivate) diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 93e9ad61b..248ee62b6 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -54,6 +54,25 @@ class QQuickWebEngineSettings; class QQuickWebEngineViewExperimental; class QQuickWebEngineViewPrivate; +#ifdef ENABLE_QML_TESTSUPPORT_API +class QQuickWebEngineTestSupport; +#endif + +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest { + Q_GADGET + Q_PROPERTY(bool toggleOn READ toggleOn) +public: + QQuickWebEngineFullScreenRequest(); + QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn); + + Q_INVOKABLE void accept(); + bool toggleOn() { return m_toggleOn; } + +private: + QQuickWebEngineViewPrivate *viewPrivate; + bool m_toggleOn; +}; + class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_OBJECT Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) @@ -63,18 +82,25 @@ 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(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged REVISION 1) Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1) Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile FINAL REVISION 1) Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1) Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1) Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1) Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL) + +#ifdef ENABLE_QML_TESTSUPPORT_API + Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL) +#endif + Q_ENUMS(NavigationRequestAction); Q_ENUMS(NavigationType); Q_ENUMS(LoadStatus); Q_ENUMS(ErrorDomain); Q_ENUMS(NewViewDestination); Q_ENUMS(JavaScriptConsoleMessageLevel); + Q_FLAGS(FindFlags); public: QQuickWebEngineView(QQuickItem *parent = 0); @@ -88,6 +114,7 @@ public: QString title() const; bool canGoBack() const; bool canGoForward() const; + bool isFullScreen() const; qreal zoomFactor() const; void setZoomFactor(qreal arg); @@ -142,6 +169,12 @@ public: ErrorMessageLevel }; + enum FindFlag { + FindBackward = 1, + FindCaseSensitively = 2, + }; + Q_DECLARE_FLAGS(FindFlags, FindFlag) + // QmlParserStatus virtual void componentComplete() Q_DECL_OVERRIDE; @@ -154,6 +187,11 @@ public: void setWebChannel(QQmlWebChannel *); QQuickWebEngineHistory *navigationHistory() const; +#ifdef ENABLE_QML_TESTSUPPORT_API + QQuickWebEngineTestSupport *testSupport() const; + void setTestSupport(QQuickWebEngineTestSupport *testSupport); +#endif + public Q_SLOTS: void runJavaScript(const QString&, const QJSValue & = QJSValue()); void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()); @@ -162,6 +200,8 @@ public Q_SLOTS: void goBackOrForward(int index); void reload(); void stop(); + Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue()); + Q_REVISION(1) void fullScreenCancelled(); Q_SIGNALS: void titleChanged(); @@ -173,6 +213,8 @@ Q_SIGNALS: void navigationRequested(QQuickWebEngineNavigationRequest *request); void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID); Q_REVISION(1) void certificateError(QQuickWebEngineCertificateError *error); + Q_REVISION(1) void fullScreenRequested(const QQuickWebEngineFullScreenRequest &request); + Q_REVISION(1) void isFullScreenChanged(); Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request); Q_REVISION(1) void zoomFactorChanged(qreal arg); Q_REVISION(1) void webChannelChanged(); @@ -197,5 +239,6 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickWebEngineView) +Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest) #endif // QQUICKWEBENGINEVIEW_P_H diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 98a7a9c5f..b3907d3a4 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -46,8 +46,10 @@ #include <QtCore/qcompilerdetection.h> #include <QtGui/qaccessibleobject.h> +namespace QtWebEngineCore { class WebContentsAdapter; class UIDelegatesManager; +} QT_BEGIN_NAMESPACE class QQuickWebEngineView; @@ -55,6 +57,10 @@ class QQmlComponent; class QQmlContext; class QQuickWebEngineSettings; +#ifdef ENABLE_QML_TESTSUPPORT_API +class QQuickWebEngineTestSupport; +#endif + class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewport : public QObject { Q_OBJECT Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) @@ -77,9 +83,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec Q_OBJECT Q_PROPERTY(QQuickWebEngineViewport *viewport READ viewport) Q_PROPERTY(QQmlComponent *extraContextMenuEntriesComponent READ extraContextMenuEntriesComponent WRITE setExtraContextMenuEntriesComponent NOTIFY extraContextMenuEntriesComponentChanged) - Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setIsFullScreen NOTIFY isFullScreenChanged) Q_ENUMS(Feature) - Q_FLAGS(FindFlags) public: enum Feature { @@ -89,25 +93,14 @@ public: Geolocation }; - enum FindFlag { - FindBackward = 1, - FindCaseSensitively = 2, - }; - Q_DECLARE_FLAGS(FindFlags, FindFlag) - - void setIsFullScreen(bool fullscreen); - bool isFullScreen() const; QQuickWebEngineViewport *viewport() const; void setExtraContextMenuEntriesComponent(QQmlComponent *); QQmlComponent *extraContextMenuEntriesComponent() const; public Q_SLOTS: - void findText(const QString&, FindFlags, const QJSValue & = QJSValue()); void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted); Q_SIGNALS: - void fullScreenRequested(bool fullScreen); - void isFullScreenChanged(); void extraContextMenuEntriesComponentChanged(); void featurePermissionRequested(const QUrl &securityOrigin, Feature feature); void loadVisuallyCommitted(); @@ -121,7 +114,7 @@ private: Q_DECLARE_PUBLIC(QQuickWebEngineView) }; -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewPrivate : public WebContentsAdapterClient +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewPrivate : public QtWebEngineCore::WebContentsAdapterClient { public: Q_DECLARE_PUBLIC(QQuickWebEngineView) @@ -131,10 +124,10 @@ public: QQuickWebEngineViewExperimental *experimental() const; QQuickWebEngineViewport *viewport() const; - UIDelegatesManager *ui(); + QtWebEngineCore::UIDelegatesManager *ui(); - virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; + virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; + virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; @@ -143,20 +136,20 @@ public: virtual void selectionChanged() Q_DECL_OVERRIDE { } virtual QRectF viewportRect() const Q_DECL_OVERRIDE; virtual qreal dpiScale() const Q_DECL_OVERRIDE; - virtual void loadStarted(const QUrl &provisionalUrl) Q_DECL_OVERRIDE; + virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; virtual void loadCommitted() Q_DECL_OVERRIDE; virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE; - virtual void loadFinished(bool success, const QUrl &url, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; + virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; virtual void requestFullScreen(bool) Q_DECL_OVERRIDE; virtual bool isFullScreen() const Q_DECL_OVERRIDE; - virtual bool contextMenuRequested(const WebEngineContextMenuData &) Q_DECL_OVERRIDE; + virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE; virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) Q_DECL_OVERRIDE; - virtual void runFileChooser(FilePickerController *controller) Q_DECL_OVERRIDE; + virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; + virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE; virtual void didRunJavaScript(quint64, const QVariant&) Q_DECL_OVERRIDE; virtual void didFetchDocumentMarkup(quint64, const QString&) Q_DECL_OVERRIDE { } virtual void didFetchDocumentInnerText(quint64, const QString&) Q_DECL_OVERRIDE { } @@ -169,14 +162,14 @@ public: #ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; #endif // QT_NO_ACCESSIBILITY - virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; + virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController); virtual void runGeolocationPermissionRequest(QUrl const&) Q_DECL_OVERRIDE; - virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; + virtual QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; void setDevicePixelRatio(qreal); - void adoptWebContents(WebContentsAdapter *webContents); + void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); void setProfile(QQuickWebEngineProfile *profile); void ensureContentsAdapter(); @@ -186,12 +179,15 @@ public: static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx); static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p); - QExplicitlySharedDataPointer<WebContentsAdapter> adapter; + QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter; QScopedPointer<QQuickWebEngineViewExperimental> e; QScopedPointer<QQuickWebEngineViewport> v; QScopedPointer<QQuickWebEngineHistory> m_history; QQuickWebEngineProfile *m_profile; QScopedPointer<QQuickWebEngineSettings> m_settings; +#ifdef ENABLE_QML_TESTSUPPORT_API + QQuickWebEngineTestSupport *m_testSupport; +#endif QQmlComponent *contextMenuExtraItems; QUrl explicitUrl; QUrl icon; @@ -200,10 +196,10 @@ public: bool isLoading; qreal devicePixelRatio; QMap<quint64, QJSValue> m_callbacks; - QSharedPointer<CertificateErrorController> m_certificateErrorController; + QList<QSharedPointer<CertificateErrorController> > m_certificateErrorControllers; private: - QScopedPointer<UIDelegatesManager> m_uIDelegatesManager; + QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager; QList<QQuickWebEngineScript *> m_userScripts; qreal m_dpiScale; }; diff --git a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc index 893c358ae..73c084dab 100644 --- a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc +++ b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc @@ -206,6 +206,45 @@ */ /*! + \qmlmethod void WebEngineView::findText(string subString) + \since QtWebEngine 1.1 + Finds the specified string, \a subString, in the page. + + To clear the selection, just pass an empty string. +*/ + +/*! + \qmlmethod void WebEngineView::findText(string subString, FindFlags options) + \since QtWebEngine 1.1 + Finds the specified string, \a subString, in the page, using the given \a options. + + To clear the selection, just pass an empty string. + + \code + findText("Qt", WebEngineView.FindBackward | WebEngineView.FindCaseSensitively); + \endcode +*/ + +/*! + \qmlmethod void WebEngineView::findText(string subString, FindFlags options, variant resultCallback) + \since QtWebEngine 1.1 + Finds the specified string, \a subString, in the page, using the given \a options. + + To clear the selection, just pass an empty string. + + The \a resultCallback must take a boolean parameter. It will be called with + a value of true if the \a subString was found; otherwise the callback value + will be false. + + \code + findText("Qt", WebEngineView.FindCaseSensitively, function(success) { + if (success) + console.log("Qt was found!"); + }); + \endcode +*/ + +/*! \qmlsignal WebEngineView::loadingChanged(loadRequest) This signal is emitted when a page load begins, ends, or fails. @@ -245,14 +284,13 @@ */ /*! - \qmlsignal WebEngineView::linkHovered(hoveredUrl, hoveredTitle) + \qmlsignal WebEngineView::linkHovered(hoveredUrl) Within a mouse-driven interface, this signal is emitted when a mouse pointer passes over a link, corresponding to the \c{mouseover} DOM event. This event may also occur in touch interfaces for \c{mouseover} events that are not cancelled with \c{preventDefault()}. \a{hoveredUrl} - provides the link's location, and \a{hoveredTitle} is any available - link text. + provides the link's location. The corresponding handler is onLinkHovered. */ @@ -365,3 +403,16 @@ \sa WebEngineNewViewRequest::destination */ + +/*! + \qmlproperty enumeration WebEngineView::FindFlags + + This enum describes the options available to the findText() function. The options + can be OR-ed together from the following list: + + \value FindBackward Searches backwards instead of forwards. + \value FindCaseSensitively By default findText() works case insensitive. Specifying + this option changes the behavior to a case sensitive find operation. + + \sa WebEngineView::findText() +*/ diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index dc10a50a7..c5ef11a5e 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -81,6 +81,8 @@ public: QObject::tr("Cannot create a separate instance of NavigationHistory")); qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel", QObject::tr("Cannot create a separate instance of NavigationHistory")); + qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest", + QObject::tr("Cannot create a separate instance of FullScreenRequest")); } }; diff --git a/src/webengine/plugin/testsupport/plugin.cpp b/src/webengine/plugin/testsupport/plugin.cpp new file mode 100644 index 000000000..667ffffd6 --- /dev/null +++ b/src/webengine/plugin/testsupport/plugin.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 <QtQml> + +#include "qquickwebenginetestsupport_p.h" + +QT_BEGIN_NAMESPACE + +class QtWebEngineTestSupportPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") +public: + virtual void registerTypes(const char *uri) + { + qWarning("\nWARNING: This project is using the testsupport QML API extensions for QtWebEngine and is therefore tied to a specific QtWebEngine release.\n" + "WARNING: The testsupport API will change from version to version, or even be removed. You have been warned!\n"); + + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine.testsupport")); + + qmlRegisterType<QQuickWebEngineTestSupport>(uri, 1, 0, "WebEngineTestSupport"); + qmlRegisterUncreatableType<QQuickWebEngineErrorPage>(uri, 1, 0, "WebEngineErrorPage", + QObject::tr("Cannot create a separate instance of WebEngineErrorPage")); + qmlRegisterUncreatableType<QQuickWebEngineJavaScriptDialog>(uri, 1, 0, "WebEngineJavaScriptDialog", + QObject::tr("Cannot create a separate instance of WebEngineJavaScriptDialog")); + } +}; + +QT_END_NAMESPACE + +#include "plugin.moc" diff --git a/src/webengine/plugin/testsupport/qmldir b/src/webengine/plugin/testsupport/qmldir new file mode 100644 index 000000000..588c9d2d4 --- /dev/null +++ b/src/webengine/plugin/testsupport/qmldir @@ -0,0 +1,3 @@ +module QtWebEngine.testsupport +plugin qtwebenginetestsupportplugin +typeinfo plugins.qmltypes diff --git a/src/webengine/plugin/testsupport/testsupport.pro b/src/webengine/plugin/testsupport/testsupport.pro new file mode 100644 index 000000000..1a45ad56a --- /dev/null +++ b/src/webengine/plugin/testsupport/testsupport.pro @@ -0,0 +1,13 @@ +CXX_MODULE = qml +TARGET = qtwebenginetestsupportplugin +TARGETPATH = QtWebEngine/testsupport +IMPORT_VERSION = 1.0 + +QT += webengine qml quick +QT_PRIVATE += webengine-private + +INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api + +SOURCES = plugin.cpp + +load(qml_plugin) diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index bfcda558b..0a534ac2c 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -46,6 +46,8 @@ #include <private/qquickwindow_p.h> #include <private/qsgcontext_p.h> +namespace QtWebEngineCore { + RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQtDelegateClient *client, bool isPopup) : m_client(client) , m_isPopup(isPopup) @@ -273,3 +275,5 @@ void RenderWidgetHostViewQtDelegateQuick::onWindowPosChanged() { m_client->windowBoundsChanged(); } + +} // namespace QtWebEngineCore diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h index cb1b6a83f..ddd0e4d9e 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h @@ -41,6 +41,8 @@ #include <QQuickItem> +namespace QtWebEngineCore { + class RenderWidgetHostViewQtDelegateQuick : public QQuickItem, public RenderWidgetHostViewQtDelegate { Q_OBJECT @@ -95,4 +97,7 @@ private: bool m_isPopup; bool m_initialized; }; + +} // namespace QtWebEngineCore + #endif diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp index c395fdd4d..39c48ea5c 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp @@ -39,6 +39,7 @@ #include "qquickwebengineview_p_p.h" #include <QQuickItem> +namespace QtWebEngineCore { RenderWidgetHostViewQtDelegateQuickWindow::RenderWidgetHostViewQtDelegateQuickWindow(RenderWidgetHostViewQtDelegate *realDelegate) : m_realDelegate(realDelegate) @@ -136,3 +137,5 @@ void RenderWidgetHostViewQtDelegateQuickWindow::setTooltip(const QString &toolti { Q_UNUSED(tooltip); } + +} // namespace QtWebEngineCore diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h index 6bd21d15a..cda51a1ab 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h @@ -44,6 +44,8 @@ #include <QQuickWindow> #include <QScopedPointer> +namespace QtWebEngineCore { + class RenderWidgetHostViewQtDelegateQuickWindow : public QQuickWindow , public RenderWidgetHostViewQtDelegate { public: @@ -76,4 +78,6 @@ private: QScopedPointer<RenderWidgetHostViewQtDelegate> m_realDelegate; }; +} // namespace QtWebEngineCore + #endif // RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_QUICKWINDOW_H diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index ed51bd8f2..44c763f37 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -52,6 +52,8 @@ // Uncomment for QML debugging //#define UI_DELEGATES_DEBUG +namespace QtWebEngineCore { + #define NO_SEPARATOR #if defined(Q_OS_WIN) #define FILE_NAME_CASE_STATEMENT(TYPE, COMPONENT) \ @@ -387,3 +389,5 @@ void UIDelegatesManager::showFilePicker(FilePickerController *controller) QMetaObject::invokeMethod(filePicker, "open"); } + +} // namespace QtWebEngineCore diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h index 797aaec74..9367bff30 100644 --- a/src/webengine/ui_delegates_manager.h +++ b/src/webengine/ui_delegates_manager.h @@ -63,14 +63,16 @@ #define MEMBER_DECLARATION(TYPE, COMPONENT) \ QQmlComponent *COMPONENT##Component -class JavaScriptDialogController; -class FilePickerController; QT_BEGIN_NAMESPACE class QObject; class QQmlContext; class QQuickWebEngineView; QT_END_NAMESPACE +namespace QtWebEngineCore { +class JavaScriptDialogController; +class FilePickerController; + const char *defaultPropertyName(QObject *obj); class MenuItemHandler : public QObject { @@ -130,8 +132,10 @@ private: FOR_EACH_COMPONENT_TYPE(MEMBER_DECLARATION, SEMICOLON_SEPARATOR) - Q_DISABLE_COPY(UIDelegatesManager); + Q_DISABLE_COPY(UIDelegatesManager) }; +} // namespace QtWebEngineCore + #endif // UI_DELEGATES_MANAGER_H diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro index 154286e9e..6cba9c5d9 100644 --- a/src/webengine/webengine.pro +++ b/src/webengine/webengine.pro @@ -48,4 +48,11 @@ HEADERS = \ render_widget_host_view_qt_delegate_quickwindow.h \ ui_delegates_manager.h +isQMLTestSupportApiEnabled() { + SOURCES += api/qquickwebenginetestsupport.cpp + HEADERS += api/qquickwebenginetestsupport_p.h + + DEFINES += ENABLE_QML_TESTSUPPORT_API +} + load(qt_module) diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index ecf682edd..703570587 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -41,6 +41,8 @@ QT_BEGIN_NAMESPACE +using QtWebEngineCore::BrowserContextAdapterClient; + static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state) { switch (state) { diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index e3e8a7d44..40c7c6b49 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -63,7 +63,7 @@ public: qint64 totalBytes; qint64 receivedBytes; - void update(const BrowserContextAdapterClient::DownloadItemInfo &info); + void update(const QtWebEngineCore::BrowserContextAdapterClient::DownloadItemInfo &info); }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 72b651cf1..08976a291 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -44,6 +44,7 @@ #include <QAuthenticator> #include <QClipboard> #include <QFileDialog> +#include <QKeyEvent> #include <QIcon> #include <QInputDialog> #include <QLayout> @@ -55,6 +56,8 @@ QT_BEGIN_NAMESPACE +using namespace QtWebEngineCore; + static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition) { switch (disposition) { @@ -240,10 +243,14 @@ qreal QWebEnginePagePrivate::dpiScale() const return 1.0; } -void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl) +void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage) { - Q_UNUSED(provisionalUrl) + Q_UNUSED(provisionalUrl); Q_Q(QWebEnginePage); + + if (isErrorPage) + return; + isLoading = true; Q_EMIT q->loadStarted(); updateNavigationActions(); @@ -254,12 +261,16 @@ void QWebEnginePagePrivate::loadCommitted() updateNavigationActions(); } -void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, int errorCode, const QString &errorDescription) +void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) { Q_Q(QWebEnginePage); Q_UNUSED(url); Q_UNUSED(errorCode); Q_UNUSED(errorDescription); + + if (isErrorPage) + return; + isLoading = false; if (success) explicitUrl = QUrl(); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 74e17fb39..ccfdd5d0e 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -44,8 +44,10 @@ #include <QtCore/qcompilerdetection.h> #include <QSharedData> +namespace QtWebEngineCore { class RenderWidgetHostViewQtDelegate; class WebContentsAdapter; +} QT_BEGIN_NAMESPACE class QWebEngineHistory; @@ -97,7 +99,7 @@ private: QHash<quint64, CallbackSharedDataPointer> m_callbackMap; }; -class QWebEnginePagePrivate : public WebContentsAdapterClient +class QWebEnginePagePrivate : public QtWebEngineCore::WebContentsAdapterClient { public: Q_DECLARE_PUBLIC(QWebEnginePage) @@ -106,8 +108,8 @@ public: QWebEnginePagePrivate(QWebEngineProfile *profile = 0); ~QWebEnginePagePrivate(); - virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE { return CreateRenderWidgetHostViewQtDelegate(client); } + virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; + virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE { return CreateRenderWidgetHostViewQtDelegate(client); } virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; @@ -116,20 +118,20 @@ public: virtual void selectionChanged() Q_DECL_OVERRIDE; virtual QRectF viewportRect() const Q_DECL_OVERRIDE; virtual qreal dpiScale() const Q_DECL_OVERRIDE; - virtual void loadStarted(const QUrl &provisionalUrl) Q_DECL_OVERRIDE; + virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; virtual void loadCommitted() Q_DECL_OVERRIDE; virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE { } - virtual void loadFinished(bool success, const QUrl &url, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; + virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QtWebEngineCore::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 bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) 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; - virtual void runFileChooser(FilePickerController *controller) Q_DECL_OVERRIDE; + virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; + virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE; virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; @@ -143,26 +145,26 @@ public: #ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; #endif // QT_NO_ACCESSIBILITY - virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; + virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE; - virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; + virtual QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; void updateAction(QWebEnginePage::WebAction) const; void updateNavigationActions(); void _q_webActionTriggered(bool checked); - WebContentsAdapter *webContents() { return adapter.data(); } + QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); } void recreateFromSerializedHistory(QDataStream &input); - QExplicitlySharedDataPointer<WebContentsAdapter> adapter; + QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter; QWebEngineHistory *history; QWebEngineProfile *profile; QWebEngineSettings *settings; QWebEngineView *view; QSize viewportSize; QUrl explicitUrl; - WebEngineContextMenuData m_menuData; + QtWebEngineCore::WebEngineContextMenuData m_menuData; bool isLoading; QWebEngineScriptCollection scriptCollection; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index e2441ca54..eb502d050 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using QtWebEngineCore::BrowserContextAdapter; + /*! \class QWebEngineProfile \brief The QWebEngineProfile class provides a web-engine profile shared by multiple pages. diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 6f2d53a81..6ae9f9ca9 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -44,19 +44,21 @@ #include <QMap> #include <QPointer> +namespace QtWebEngineCore { class BrowserContextAdapter; +} QT_BEGIN_NAMESPACE class QWebEngineSettings; -class QWebEngineProfilePrivate : public BrowserContextAdapterClient { +class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) - QWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext); + QWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext, bool ownsContext); ~QWebEngineProfilePrivate(); - BrowserContextAdapter *browserContext() const { return m_browserContext; } + QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContext; } QWebEngineSettings *settings() const { return m_settings; } void cancelDownload(quint32 downloadId); @@ -74,8 +76,8 @@ public: private: QWebEngineProfile *q_ptr; QWebEngineSettings *m_settings; - BrowserContextAdapter *m_browserContext; - QExplicitlySharedDataPointer<BrowserContextAdapter> m_browserContextRef; + QtWebEngineCore::BrowserContextAdapter *m_browserContext; + QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads; QMap<QByteArray, QPointer<QWebEngineUrlSchemeHandler> > m_urlSchemeHandlers; }; diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp index 63459992b..e2f267330 100644 --- a/src/webenginewidgets/api/qwebenginescript.cpp +++ b/src/webenginewidgets/api/qwebenginescript.cpp @@ -39,6 +39,8 @@ #include "user_script.h" #include <QtCore/QDebug> +using QtWebEngineCore::UserScript; + QWebEngineScript::QWebEngineScript() : d(new UserScript) { @@ -76,16 +78,16 @@ void QWebEngineScript::setName(const QString &scriptName) d->setName(scriptName); } -QString QWebEngineScript::source() const +QString QWebEngineScript::sourceCode() const { - return d->source(); + return d->sourceCode(); } -void QWebEngineScript::setSource(const QString &scriptSource) +void QWebEngineScript::setSourceCode(const QString &scriptSource) { - if (scriptSource == source()) + if (scriptSource == sourceCode()) return; - d->setSource(scriptSource); + d->setSourceCode(scriptSource); } ASSERT_ENUMS_MATCH(QWebEngineScript::Deferred, UserScript::AfterLoad) @@ -157,7 +159,7 @@ QDebug operator<<(QDebug d, const QWebEngineScript &script) break; } d << script.worldId() << ", " - << script.runsOnSubFrames() << ", " << script.source() << ")"; + << script.runsOnSubFrames() << ", " << script.sourceCode() << ")"; return d.space(); } #endif diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/webenginewidgets/api/qwebenginescript.h index 735ee92e0..2b03cd06f 100644 --- a/src/webenginewidgets/api/qwebenginescript.h +++ b/src/webenginewidgets/api/qwebenginescript.h @@ -41,7 +41,10 @@ #include <QtCore/QSharedDataPointer> #include <QtCore/QString> +namespace QtWebEngineCore { class UserScript; +} // namespace + QT_BEGIN_NAMESPACE class QWEBENGINEWIDGETS_EXPORT QWebEngineScript { @@ -69,8 +72,8 @@ public: QString name() const; void setName(const QString &); - QString source() const; - void setSource(const QString &); + QString sourceCode() const; + void setSourceCode(const QString &); InjectionPoint injectionPoint() const; void setInjectionPoint(InjectionPoint); @@ -90,9 +93,9 @@ public: private: friend class QWebEngineScriptCollectionPrivate; friend class QWebEngineScriptCollection; - QWebEngineScript(const UserScript &); + QWebEngineScript(const QtWebEngineCore::UserScript &); - QSharedDataPointer<UserScript> d; + QSharedDataPointer<QtWebEngineCore::UserScript> d; }; Q_DECLARE_SHARED(QWebEngineScript) diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index ffbb9052e..2f1f31b0e 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -39,6 +39,8 @@ #include "user_script_controller_host.h" +using QtWebEngineCore::UserScript; + QWebEngineScriptCollection::QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *collectionPrivate) :d(collectionPrivate) { @@ -96,7 +98,7 @@ QList<QWebEngineScript> QWebEngineScriptCollection::toList() const } -QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(UserScriptControllerHost *controller, WebContentsAdapter *webContents) +QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *controller, QtWebEngineCore::WebContentsAdapter *webContents) : m_scriptController(controller) , m_contents(webContents) { diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h index baf09dbb4..9a3a425ba 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h +++ b/src/webenginewidgets/api/qwebenginescriptcollection_p.h @@ -43,13 +43,15 @@ #include <QtCore/QSet> +namespace QtWebEngineCore { class UserScriptControllerHost; class WebContentsAdapter; +} // namespace QT_BEGIN_NAMESPACE class QWebEngineScriptCollectionPrivate { public: - QWebEngineScriptCollectionPrivate(UserScriptControllerHost *, WebContentsAdapter * = 0); + QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *, QtWebEngineCore::WebContentsAdapter * = 0); int count() const; bool contains(const QWebEngineScript &) const; @@ -62,8 +64,8 @@ public: void reserve(int); private: - UserScriptControllerHost *m_scriptController; - WebContentsAdapter *m_contents; + QtWebEngineCore::UserScriptControllerHost *m_scriptController; + QtWebEngineCore::WebContentsAdapter *m_contents; }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index f7dcafa59..dadc3bfe1 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -41,6 +41,8 @@ QT_BEGIN_NAMESPACE +using QtWebEngineCore::WebEngineSettings; + static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::WebAttribute attribute) { switch (attribute) { diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h index ff8fad25e..44339a2f6 100644 --- a/src/webenginewidgets/api/qwebenginesettings.h +++ b/src/webenginewidgets/api/qwebenginesettings.h @@ -25,7 +25,9 @@ #include <QtCore/qscopedpointer.h> #include <QtCore/qstring.h> +namespace QtWebEngineCore { class WebEngineSettings; +} QT_BEGIN_NAMESPACE @@ -88,7 +90,7 @@ public: private: Q_DISABLE_COPY(QWebEngineSettings) - typedef WebEngineSettings QWebEngineSettingsPrivate; + typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate; QWebEngineSettingsPrivate* d_func() { return d_ptr.data(); } const QWebEngineSettingsPrivate* d_func() const { return d_ptr.data(); } QScopedPointer<QWebEngineSettingsPrivate> d_ptr; diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp index e937a5bba..cb8b200a2 100644 --- a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp +++ b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE -QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(URLRequestCustomJobDelegate * p) +QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate * p) : QObject(p) // owned by the jobdelegate and deleted when the job is done , d_ptr(p) { diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h b/src/webenginewidgets/api/qwebengineurlrequestjob_p.h index 3aea80d2f..72c9dc836 100644 --- a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h +++ b/src/webenginewidgets/api/qwebengineurlrequestjob_p.h @@ -43,7 +43,9 @@ #include <QtCore/QObject> #include <QtCore/QUrl> +namespace QtWebEngineCore { class URLRequestCustomJobDelegate; +} // namespace QT_BEGIN_NAMESPACE @@ -58,10 +60,10 @@ public: void setReply(const QByteArray &contentType, QIODevice *device); private: - QWebEngineUrlRequestJob(URLRequestCustomJobDelegate *); + QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *); friend class QWebEngineUrlSchemeHandlerPrivate; - URLRequestCustomJobDelegate* d_ptr; + QtWebEngineCore::URLRequestCustomJobDelegate* d_ptr; }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp b/src/webenginewidgets/api/qwebengineurlschemehandler.cpp index ccb92258b..16ad220b2 100644 --- a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp +++ b/src/webenginewidgets/api/qwebengineurlschemehandler.cpp @@ -54,7 +54,7 @@ QWebEngineUrlSchemeHandlerPrivate::~QWebEngineUrlSchemeHandlerPrivate() { } -bool QWebEngineUrlSchemeHandlerPrivate::handleJob(URLRequestCustomJobDelegate *job) +bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCustomJobDelegate *job) { QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(job); q_ptr->requestStarted(requestJob); diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h b/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h index 6146cc05e..b15171edc 100644 --- a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h +++ b/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h @@ -49,14 +49,14 @@ class QWebEngineProfile; class QWebEngineUrlRequestJob; class QWebEngineUrlSchemeHandler; -class QWebEngineUrlSchemeHandlerPrivate : public CustomUrlSchemeHandler { +class QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler { public: Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler) QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *, QWebEngineProfile *); virtual ~QWebEngineUrlSchemeHandlerPrivate(); - virtual bool handleJob(URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE; + virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE; private: QWebEngineUrlSchemeHandler *q_ptr; diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 252b13fa4..865d0f93f 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -49,6 +49,7 @@ #include <private/qsgcontext_p.h> #include <private/qsgengine_p.h> +namespace QtWebEngineCore { static const int MaxTooltipLength = 1024; @@ -294,3 +295,5 @@ void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged() { m_client->windowBoundsChanged(); } + +} // namespace QtWebEngineCore diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index 54fdf3b29..d0dfdc689 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -50,6 +50,8 @@ #include <QtWidgets/QOpenGLWidget> #endif +namespace QtWebEngineCore { + class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public RenderWidgetHostViewQtDelegate { Q_OBJECT public: @@ -99,4 +101,6 @@ private: QList<QMetaObject::Connection> m_windowConnections; }; +} // namespace QtWebEngineCore + #endif diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 98e52352f..1cf2e37c4 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -73,6 +73,7 @@ static QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>() << &QQuickWebEngineNewViewRequest::staticMetaObject << &QQuickWebEngineProfile::staticMetaObject << &QQuickWebEngineScript::staticMetaObject + << &QQuickWebEngineFullScreenRequest::staticMetaObject ; static QList<const char *> knownEnumNames = QList<const char *>(); @@ -127,6 +128,7 @@ static QStringList expectedAPI = QStringList() << "QQuickWebEngineView.icon --> QUrl" << "QQuickWebEngineView.canGoBack --> bool" << "QQuickWebEngineView.canGoForward --> bool" + << "QQuickWebEngineView.isFullScreen --> bool" << "QQuickWebEngineView.loading --> bool" << "QQuickWebEngineView.loadProgress --> int" << "QQuickWebEngineView.titleChanged() --> void" @@ -138,6 +140,9 @@ static QStringList expectedAPI = QStringList() << "QQuickWebEngineView.iconChanged() --> void" << "QQuickWebEngineView.linkHovered(QUrl) --> void" << "QQuickWebEngineView.navigationRequested(QQuickWebEngineNavigationRequest*) --> void" + << "QQuickWebEngineView.fullScreenRequested(QQuickWebEngineFullScreenRequest) --> void" + << "QQuickWebEngineView.isFullScreenChanged() --> void" + << "QQuickWebEngineView.fullScreenCancelled() --> void" << "QQuickWebEngineView.runJavaScript(QString,QJSValue) --> void" << "QQuickWebEngineView.runJavaScript(QString) --> void" << "QQuickWebEngineView.loadHtml(QString,QUrl) --> void" @@ -218,21 +223,23 @@ static QStringList expectedAPI = QStringList() << "QQuickWebEngineScript.ApplicationWorld --> ScriptWorldId" << "QQuickWebEngineScript.UserWorld --> ScriptWorldId" << "QQuickWebEngineScript.name --> QString" - << "QQuickWebEngineScript.source --> QString" + << "QQuickWebEngineScript.sourceCode --> QString" << "QQuickWebEngineScript.injectionPoint --> InjectionPoint" << "QQuickWebEngineScript.worldId --> ScriptWorldId" << "QQuickWebEngineScript.runOnSubframes --> bool" << "QQuickWebEngineScript.nameChanged(QString) --> void" - << "QQuickWebEngineScript.sourceChanged(QString) --> void" + << "QQuickWebEngineScript.sourceCodeChanged(QString) --> void" << "QQuickWebEngineScript.injectionPointChanged(InjectionPoint) --> void" << "QQuickWebEngineScript.worldIdChanged(ScriptWorldId) --> void" << "QQuickWebEngineScript.runOnSubframesChanged(bool) --> void" << "QQuickWebEngineScript.setName(QString) --> void" - << "QQuickWebEngineScript.setSource(QString) --> void" + << "QQuickWebEngineScript.setSourceCode(QString) --> void" << "QQuickWebEngineScript.setInjectionPoint(InjectionPoint) --> void" << "QQuickWebEngineScript.setWorldId(ScriptWorldId) --> void" << "QQuickWebEngineScript.setRunOnSubframes(bool) --> void" << "QQuickWebEngineScript.toString() --> QString" + << "QQuickWebEngineFullScreenRequest.toggleOn --> bool" + << "QQuickWebEngineFullScreenRequest.accept() --> void" ; static bool isCheckedEnum(const QByteArray &typeName) diff --git a/tests/auto/quick/qmltests/data/alert.html b/tests/auto/quick/qmltests/data/alert.html new file mode 100644 index 000000000..39a853519 --- /dev/null +++ b/tests/auto/quick/qmltests/data/alert.html @@ -0,0 +1,8 @@ +<!doctype html> +<html> +<head> + <script> alert("Hello Qt"); </script> +</head> +<body> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/confirm.html b/tests/auto/quick/qmltests/data/confirm.html new file mode 100644 index 000000000..d7256a883 --- /dev/null +++ b/tests/auto/quick/qmltests/data/confirm.html @@ -0,0 +1,19 @@ +<!doctype html> +<html> +<head> + <script> + document.title = ""; + function updateTitle(accepted) { + if (accepted) + document.title += " ACCEPTED"; + else + document.title += " REJECTED"; + } + + updateTitle(confirm("ACCEPT")); + updateTitle(confirm("REJECT")); + </script> +</head> +<body> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/prompt.html b/tests/auto/quick/qmltests/data/prompt.html new file mode 100644 index 000000000..ae5fbd07a --- /dev/null +++ b/tests/auto/quick/qmltests/data/prompt.html @@ -0,0 +1,12 @@ +<!doctype html> +<html> +<head> + <script> + document.title = prompt("Please, reverse the default value", "Hello Qt"); + if (prompt("REJECT") !== null) + document.title = "FAIL"; + </script> +</head> +<body> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index 1cb23a1c4..5f72c52fa 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -42,7 +42,6 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebEngine 1.1 -import QtWebEngine.experimental 1.0 TestWebEngineView { id: webEngineView @@ -67,12 +66,12 @@ TestWebEngineView { name: "WebViewFindText" function test_findText() { - var findFlags = WebEngineViewExperimental.FindCaseSensitively + var findFlags = WebEngineView.FindCaseSensitively webEngineView.url = Qt.resolvedUrl("test1.html") verify(webEngineView.waitForLoadSucceeded()) webEngineView.clear() - webEngineView.experimental.findText("Hello", findFlags, webEngineView.findTextCallback) + webEngineView.findText("Hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) } @@ -83,7 +82,7 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()) webEngineView.clear() - webEngineView.experimental.findText("heLLo", findFlags, webEngineView.findTextCallback) + webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) } @@ -94,19 +93,19 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()) webEngineView.clear() - webEngineView.experimental.findText("bla", findFlags, webEngineView.findTextCallback) + webEngineView.findText("bla", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 100) verify(!findFailed) } function test_findTextFailCaseSensitive() { - var findFlags = WebEngineViewExperimental.FindCaseSensitively + var findFlags = WebEngineView.FindCaseSensitively webEngineView.url = Qt.resolvedUrl("test1.html") verify(webEngineView.waitForLoadSucceeded()) webEngineView.clear() - webEngineView.experimental.findText("heLLo", findFlags, webEngineView.findTextCallback) + webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0) verify(findFailed) } @@ -117,7 +116,7 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()) webEngineView.clear() - webEngineView.experimental.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback) + webEngineView.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0) verify(findFailed) } diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml new file mode 100644 index 000000000..da04fbd92 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtWebEngine 1.0 +import QtWebEngine.testsupport 1.0 + +TestWebEngineView { + id: webEngineView + + property string messageFromAlertDialog: "" + property int confirmCount: 0 + property int promptCount: 0 + + testSupport: WebEngineTestSupport { + onAlertDialog: { + webEngineView.messageFromAlertDialog = dialog.message + dialog.accept() + } + + onConfirmDialog: { + webEngineView.confirmCount += 1 + if (dialog.message == "ACCEPT") + dialog.accept() + else + dialog.reject() + } + + onPromptDialog: { + webEngineView.promptCount += 1 + if (dialog.message == "REJECT") + dialog.reject() + else { + var reversedDefaultValue = dialog.defaultValue.split("").reverse().join("") + dialog.accept(reversedDefaultValue) + } + } + } + + TestCase { + id: test + name: "WebEngineViewJavaScriptDialogs" + + function init() { + webEngineView.messageFromAlertDialog = "" + webEngineView.confirmCount = 0 + webEngineView.promptCount = 0 + } + + function test_alert() { + webEngineView.url = Qt.resolvedUrl("alert.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.messageFromAlertDialog, "Hello Qt") + } + + function test_confirm() { + webEngineView.url = Qt.resolvedUrl("confirm.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.confirmCount, 2) + compare(webEngineView.title, "ACCEPTED REJECTED") + } + + function test_prompt() { + webEngineView.url = Qt.resolvedUrl("prompt.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.promptCount, 2) + compare(webEngineView.title, "tQ olleH") + } + } +} diff --git a/tests/auto/quick/qmltests/data/tst_loadFail.qml b/tests/auto/quick/qmltests/data/tst_loadFail.qml index e88d82903..7b5bbe2e2 100644 --- a/tests/auto/quick/qmltests/data/tst_loadFail.qml +++ b/tests/auto/quick/qmltests/data/tst_loadFail.qml @@ -43,36 +43,69 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebEngine 1.1 import QtWebEngine.experimental 1.0 +import QtWebEngine.testsupport 1.0 TestWebEngineView { id: webEngineView width: 400 height: 300 - property variant unavailableUrl + property var unavailableUrl: Qt.resolvedUrl("file_that_does_not_exist.html") + property var loadRequestArray: [] + + testSupport: WebEngineTestSupport { + property var errorPageLoadStatus: null + + function waitForErrorPageLoadSucceeded() { + var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus }) + testSupport.errorPageLoadStatus = null + return success + } + + errorPage.onLoadingChanged: { + errorPageLoadStatus = loadRequest.status + + loadRequestArray.push({ + "status": loadRequest.status, + "url": loadRequest.url.toString(), + "errorDomain": loadRequest.errorDomain, + "isErrorPage": true + }) + } + } + + onLoadingChanged: { + if (loadRequest.status == WebEngineView.LoadFailedStatus) { + test.compare(loadRequest.url, unavailableUrl) + test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain) + } + + loadRequestArray.push({ + "status": loadRequest.status, + "url": loadRequest.url.toString(), + "errorDomain": loadRequest.errorDomain, + "isErrorPage": false + }) + } TestCase { id: test name: "WebEngineViewLoadFail" - function initTestCase() { - WebEngine.settings.errorPageEnabled = false - } - function test_fail() { - unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html") + WebEngine.settings.errorPageEnabled = false webEngineView.url = unavailableUrl verify(webEngineView.waitForLoadFailed()) } function test_fail_url() { + WebEngine.settings.errorPageEnabled = false var url = Qt.resolvedUrl("test1.html") webEngineView.url = url compare(webEngineView.url, url) verify(webEngineView.waitForLoadSucceeded()) compare(webEngineView.url, url) - unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html") webEngineView.url = unavailableUrl compare(webEngineView.url, unavailableUrl) verify(webEngineView.waitForLoadFailed()) @@ -80,12 +113,47 @@ TestWebEngineView { // We expect the url of the previously loaded page here. compare(webEngineView.url, url) } - } - onLoadingChanged: { - if (loadRequest.status == WebEngineView.LoadFailedStatus) { - test.compare(loadRequest.url, unavailableUrl) - test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain) + function test_error_page() { + WebEngine.settings.errorPageEnabled = true + webEngineView.url = unavailableUrl + + // Loading of the error page must be successful + verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded()) + + var loadRequest = null + compare(loadRequestArray.length, 4) + + // Start to load unavailableUrl + loadRequest = loadRequestArray[0] + compare(loadRequest.status, WebEngineView.LoadStartedStatus) + compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain) + compare(loadRequest.url, unavailableUrl) + verify(!loadRequest.isErrorPage) + + // Loading of the unavailableUrl must fail + loadRequest = loadRequestArray[1] + compare(loadRequest.status, WebEngineView.LoadFailedStatus) + compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain) + compare(loadRequest.url, unavailableUrl) + verify(!loadRequest.isErrorPage) + + // Start to load error page + loadRequest = loadRequestArray[2] + compare(loadRequest.status, WebEngineView.LoadStartedStatus) + compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain) + compare(loadRequest.url, "data:text/html,chromewebdata") + verify(loadRequest.isErrorPage) + + // Loading of the error page must be successful + loadRequest = loadRequestArray[3] + compare(loadRequest.status, WebEngineView.LoadSucceededStatus) + compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain) + compare(loadRequest.url, "data:text/html,chromewebdata") + verify(loadRequest.isErrorPage) + + compare(webEngineView.url, unavailableUrl) + compare(webEngineView.title, unavailableUrl + " is not found") } } } diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 335d9155e..ea56cc29e 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -42,7 +42,6 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebEngine 1.1 -import QtWebEngine.experimental 1.0 TestWebEngineView { id: webEngineView @@ -52,7 +51,7 @@ TestWebEngineView { ListView { id: backItemsList anchors.fill: parent - model: webEngineView.experimental.navigationHistory.backItems + model: webEngineView.navigationHistory.backItems currentIndex: count - 1 delegate: Text { @@ -64,7 +63,7 @@ TestWebEngineView { ListView { id: forwardItemsList anchors.fill: parent - model: webEngineView.experimental.navigationHistory.forwardItems + model: webEngineView.navigationHistory.forwardItems currentIndex: 0 delegate: Text { @@ -94,7 +93,7 @@ TestWebEngineView { compare(backItemsList.count, 1) compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html")) - webEngineView.experimental.goBackTo(0) + webEngineView.goBackOrForward(-1) verify(webEngineView.waitForLoadSucceeded()) compare(webEngineView.url, Qt.resolvedUrl("test1.html")) compare(webEngineView.canGoBack, false) @@ -121,7 +120,7 @@ TestWebEngineView { compare(forwardItemsList.count, 0) compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html")) - webEngineView.experimental.goBackTo(1) + webEngineView.goBackOrForward(-2) verify(webEngineView.waitForLoadSucceeded()) compare(webEngineView.url, Qt.resolvedUrl("test1.html")) compare(webEngineView.canGoBack, false) @@ -130,7 +129,7 @@ TestWebEngineView { compare(forwardItemsList.count, 2) compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("test2.html")) - webEngineView.experimental.goForwardTo(1) + webEngineView.goBackOrForward(2) verify(webEngineView.waitForLoadSucceeded()) compare(webEngineView.url, Qt.resolvedUrl("javascript.html")) compare(webEngineView.canGoBack, true) diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index 6789b714b..4b6795ae1 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -6,11 +6,14 @@ IMPORTPATH += $$PWD/data OTHER_FILES += \ $$PWD/data/TestWebEngineView.qml \ + $$PWD/data/alert.html \ + $$PWD/data/confirm.html \ $$PWD/data/favicon.html \ $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ $$PWD/data/javascript.html \ $$PWD/data/link.html \ + $$PWD/data/prompt.html \ $$PWD/data/redirect.html \ $$PWD/data/small-favicon.png \ $$PWD/data/test1.html \ @@ -20,6 +23,7 @@ OTHER_FILES += \ $$PWD/data/keyboardModifierMapping.html \ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \ $$PWD/data/tst_favIconLoad.qml \ + $$PWD/data/tst_javaScriptDialogs.qml \ $$PWD/data/tst_linkHovered.qml \ $$PWD/data/tst_loadFail.qml \ $$PWD/data/tst_loadHtml.qml \ @@ -37,3 +41,22 @@ OTHER_FILES += \ load(qt_build_paths) DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD$${QMAKE_DIR_SEP}data\\\"\" + +!isQMLTestSupportApiEnabled() { + PLUGIN_EXTENSION = .so + PLUGIN_PREFIX = lib + osx: PLUGIN_PREFIX = .dylib + win32 { + PLUGIN_EXTENSION = .dll + PLUGIN_PREFIX = + } + + TESTSUPPORT_MODULE = $$shell_path($$[QT_INSTALL_QML]/QtWebEngine/testsupport/$${PLUGIN_PREFIX}qtwebenginetestsupportplugin$${PLUGIN_EXTENSION}) + BUILD_DIR = $$shell_path($$clean_path($$OUT_PWD/../../../..)) + SRC_DIR = $$shell_path($$clean_path($$PWD/../../../..)) + + warning("QML Test Support API is disabled. This means some QML tests that use Test Support API will fail.") + warning("Use the following command to build Test Support module and rebuild WebEngineView API:") + warning("cd $$BUILD_DIR && qmake WEBENGINE_CONFIG+=testsupport -r $$shell_path($$SRC_DIR/qtwebengine.pro) && make -C $$shell_path($$BUILD_DIR/src/webengine) clean && make") + warning("After performing the command above make sure QML module \"QtWebEngine.testsupport\" is deployed at $$TESTSUPPORT_MODULE") +} diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml index 2c8e9e1ea..9e9f73646 100644 --- a/tests/quicktestbrowser/BrowserWindow.qml +++ b/tests/quicktestbrowser/BrowserWindow.qml @@ -54,12 +54,16 @@ ApplicationWindow { id: browserWindow property QtObject applicationRoot property Item currentWebView: tabs.currentIndex < tabs.count ? tabs.getTab(tabs.currentIndex).item.webView : null + property int previousVisibility: Window.Windowed property bool isFullScreen: visibility == Window.FullScreen onIsFullScreenChanged: { // This is for the case where the system forces us to leave fullscreen. - if (currentWebView) - currentWebView.state = isFullScreen ? "FullScreen" : "" + if (currentWebView && !isFullScreen) { + currentWebView.state = "" + if (currentWebView.isFullScreen) + currentWebView.fullScreenCancelled() + } } height: 600 @@ -89,7 +93,7 @@ ApplicationWindow { offTheRecord: true } - // Make sure the Qt.WindowFullscreenButtonHint is set on Mac. + // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint // Create a styleItem to determine the platform. @@ -141,7 +145,7 @@ ApplicationWindow { shortcut: "Escape" onTriggered: { if (browserWindow.isFullScreen) - browserWindow.showNormal() + browserWindow.visibility = browserWindow.previousVisibility } } Action { @@ -357,10 +361,12 @@ ApplicationWindow { ] onCertificateError: { - sslDialog.certError = error - sslDialog.text = "Certificate Error: " + error.description - sslDialog.visible = true - error.defer() + if (!acceptedCertificates.shouldAutoAccept(error)){ + error.defer() + sslDialog.enqueue(error) + } else{ + error.ignoreCertificateError() + } } onNewViewRequested: { @@ -378,18 +384,19 @@ ApplicationWindow { } } - experimental { - isFullScreen: webEngineView.state == "FullScreen" && browserWindow.isFullScreen - onFullScreenRequested: { - if (fullScreen) { - webEngineView.state = "FullScreen" - browserWindow.showFullScreen(); - } else { - webEngineView.state = "" - browserWindow.showNormal(); - } + onFullScreenRequested: { + if (request.toggleOn) { + webEngineView.state = "FullScreen" + browserWindow.previousVisibility = browserWindow.visibility + browserWindow.showFullScreen() + } else { + webEngineView.state = "" + browserWindow.visibility = browserWindow.previousVisibility } + request.accept() + } + experimental { onFeaturePermissionRequested: { permBar.securityOrigin = securityOrigin; permBar.requestedFeature = feature; @@ -416,18 +423,18 @@ ApplicationWindow { TextField { id: findTextField onAccepted: { - webEngineView.experimental.findText(text, 0) + webEngineView.findText(text) } } ToolButton { id: findBackwardButton iconSource: "icons/go-previous.png" - onClicked: webEngineView.experimental.findText(findTextField.text, WebEngineViewExperimental.FindBackward) + onClicked: webEngineView.findText(findTextField.text, WebEngineView.FindBackward) } ToolButton { id: findForwardButton iconSource: "icons/go-next.png" - onClicked: webEngineView.experimental.findText(findTextField.text, 0) + onClicked: webEngineView.findText(findTextField.text) } ToolButton { id: findCancelButton @@ -440,17 +447,50 @@ ApplicationWindow { } } + QtObject{ + id:acceptedCertificates + + property var acceptedUrls : [] + + function shouldAutoAccept(certificateError){ + var domain = utils.domainFromString(certificateError.url) + return acceptedUrls.indexOf(domain) >= 0 + } + } + MessageDialog { id: sslDialog - property var certError - - standardButtons: StandardButton.Cancel | StandardButton.Ok - visible: false - title: "Do you want to accept this certificate?" + property var certErrors: [] + icon: StandardIcon.Warning + standardButtons: StandardButton.No | StandardButton.Yes + title: "Server's certificate not trusted" + text: "Do you wish to continue?" + detailedText: "If you wish so, you may continue with an unverified certificate. " + + "Accepting an unverified certificate means " + + "you may not be connected with the host you tried to connect to.\n" + + "Do you wish to override the security check and continue?" + onYes: { + var cert = certErrors.shift() + var domain = utils.domainFromString(cert.url) + acceptedCertificates.acceptedUrls.push(domain) + cert.ignoreCertificateError() + presentError() + } + onNo: reject() + onRejected: reject() - onAccepted: certError.ignoreCertificateError() - onRejected: certError.rejectCertificate() + function reject(){ + certErrors.shift().rejectCertificate() + presentError() + } + function enqueue(error){ + certErrors.push(error) + presentError() + } + function presentError(){ + visible = certErrors.length > 0 + } } DownloadView { diff --git a/tests/quicktestbrowser/utils.h b/tests/quicktestbrowser/utils.h index 0f4460dfe..52025b7e4 100644 --- a/tests/quicktestbrowser/utils.h +++ b/tests/quicktestbrowser/utils.h @@ -48,6 +48,7 @@ class Utils : public QObject { Q_OBJECT public: Q_INVOKABLE static QUrl fromUserInput(const QString& userInput); + Q_INVOKABLE static QString domainFromString(const QString& urlString); }; inline QUrl Utils::fromUserInput(const QString& userInput) @@ -58,4 +59,9 @@ inline QUrl Utils::fromUserInput(const QString& userInput) return QUrl::fromUserInput(userInput); } +inline QString Utils::domainFromString(const QString& urlString) +{ + return QUrl::fromUserInput(urlString).host(); +} + #endif // UTILS_H diff --git a/tools/qmake/config.tests/khr/khr.cpp b/tools/qmake/config.tests/khr/khr.cpp new file mode 100644 index 000000000..6182df286 --- /dev/null +++ b/tools/qmake/config.tests/khr/khr.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.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 <KHR/khrplatform.h> + +int main(int, char **) +{ + const khronos_boolean_enum_t kfalse = KHRONOS_FALSE; + const khronos_boolean_enum_t ktrue = KHRONOS_TRUE; + return kfalse == ktrue; +} diff --git a/tools/qmake/config.tests/khr/khr.pro b/tools/qmake/config.tests/khr/khr.pro new file mode 100644 index 000000000..6abd2367a --- /dev/null +++ b/tools/qmake/config.tests/khr/khr.pro @@ -0,0 +1,2 @@ +CONFIG-=qt +linux:SOURCES += khr.cpp diff --git a/tools/qmake/mkspecs/features/configure.prf b/tools/qmake/mkspecs/features/configure.prf index 6e74b5547..7b111b78f 100644 --- a/tools/qmake/mkspecs/features/configure.prf +++ b/tools/qmake/mkspecs/features/configure.prf @@ -20,7 +20,8 @@ defineTest(runConfigure) { qtCompileTest($$test) } # libcap-dev package doesn't ship .pc files on Ubuntu. - linux:!config_libcap:skipBuild("libcap appears to be missing") + linux:!config_libcap:skipBuild("libcap development package appears to be missing") + linux:!config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)") contains(QT_CONFIG, xcb) { for(package, $$list("libdrm xcomposite xi xrandr")) { !packagesExist($$package):skipBuild("Unmet dependency: $$package") diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf index 2e2261cb9..a34bd23c6 100644 --- a/tools/qmake/mkspecs/features/functions.prf +++ b/tools/qmake/mkspecs/features/functions.prf @@ -37,6 +37,12 @@ defineTest(isGCCVersionSupported) { return(false) } +defineTest(isQMLTestSupportApiEnabled) { + contains(QT_BUILD_PARTS, tests): return(true) + contains(WEBENGINE_CONFIG, testsupport): return(true) + return(false) +} + # Map to the correct target type for gyp defineReplace(toGypTargetType) { equals(TEMPLATE, "app"):return("executable") |