From e43a2219fb1c230439a550ef6a3866de55352018 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 11 Jan 2016 16:06:01 +0100 Subject: Send proper key codes for KeyEvents to WebKit. A few KeyEvents to key code mappings were incorrect or missing. Fix them. Change-Id: I74087768fddd467993f04ed8b4c2dc6345d20e8a Task-number: QTBUG-50354 Reviewed-by: Allan Sandfeld Jensen --- src/core/web_event_factory.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index 1a58ae385..1306f6f3b 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -264,9 +264,10 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) case Qt::Key_Help: return VK_HELP; // (2F) HELP key case Qt::Key_0: - case Qt::Key_ParenLeft: + case Qt::Key_ParenRight: return VK_0; // (30) 0) key case Qt::Key_1: + case Qt::Key_Exclam: return VK_1; // (31) 1 ! key case Qt::Key_2: case Qt::Key_At: @@ -290,7 +291,7 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) case Qt::Key_Asterisk: return VK_8; // (38) 8 key '*' case Qt::Key_9: - case Qt::Key_ParenRight: + case Qt::Key_ParenLeft: return VK_9; // (39) 9 key '(' case Qt::Key_A: return VK_A; // (41) A key case 'a': case 'A': return 0x41; @@ -428,6 +429,7 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) case Qt::Key_BraceRight: return VK_OEM_6; // case ']': case '}': return 0xDD; // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key + case Qt::Key_Apostrophe: case Qt::Key_QuoteDbl: return VK_OEM_7; // case '\'': case '"': return 0xDE; // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. -- cgit v1.2.3 From 532a69c6fea4963c0ea1011270949fa92035a780 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 12 Jan 2016 13:38:12 +0100 Subject: Update key code mappings using QtWebkit mappings as reference. Copy additional key code mappings from PlatformKeyboardEventQt.cpp. Also add a mapping for missing numeric keypad equals key. Change-Id: Ia6c4413795293be84bcd8ea9d981d8cdfb94509b Task-number: QTBUG-50401 Reviewed-by: Joerg Bornemann --- src/core/web_event_factory.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index 1306f6f3b..2e6fde214 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -109,6 +109,8 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) return VK_DECIMAL; // (6E) Decimal key case Qt::Key_Slash: return VK_DIVIDE; // (6F) Divide key + case Qt::Key_Equal: + return VK_OEM_PLUS; // (BB) Equal key case Qt::Key_PageUp: return VK_PRIOR; // (21) PAGE UP key case Qt::Key_PageDown: @@ -376,13 +378,22 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key - // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key - // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key - // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key - // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key - // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key - // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key - // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key + + case Qt::Key_VolumeMute: + return VK_VOLUME_MUTE; // (AD) Windows 2000/XP: Volume Mute key + case Qt::Key_VolumeDown: + return VK_VOLUME_DOWN; // (AE) Windows 2000/XP: Volume Down key + case Qt::Key_VolumeUp: + return VK_VOLUME_UP; // (AF) Windows 2000/XP: Volume Up key + case Qt::Key_MediaNext: + return VK_MEDIA_NEXT_TRACK; // (B0) Windows 2000/XP: Next Track key + case Qt::Key_MediaPrevious: + return VK_MEDIA_PREV_TRACK; // (B1) Windows 2000/XP: Previous Track key + case Qt::Key_MediaStop: + return VK_MEDIA_STOP; // (B2) Windows 2000/XP: Stop Media key + case Qt::Key_MediaTogglePlayPause: + return VK_MEDIA_PLAY_PAUSE; // (B3) Windows 2000/XP: Play/Pause Media key + // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key @@ -434,6 +445,12 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) return VK_OEM_7; // case '\'': case '"': return 0xDE; // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard + + case Qt::Key_AudioRewind: + return 0xE3; // (E3) Android/GoogleTV: Rewind media key (Windows: VK_ICO_HELP Help key on 1984 Olivetti M24 deluxe keyboard) + case Qt::Key_AudioForward: + return 0xE4; // (E4) Android/GoogleTV: Fast forward media key (Windows: VK_ICO_00 '00' key on 1984 Olivetti M24 deluxe keyboard) + // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP // VK_ATTN (F6) Attn key -- cgit v1.2.3 From 811e583807d7f1f6654aca926f2c6830b88f21af Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 11 Jan 2016 14:54:40 +0100 Subject: Fix access violation error because of access to an invalid QString. Commit 6ed125c0073288f46e544b9d415d1f9a9968cb2d introduced the usage of QT_USE_QSTRINGBUILDER, which caused an issue in BrowserContextAdapter::httpAcceptLanguageWithoutQualities, incorrectly deducing the return type of the lambda. Fix consists in explicitly setting the return type of the lambda to QString. Change-Id: If3f8992e031838e899d35bcd2f962d051976a8f7 Reviewed-by: Joerg Bornemann --- src/core/browser_context_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 0bbb13857..b9d439596 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -406,7 +406,7 @@ QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const { const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); return std::accumulate(list.constBegin(), list.constEnd(), QString(), - [](const QString &r, const QString &e) { + [](const QString &r, const QString &e) -> QString { return (r.isEmpty() ? r : r + QString(QLatin1Char(','))) + e.split(QLatin1Char(';')).first(); }); -- cgit v1.2.3 From 3c6eb1d5a1344bd60e9fc812b999695957d7028a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 13 Jan 2016 15:30:15 +0100 Subject: Fix tst_QQuickWebEngineViewGraphics::showHideShow for OS X Defer the TestView::exposeChanged signal. On OS X exposeEvent is called directly by view->show(). Thus exposeChanged was emitted before signalSpy.wait() was called and the check on wait consequently failed. Change-Id: Ie318f8ddc0d1bcc35a14c73e615798b3e164739c Reviewed-by: Allan Sandfeld Jensen --- .../tst_qquickwebengineviewgraphics.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp index a969993ff..eacd1f87e 100644 --- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp +++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp @@ -52,12 +52,19 @@ class TestView : public QQuickView { Q_OBJECT public: + TestView() + { + connect(this, &TestView::_q_exposeChanged, this, &TestView::exposeChanged, + Qt::QueuedConnection); + } + virtual void exposeEvent(QExposeEvent *e) Q_DECL_OVERRIDE { QQuickView::exposeEvent(e); - emit exposeChanged(); + emit _q_exposeChanged(); } Q_SIGNALS: + void _q_exposeChanged(); void exposeChanged(); }; -- cgit v1.2.3 From 80e61853071de837416d80a203d6ed188b10b221 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 17 Dec 2015 18:29:32 +0200 Subject: Show host only in authentication dialog to reduce window size Change-Id: I6742fb003420404dafdcf204b5c3e9ffd9f474fc Reviewed-by: Joerg Bornemann --- src/webengine/ui_delegates_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index 64e22c4a9..96b3e3a77 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -346,8 +346,9 @@ void UIDelegatesManager::showDialog(QSharedPointerhost().toHtmlEscaped()); } else { - introMessage = tr("Enter username and password for \"%1\" at %2"); - introMessage = introMessage.arg(dialogController->realm()).arg(dialogController->url().toString().toHtmlEscaped()); + const QUrl url = dialogController->url(); + introMessage = tr("Enter username and password for \"%1\" at %2://%3"); + introMessage = introMessage.arg(dialogController->realm(), url.scheme(), url.host()); } QQmlProperty textProp(authenticationDialog, QStringLiteral("text")); textProp.write(introMessage); -- cgit v1.2.3 From f32f4af43c207072e6bb175b9e63e0d3ebc2cc1d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 13 Jan 2016 11:48:34 +0100 Subject: Update license header for qwebenginepage.cpp to LGPLv3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This amends commit 3b4eec9b. Change-Id: I19e8a295fa7e64ff83c26b6965097bd0ae3cbf73 Reviewed-by: Michael Brüning --- src/webenginewidgets/api/qwebenginepage.cpp | 56 ++++++++++++++++++----------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 61feec244..c89f73724 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -1,24 +1,38 @@ -/* - Copyright (C) 2015 The Qt Company Ltd. - Copyright (C) 2008, 2009, 2012 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2007 Staikos Computing Services Inc. - Copyright (C) 2007 Apple Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ +/**************************************************************************** +** +** Copyright (C) 2016 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 "qwebenginepage.h" #include "qwebenginepage_p.h" -- cgit v1.2.3 From 46bf07baaee9520c8128f7602b16ef33b7694bec Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 14 Jan 2016 12:04:50 +0100 Subject: Fix namespaced build of markdowneditor example Change-Id: Iff50511b06962d02e2a69ee47f1f0df82425dc2d Reviewed-by: Allan Sandfeld Jensen --- examples/webenginewidgets/markdowneditor/mainwindow.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.h b/examples/webenginewidgets/markdowneditor/mainwindow.h index 6099f1f79..c065fa685 100644 --- a/examples/webenginewidgets/markdowneditor/mainwindow.h +++ b/examples/webenginewidgets/markdowneditor/mainwindow.h @@ -47,9 +47,11 @@ #include #include +QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } +QT_END_NAMESPACE class MainWindow : public QMainWindow { -- cgit v1.2.3 From a3906aac584aace90c0dd763c9b66b6a8a315ca6 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 8 Jan 2016 14:13:02 +0100 Subject: Update logo of demobrowser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I26b907d943ebd424087c54465608598aaf0d0013 Reviewed-by: Michal Klocek Reviewed-by: Michael Brüning --- .../demobrowser/data/demobrowser.svg | 430 ++------------------- .../webenginewidgets/demobrowser/demobrowser.icns | Bin 50218 -> 31513 bytes .../webenginewidgets/demobrowser/demobrowser.ico | Bin 15374 -> 82726 bytes 3 files changed, 22 insertions(+), 408 deletions(-) diff --git a/examples/webenginewidgets/demobrowser/data/demobrowser.svg b/examples/webenginewidgets/demobrowser/data/demobrowser.svg index f61a54c67..9f39deb66 100644 --- a/examples/webenginewidgets/demobrowser/data/demobrowser.svg +++ b/examples/webenginewidgets/demobrowser/data/demobrowser.svg @@ -1,410 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Qt Browser - - - Jens Bache-Wiig - - - - - Copyright (C) 2015 The Qt Company Ltd. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - diff --git a/examples/webenginewidgets/demobrowser/demobrowser.icns b/examples/webenginewidgets/demobrowser/demobrowser.icns index f591ae48a..f24ac6ee7 100644 Binary files a/examples/webenginewidgets/demobrowser/demobrowser.icns and b/examples/webenginewidgets/demobrowser/demobrowser.icns differ diff --git a/examples/webenginewidgets/demobrowser/demobrowser.ico b/examples/webenginewidgets/demobrowser/demobrowser.ico index 7f9be934d..d197d0358 100644 Binary files a/examples/webenginewidgets/demobrowser/demobrowser.ico and b/examples/webenginewidgets/demobrowser/demobrowser.ico differ -- cgit v1.2.3 From eced172d4ebf573888a14990895f4b6f2ea74a73 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 7 Jan 2016 14:39:13 +0100 Subject: Doc: Use WebEngine.settings.pluginsEnabled as example javaScriptEnabled is true by default, so setting it explicitly to true is a bit dubious. Enabling pluginsEnabled (which is false by default) is a better example. Change-Id: I8a94d0fed895c6bc4211bd6718aaba34a437f8c5 Reviewed-by: Leena Miettinen --- src/webengine/api/qquickwebenginesingleton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp index b7a8c3b69..f0f5969c2 100644 --- a/src/webengine/api/qquickwebenginesingleton.cpp +++ b/src/webengine/api/qquickwebenginesingleton.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE \code Component.onCompleted: { - WebEngine.settings.javaScriptEnabled = true; + WebEngine.settings.pluginsEnabled = true; } \endcode */ -- cgit v1.2.3 From 7c7ee9a94bd566bd94e1548fb4bb6b5ec774c0d1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 14 Jan 2016 10:42:21 +0100 Subject: Have a WeakPtrFactory per thread in URLRequestCustomJob We must separate WeakPtrs per thread. Otherwise we run into a DCHECK in weak_ptr.cc: "WeakPtrs must be checked on the same sequenced thread.". Done-by: Allan Change-Id: I6ae971b01fb8f8ecda13e50798d6315dcf19d96e Reviewed-by: Allan Sandfeld Jensen --- src/core/url_request_custom_job.cpp | 16 +++++++++------- src/core/url_request_custom_job.h | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp index 0a81d04a1..1b6f1c767 100644 --- a/src/core/url_request_custom_job.cpp +++ b/src/core/url_request_custom_job.cpp @@ -60,7 +60,8 @@ URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *n , m_schemeHandler(schemeHandler) , m_error(0) , m_started(false) - , m_weakFactory(this) + , m_weakFactoryIO(this) + , m_weakFactoryUI(this) { } @@ -78,7 +79,7 @@ URLRequestCustomJob::~URLRequestCustomJob() void URLRequestCustomJob::Start() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&URLRequestCustomJob::startAsync, m_weakFactory.GetWeakPtr())); + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&URLRequestCustomJob::startAsync, m_weakFactoryIO.GetWeakPtr())); } void URLRequestCustomJob::Kill() @@ -93,7 +94,8 @@ void URLRequestCustomJob::Kill() if (m_device && m_device->isOpen()) m_device->close(); m_device = 0; - m_weakFactory.InvalidateWeakPtrs(); + m_weakFactoryIO.InvalidateWeakPtrs(); + m_weakFactoryUI.InvalidateWeakPtrs(); URLRequestJob::Kill(); } @@ -151,7 +153,7 @@ void URLRequestCustomJob::setReplyDevice(QIODevice *device) m_device->open(QIODevice::ReadOnly); if (m_device && m_device->isReadable()) - content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactory.GetWeakPtr())); + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr())); else fail(ERR_INVALID_URL); } @@ -179,7 +181,7 @@ void URLRequestCustomJob::redirect(const GURL &url) QMutexLocker lock(&m_mutex); m_redirect = url; - content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactory.GetWeakPtr())); + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr())); } void URLRequestCustomJob::abort() @@ -189,7 +191,7 @@ void URLRequestCustomJob::abort() if (m_device && m_device->isOpen()) m_device->close(); m_device = 0; - content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactory.GetWeakPtr())); + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactoryUI.GetWeakPtr())); } void URLRequestCustomJob::notifyCanceled() @@ -214,7 +216,7 @@ void URLRequestCustomJob::fail(int error) DCHECK_CURRENTLY_ON(content::BrowserThread::UI); QMutexLocker lock(&m_mutex); m_error = error; - content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyFailure, m_weakFactory.GetWeakPtr())); + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyFailure, m_weakFactoryUI.GetWeakPtr())); } void URLRequestCustomJob::notifyFailure() diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h index a994c467a..be5cae43c 100644 --- a/src/core/url_request_custom_job.h +++ b/src/core/url_request_custom_job.h @@ -87,7 +87,8 @@ private: int m_error; GURL m_redirect; bool m_started; - base::WeakPtrFactory m_weakFactory; + base::WeakPtrFactory m_weakFactoryIO; + base::WeakPtrFactory m_weakFactoryUI; friend class URLRequestCustomJobDelegate; -- cgit v1.2.3 From bc0db957cd158af234f02fb1a9510eab60a491a2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 15 Jan 2016 11:22:01 +0100 Subject: Fix initialization order of m_webChannel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initialization order did not match the declaration order causing compiler warnings. Change-Id: I3c852525736a145202085a698b542a7df7c3a9d9 Reviewed-by: Michael Brüning --- src/webengine/api/qquickwebengineview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index c6d849387..0cd356508 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -109,9 +109,9 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() , isLoading(false) , m_activeFocusOnPress(true) , devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio()) + , m_webChannel(0) , m_dpiScale(1.0) , m_backgroundColor(Qt::white) - , m_webChannel(0) { // The gold standard for mobile web content is 160 dpi, and the devicePixelRatio expected // is the (possibly quantized) ratio of device dpi to 160 dpi. -- cgit v1.2.3 From 320504179eb5b7b8c52e54ea97c930ee7d8c1ae6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 15 Jan 2016 12:36:32 +0100 Subject: Fix access after free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If deleteLater is called from the destructor of LocationProviderQt, QtPositioningHelper shouldn't be accessing LocationProviderQt from its destructor. Change-Id: I1f2344edc1918fcfa566c3cd6045694cabf89768 Reviewed-by: Michael Brüning --- src/core/location_provider_qt.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp index 222d15354..485ea8d94 100644 --- a/src/core/location_provider_qt.cpp +++ b/src/core/location_provider_qt.cpp @@ -74,6 +74,7 @@ private: QGeoPositionInfoSource *m_positionInfoSource; void postToLocationProvider(const base::Closure &task); + friend class LocationProviderQt; }; QtPositioningHelper::QtPositioningHelper(LocationProviderQt *provider) @@ -85,7 +86,8 @@ QtPositioningHelper::QtPositioningHelper(LocationProviderQt *provider) QtPositioningHelper::~QtPositioningHelper() { - m_locationProvider->m_positioningHelper = 0; + if (m_locationProvider) + m_locationProvider->m_positioningHelper = 0; } static bool isHighAccuracySource(const QGeoPositionInfoSource *source) @@ -223,7 +225,10 @@ LocationProviderQt::LocationProviderQt() LocationProviderQt::~LocationProviderQt() { - m_positioningHelper->deleteLater(); + if (m_positioningHelper) { + m_positioningHelper->m_locationProvider = 0; + m_positioningHelper->deleteLater(); + } } bool LocationProviderQt::StartProvider(bool highAccuracy) -- cgit v1.2.3 From 1ad2e1b809b31ef21a34674590a2d55c49bd3468 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 8 Jan 2016 13:03:31 +0100 Subject: Doc: Document support for proxies Change-Id: Icde2ed5519fe27d7b69d89e1c734d466cf65dfe3 Reviewed-by: Joerg Bornemann --- src/webengine/doc/src/qtwebengine-overview.qdoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index 50d03a9f4..53ff4b462 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -138,6 +138,15 @@ handled by using the WebEngineView::certificateError QML method or by reimplementing the QWebEnginePage::certificateError function. + \section1 Proxy Support + + If QNetworkProxy::applicationProxy is set, it will also be used for Qt WebEngine. Otherwise, + Qt WebEngine automatically picks up the proxy configuration from OS X and Windows. On Linux, + it acknowledges settings from KDE and Gnome. + + If a proxy requires authentication, QWebEnginePage::proxyAuthenticationRequired is emitted. + For Qt Quick, a dialog is shown. + \section1 Using WebEngine Core Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets for handling -- cgit v1.2.3 From 3a28b83b6f7dabff75483c38bbc786c2ff7af321 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 15 Jan 2016 16:23:00 +0100 Subject: Do not return negative values in WebEngineHistoryListModel QSortFilterProxyModel does not like negative values which were returned when adapter was not yet initialized. Add missing guards for adapter. Change-Id: I3d1dd5343aaf2c4d5504950005b05fb650835884 Reviewed-by: Kai Koehne --- src/webengine/api/qquickwebenginehistory.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index d790093a4..050833b28 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -54,7 +54,7 @@ QQuickWebEngineHistoryListModelPrivate::~QQuickWebEngineHistoryListModelPrivate( int QQuickWebEngineHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount(); } @@ -65,6 +65,8 @@ int QQuickWebEngineHistoryListModelPrivate::index(int index) const int QQuickWebEngineHistoryListModelPrivate::offsetForIndex(int index) const { + if (!adapter()) + return index; return index - adapter()->currentNavigationEntryIndex(); } @@ -81,7 +83,7 @@ QQuickWebEngineBackHistoryListModelPrivate::QQuickWebEngineBackHistoryListModelP int QQuickWebEngineBackHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->currentNavigationEntryIndex(); } @@ -104,12 +106,14 @@ QQuickWebEngineForwardHistoryListModelPrivate::QQuickWebEngineForwardHistoryList int QQuickWebEngineForwardHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount() - adapter()->currentNavigationEntryIndex() - 1; } int QQuickWebEngineForwardHistoryListModelPrivate::index(int i) const { + if (!adapter()) + return i + 1; return adapter()->currentNavigationEntryIndex() + i + 1; } -- cgit v1.2.3 From 7b2cbb3e9dae2080c76f8858daa3743f3e7aac1d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 15 Jan 2016 11:19:50 +0100 Subject: Fix access of freed data The string parts inside the lambda construction were already freed, so instead use a simpler construction where we are sure we are still holding the stringlist. Change-Id: I3559ab9d203b368e2d62efef73497ce7f9135cc5 Reviewed-by: Joerg Bornemann --- src/core/browser_context_adapter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index b9d439596..a6d3dfa4d 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -54,8 +54,6 @@ #include #include -#include - namespace { inline QString buildLocationFromStandardPath(const QString &standardPath, const QString &name) { QString location = standardPath; @@ -405,11 +403,13 @@ void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, Permissio QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const { const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); - return std::accumulate(list.constBegin(), list.constEnd(), QString(), - [](const QString &r, const QString &e) -> QString { - return (r.isEmpty() ? r : r + QString(QLatin1Char(','))) - + e.split(QLatin1Char(';')).first(); - }); + QString out; + Q_FOREACH (const QString& str, list) { + if (!out.isEmpty()) + out.append(QLatin1Char(',')); + out.append(str.split(QLatin1Char(';')).first()); + } + return out; } QString BrowserContextAdapter::httpAcceptLanguage() const -- cgit v1.2.3 From 50c423267ee54020a7ddbe3a0f56ddca4653c40a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 15 Jan 2016 14:35:00 +0100 Subject: Fix crash in BrowserContextAdapter::removeCustomUrlSchemeHandler Do not cache the end iterator, because erase might invalidate it. Do not increment the iterator in the erase case. Change-Id: I1cbad04fdaaf1bf4cfae252bb7569d817b6ab5a5 Reviewed-by: Allan Sandfeld Jensen --- src/core/browser_context_adapter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index a6d3dfa4d..4aa34e5d6 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -361,13 +361,13 @@ bool BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHand { bool removedOneOrMore = false; auto it = m_customUrlSchemeHandlers.begin(); - auto end = m_customUrlSchemeHandlers.end(); - for (; it != end; ++it) { + while (it != m_customUrlSchemeHandlers.end()) { if (it.value() == handler) { it = m_customUrlSchemeHandlers.erase(it); removedOneOrMore = true; continue; } + ++it; } if (removedOneOrMore) updateCustomUrlSchemeHandlers(); -- cgit v1.2.3 From 09ff58b1a91a1472b4aa4c644686fb2e46a3b1ca Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 2 Dec 2015 19:38:33 +0100 Subject: Remove callback functions from qwebenginecookiestore Remove all callback api calls, rename getAllCookies to loadCookies, update documentation. New function name reflects the fact the cookieAdded signal is always emitted when cookies are loaded from the store. Change-Id: Iab7bb04871c7396d2e23306a10084d425426a19f Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebenginecookiestore.cpp | 108 ++++++--------------- src/core/api/qwebenginecookiestore.h | 9 +- .../tst_qwebenginecookiestore.cpp | 44 ++++----- 3 files changed, 52 insertions(+), 109 deletions(-) diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 2938eddbd..ab2612803 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -268,41 +268,26 @@ QWebEngineCookieStore::~QWebEngineCookieStore() } /*! - \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()) - - Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed - on the caller thread. - It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. - The provided URL should also include the scheme. - - \sa setCookie() -*/ - -void QWebEngineCookieStore::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin) -{ - Q_D(QWebEngineCookieStore); - d->setCookie(resultCallback, cookie, origin); -} - -/*! - Adds \a cookie to the cookie store. This function is provided for convenience and is - equivalent to calling setCookieWithCallback() with an empty callback. + Adds \a cookie to the cookie store. It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. The provided URL should also include the scheme. - \sa setCookieWithCallback() + \note This operation is asynchronous. */ void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &origin) { - setCookieWithCallback(cookie, QWebEngineCallback(), origin); + //TODO: use callbacks or delete dummy ones + Q_D(QWebEngineCookieStore); + d->setCookie(QWebEngineCallback(), cookie, origin); } /*! Deletes \a cookie from the cookie store. It is possible to provide an optional \a origin URL argument to limit the scope of the cookie to be deleted. - The provided URL should also include the scheme. + + \note This operation is asynchronous. */ void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin) @@ -312,88 +297,59 @@ void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUr } /*! - \fn void QWebEngineCookieStore::getAllCookies(FunctorOrLambda resultCallback) + Loads all the cookies into the cookie store. The cookieAdded() signal is emitted on every + loaded cookie. Cookies are loaded automatically when the store gets initialized, which + in most cases happens on loading the first URL. However, calling this function is useful + if cookies should be listed before entering the web content. - Requests all the cookies in the cookie store. When the asynchronous operation finishes, - \a resultCallback will be called with a QByteArray as the argument containing the cookies. - This QByteArray can be parsed using QNetworkCookie::parseCookies(). - - \sa deleteCookie() + \note This operation is asynchronous. */ -void QWebEngineCookieStore::getAllCookies(const QWebEngineCallback &resultCallback) +void QWebEngineCookieStore::loadAllCookies() { + //TODO: use callbacks or delete dummy ones Q_D(QWebEngineCookieStore); - if (d->m_getAllCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); + if (d->m_getAllCookiesPending) return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, resultCallback); + d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback()); + //this will trigger cookieAdded signal d->getAllCookies(); } /*! - \fn void QWebEngineCookieStore::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback) - Deletes all the session cookies in the cookie store. Session cookies do not have an expiration date assigned to them. - When the asynchronous operation finishes, \a resultCallback will be called with the - number of cookies deleted as the argument. + + \note This operation is asynchronous. + \sa loadAllCookies() */ -void QWebEngineCookieStore::deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback) +void QWebEngineCookieStore::deleteSessionCookies() { + //TODO: use callbacks or delete dummy ones Q_D(QWebEngineCookieStore); - if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); + if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, resultCallback); + d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback()); d->deleteSessionCookies(); } /*! - \fn void QWebEngineCookieStore::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback) - - Deletes all the cookies in the cookie store. When the asynchronous operation finishes, - \a resultCallback will be called with the number of cookies deleted as the argument. - - \sa deleteSessionCookiesWithCallback(), getAllCookies() + Deletes all the cookies in the cookie store. + \note This operation is asynchronous. + \sa loadAllCookies() */ -void QWebEngineCookieStore::deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback) +void QWebEngineCookieStore::deleteAllCookies() { + //TODO: use callbacks or delete dummy ones Q_D(QWebEngineCookieStore); - if (d->m_deleteAllCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); + if (d->m_deleteAllCookiesPending) return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, resultCallback); + d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback()); d->deleteAllCookies(); } -/*! - Deletes all the session cookies in the cookie store. - - \sa deleteSessionCookiesWithCallback() -*/ - -void QWebEngineCookieStore::deleteSessionCookies() -{ - deleteSessionCookiesWithCallback(QWebEngineCallback()); -} - -/*! - Deletes all the cookies in the cookie store. - - \sa deleteAllCookiesWithCallback(), getAllCookies() -*/ - -void QWebEngineCookieStore::deleteAllCookies() -{ - deleteAllCookiesWithCallback(QWebEngineCallback()); -} - /*! \fn void QWebEngineCookieStore::setCookieFilter(FunctorOrLambda filterCallback) @@ -404,7 +360,7 @@ void QWebEngineCookieStore::deleteAllCookies() The callback should not be used to execute heavy tasks since it is running on the IO thread and therefore blocks the Chromium networking. - \sa deleteAllCookiesWithCallback(), getAllCookies() + \sa deleteAllCookies(), loadAllCookies() */ void QWebEngineCookieStore::setCookieFilter(const QWebEngineCallback &filter) { diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h index b78f885ef..3a52a2025 100644 --- a/src/core/api/qwebenginecookiestore.h +++ b/src/core/api/qwebenginecookiestore.h @@ -67,22 +67,15 @@ public: virtual ~QWebEngineCookieStore(); #ifdef Q_QDOC - void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()); - void deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback); - void deleteAllCookiesWithCallback(FunctorOrLambda resultCallback); - void getAllCookies(FunctorOrLambda resultCallback); void setCookieFilter(FunctorOrLambda filterCallback); #else - void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin = QUrl()); - void deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback); - void deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback); - void getAllCookies(const QWebEngineCallback &resultCallback); void setCookieFilter(const QWebEngineCallback &filterCallback); #endif void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); void deleteSessionCookies(); void deleteAllCookies(); + void loadAllCookies(); Q_SIGNALS: void cookieAdded(const QNetworkCookie &cookie); diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp index 9436b093e..7cf55427e 100644 --- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp +++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp @@ -95,6 +95,7 @@ void tst_QWebEngineCookieStore::cookieSignals() { QWebEngineView view; QWebEngineCookieStore *client = view.page()->profile()->cookieStore(); + client->deleteAllCookies(); QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &))); @@ -110,6 +111,7 @@ void tst_QWebEngineCookieStore::cookieSignals() // try whether updating a cookie to be expired results in that cookie being removed. QNetworkCookie expiredCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first()); client->setCookie(expiredCookie, QUrl("qrc:///resources/index.html")); + QTRY_COMPARE(cookieRemovedSpy.count(), 1); cookieRemovedSpy.clear(); @@ -123,6 +125,7 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie() { QWebEngineView view; QWebEngineCookieStore *client = view.page()->profile()->cookieStore(); + client->deleteAllCookies(); QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &))); @@ -134,8 +137,10 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie() QNetworkCookie expiredCookie3(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first()); // check if pending cookies are set and removed - client->setCookieWithCallback(cookie1, [](bool success) { QVERIFY(success); }); - client->setCookieWithCallback(cookie2, [](bool success) { QVERIFY(success); }); + client->setCookie(cookie1); + QTRY_COMPARE(cookieAddedSpy.count(),1); + client->setCookie(cookie2); + QTRY_COMPARE(cookieAddedSpy.count(),2); client->deleteCookie(cookie1); view.load(QUrl("qrc:///resources/content.html")); @@ -148,9 +153,10 @@ void tst_QWebEngineCookieStore::setAndDeleteCookie() cookieAddedSpy.clear(); cookieRemovedSpy.clear(); - client->setCookieWithCallback(cookie3, [](bool success) { QVERIFY(success); }); + client->setCookie(cookie3); + QTRY_COMPARE(cookieAddedSpy.count(), 1); // updating a cookie with an expired 'expires' field should remove the cookie with the same name - client->setCookieWithCallback(expiredCookie3, [](bool success) { QVERIFY(success); }); + client->setCookie(expiredCookie3); client->deleteCookie(cookie2); QTRY_COMPARE(cookieAddedSpy.count(), 1); QTRY_COMPARE(cookieRemovedSpy.count(), 2); @@ -160,6 +166,7 @@ void tst_QWebEngineCookieStore::batchCookieTasks() { QWebEngineView view; QWebEngineCookieStore *client = view.page()->profile()->cookieStore(); + client->deleteAllCookies(); QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &))); @@ -168,10 +175,10 @@ void tst_QWebEngineCookieStore::batchCookieTasks() QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first()); QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first()); - int capture = 0; - - client->setCookieWithCallback(cookie1, [&capture](bool success) { QVERIFY(success); ++capture; }); - client->setCookieWithCallback(cookie2, [&capture](bool success) { QVERIFY(success); ++capture; }); + client->setCookie(cookie1); + QTRY_COMPARE(cookieAddedSpy.count(), 1); + client->setCookie(cookie2); + QTRY_COMPARE(cookieAddedSpy.count(), 2); view.load(QUrl("qrc:///resources/index.html")); @@ -180,28 +187,15 @@ void tst_QWebEngineCookieStore::batchCookieTasks() QVERIFY(success.toBool()); QTRY_COMPARE(cookieAddedSpy.count(), 4); QTRY_COMPARE(cookieRemovedSpy.count(), 0); - QTRY_COMPARE(capture, 2); - capture = 0; cookieAddedSpy.clear(); cookieRemovedSpy.clear(); - client->getAllCookies([&capture](const QByteArray& cookieLine) { - ++capture; - QCOMPARE(QNetworkCookie::parseCookies(cookieLine).count(), 4); - }); - - client->deleteSessionCookiesWithCallback([&capture](int numDeleted) { - ++capture; - QCOMPARE(numDeleted, 3); - }); - - client->deleteAllCookiesWithCallback([&capture](int numDeleted) { - ++capture; - QCOMPARE(numDeleted, 1); - }); + client->deleteSessionCookies(); + QTRY_COMPARE(cookieRemovedSpy.count(), 3); - QTRY_COMPARE(capture, 3); + client->deleteAllCookies(); + QTRY_COMPARE(cookieRemovedSpy.count(), 4); } QTEST_MAIN(tst_QWebEngineCookieStore) -- cgit v1.2.3 From 7ae7b58955b018aa7294aa07d6ff7754af336f4c Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 3 Dec 2015 15:29:48 +0100 Subject: Remove FilterRequest from qwebenginecookiestore OnCanSetCookie and OnCanGetCookies should both be mapped to API. Since the other call is missing (filter cookies which should be send) remove existing one from 5.6 Change-Id: I4f42c4a1fee6add7a5efffaf4c38877a1f35ce61 Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebenginecookiestore.cpp | 32 -------------------------------- src/core/api/qwebenginecookiestore.h | 12 ------------ src/core/api/qwebenginecookiestore_p.h | 3 --- src/core/cookie_monster_delegate_qt.cpp | 6 ++---- tests/quicktestbrowser/BrowserWindow.qml | 8 -------- tests/quicktestbrowser/main.cpp | 8 +------- 6 files changed, 3 insertions(+), 66 deletions(-) diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index ab2612803..c0a3f3208 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -175,20 +175,6 @@ void QWebEngineCookieStorePrivate::onCookieChanged(const QNetworkCookie &cookie, Q_EMIT q->cookieAdded(cookie); } -bool QWebEngineCookieStorePrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) -{ - if (filterCallback) { - QWebEngineCookieStore::FilterRequest request; - request.accepted = true; - request.firstPartyUrl = firstPartyUrl; - request.cookieLine = cookieLine; - request.cookieSource = url; - callbackDirectory.invokeDirectly(filterCallback, request); - return request.accepted; - } - return true; -} - /*! \class QWebEngineCookieStore \inmodule QtWebEngineCore @@ -350,22 +336,4 @@ void QWebEngineCookieStore::deleteAllCookies() d->deleteAllCookies(); } -/*! - \fn void QWebEngineCookieStore::setCookieFilter(FunctorOrLambda filterCallback) - - Installs a cookie filter that can reject cookies before they are added to the cookie store. - The \a filterCallback must be a lambda or functor taking FilterRequest structure. If the - cookie is to be rejected, the filter can set FilterRequest::accepted to \c false. - - The callback should not be used to execute heavy tasks since it is running on the - IO thread and therefore blocks the Chromium networking. - - \sa deleteAllCookies(), loadAllCookies() -*/ -void QWebEngineCookieStore::setCookieFilter(const QWebEngineCallback &filter) -{ - Q_D(QWebEngineCookieStore); - d->filterCallback = filter; -} - QT_END_NAMESPACE diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h index 3a52a2025..b1d625385 100644 --- a/src/core/api/qwebenginecookiestore.h +++ b/src/core/api/qwebenginecookiestore.h @@ -57,20 +57,8 @@ class QWEBENGINE_EXPORT QWebEngineCookieStore : public QObject { Q_OBJECT public: - struct FilterRequest { - bool accepted; - - QUrl firstPartyUrl; - QByteArray cookieLine; - QUrl cookieSource; - }; virtual ~QWebEngineCookieStore(); -#ifdef Q_QDOC - void setCookieFilter(FunctorOrLambda filterCallback); -#else - void setCookieFilter(const QWebEngineCallback &filterCallback); -#endif void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); void deleteSessionCookies(); diff --git a/src/core/api/qwebenginecookiestore_p.h b/src/core/api/qwebenginecookiestore_p.h index 348dcd69f..41456cfdc 100644 --- a/src/core/api/qwebenginecookiestore_p.h +++ b/src/core/api/qwebenginecookiestore_p.h @@ -75,7 +75,6 @@ class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate : public QObjectPri friend class QTypeInfo; public: QtWebEngineCore::CallbackDirectory callbackDirectory; - QWebEngineCallback filterCallback; QVector m_pendingUserCookies; quint64 m_nextCallbackId; bool m_deleteSessionCookiesPending; @@ -94,8 +93,6 @@ public: void deleteAllCookies(); void getAllCookies(); - bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); - void onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList); void onSetCallbackResult(qint64 callbackId, bool success); void onDeleteCallbackResult(qint64 callbackId, int numCookies); diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp index 3689d54d7..493743385 100644 --- a/src/core/cookie_monster_delegate_qt.cpp +++ b/src/core/cookie_monster_delegate_qt.cpp @@ -166,10 +166,8 @@ void CookieMonsterDelegateQt::setClient(QWebEngineCookieStore *client) bool CookieMonsterDelegateQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) { - if (!m_client) - return true; - - return m_client->d_func()->canSetCookie(firstPartyUrl, cookieLine, url); + // TODO: should be used for FilterRequest implementation + return true; } void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml index 3fcca4aab..cf583c60d 100644 --- a/tests/quicktestbrowser/BrowserWindow.qml +++ b/tests/quicktestbrowser/BrowserWindow.qml @@ -79,7 +79,6 @@ ApplicationWindow { property alias javaScriptEnabled: javaScriptEnabled.checked; property alias errorPageEnabled: errorPageEnabled.checked; property alias pluginsEnabled: pluginsEnabled.checked; - property alias thirdPartyCookiesEnabled: thirdPartyCookiesEnabled.checked; } // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. @@ -254,13 +253,6 @@ ApplicationWindow { checkable: true checked: true } - MenuItem { - id: thirdPartyCookiesEnabled - text: "Third party cookies enabled" - checkable: true - checked: true - onToggled: applicationRoot.thirdPartyCookiesEnabled = checked - } MenuItem { id: offTheRecordEnabled text: "Off The Record" diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp index 61977a018..85a02ab34 100644 --- a/tests/quicktestbrowser/main.cpp +++ b/tests/quicktestbrowser/main.cpp @@ -86,15 +86,9 @@ int main(int argc, char **argv) QObject *rootObject = appEngine.rootObjects().first(); QQuickWebEngineProfile *profile = new QQuickWebEngineProfile(rootObject); - QWebEngineCookieStore *client = profile->cookieStore(); const QMetaObject *rootMeta = rootObject->metaObject(); - int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled"); - Q_ASSERT(index != -1); - QMetaProperty thirdPartyCookiesProperty = rootMeta->property(index); - client->setCookieFilter([rootObject,&thirdPartyCookiesProperty](const QWebEngineCookieStore::FilterRequest&){ return thirdPartyCookiesProperty.read(rootObject).toBool(); }); - - index = rootMeta->indexOfProperty("testProfile"); + int index = rootMeta->indexOfProperty("testProfile"); Q_ASSERT(index != -1); QMetaProperty profileProperty = rootMeta->property(index); profileProperty.write(rootObject, qVariantFromValue(profile)); -- cgit v1.2.3