Skip to content

Commit d0af800

Browse files
committed
Fix merge conflicts
2 parents e090104 + f71ad91 commit d0af800

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1654
-1599
lines changed

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ if (Qt5WebKitWidgets_FOUND AND ENABLE_QTWEBKIT)
377377
src/modules/backends/web/qtwebkit/QtWebKitCookieJar.cpp
378378
src/modules/backends/web/qtwebkit/QtWebKitFtpListingNetworkReply.cpp
379379
src/modules/backends/web/qtwebkit/QtWebKitHistoryInterface.cpp
380-
src/modules/backends/web/qtwebkit/QtWebKitInspector.cpp
381380
src/modules/backends/web/qtwebkit/QtWebKitNetworkManager.cpp
382381
src/modules/backends/web/qtwebkit/QtWebKitNotificationPresenter.cpp
383382
src/modules/backends/web/qtwebkit/QtWebKitPage.cpp

src/core/Application.cpp

+8-26
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv),
277277
QCryptographicHash hash(QCryptographicHash::Md5);
278278
hash.addData(profilePath.toUtf8());
279279

280-
const QString identifier(QString::fromLatin1(hash.result().toHex()));
281-
const QString server(applicationName() + (identifier.isEmpty() ? QString() : (QLatin1Char('-') + identifier)));
280+
const QString serverName(applicationName() + QLatin1Char('-') + QString::fromLatin1(hash.result().toHex()));
282281
QLocalSocket socket;
283-
socket.connectToServer(server);
282+
socket.connectToServer(serverName);
284283

285284
if (socket.waitForConnected(500))
286285
{
@@ -311,9 +310,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv),
311310

312311
m_localServer->setSocketOptions(QLocalServer::UserAccessOption);
313312

314-
if (!m_localServer->listen(server) && m_localServer->serverError() == QAbstractSocket::AddressInUseError && QLocalServer::removeServer(server))
313+
if (!m_localServer->listen(serverName) && m_localServer->serverError() == QAbstractSocket::AddressInUseError && QLocalServer::removeServer(serverName))
315314
{
316-
m_localServer->listen(server);
315+
m_localServer->listen(serverName);
317316
}
318317

319318
m_isFirstRun = !QFile::exists(profilePath);
@@ -445,7 +444,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv),
445444

446445
const WebBackend *webBackend(AddonsManager::getWebBackend());
447446

448-
if (!QSslSocket::supportsSsl() || (webBackend && webBackend->getSslVersion().isEmpty()))
447+
if (!QSslSocket::supportsSsl() || (webBackend && !webBackend->hasSslSupport()))
449448
{
450449
QMessageBox::warning(nullptr, tr("Warning"), tr("SSL support is not available or incomplete.\nSome websites may work incorrectly or do not work at all."), QMessageBox::Close);
451450
}
@@ -1017,14 +1016,7 @@ void Application::handleNewConnection()
10171016

10181017
if (!mainWindow || !SettingsManager::getOption(SettingsManager::Browser_OpenLinksInNewTabOption).toBool() || (isPrivate && !mainWindow->isPrivate()))
10191018
{
1020-
QVariantMap parameters;
1021-
1022-
if (isPrivate)
1023-
{
1024-
parameters[QLatin1String("hints")] = SessionsManager::PrivateOpen;
1025-
}
1026-
1027-
createWindow(parameters);
1019+
createWindow({{QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
10281020
}
10291021
}
10301022
else
@@ -1033,12 +1025,7 @@ void Application::handleNewConnection()
10331025

10341026
if (sessionData.isClean || QMessageBox::warning(nullptr, tr("Warning"), tr("This session was not saved correctly.\nAre you sure that you want to restore this session anyway?"), (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes)
10351027
{
1036-
QVariantMap parameters;
1037-
1038-
if (isPrivate)
1039-
{
1040-
parameters[QLatin1String("hints")] = SessionsManager::PrivateOpen;
1041-
}
1028+
const QVariantMap parameters({{QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
10421029

10431030
for (int i = 0; i < sessionData.windows.count(); ++i)
10441031
{
@@ -1084,12 +1071,7 @@ void Application::handlePositionalArguments(QCommandLineParser *parser, bool for
10841071

10851072
if (openHints.testFlag(SessionsManager::NewWindowOpen))
10861073
{
1087-
QVariantMap parameters;
1088-
1089-
if (openHints.testFlag(SessionsManager::PrivateOpen))
1090-
{
1091-
parameters[QLatin1String("hints")] = SessionsManager::PrivateOpen;
1092-
}
1074+
const QVariantMap parameters({{QLatin1String("hints"), (openHints.testFlag(SessionsManager::PrivateOpen) ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
10931075

10941076
if (urls.isEmpty())
10951077
{

src/core/BookmarksModel.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ QMimeData* BookmarksModel::mimeData(const QModelIndexList &indexes) const
12151215
if (indexes.count() == 1)
12161216
{
12171217
mimeData->setProperty("x-item-index", indexes.at(0));
1218+
mimeData->setProperty("x-url-title", indexes.at(0).data(TitleRole).toString());
12181219
}
12191220

12201221
for (int i = 0; i < indexes.count(); ++i)

src/core/Importer.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ BookmarksModel::Bookmark* BookmarksImportJob::getImportFolder() const
9999
return m_importFolder;
100100
}
101101

102+
QDateTime BookmarksImportJob::getDateTime(const QString &timestamp) const
103+
{
104+
#if QT_VERSION < 0x050800
105+
const uint seconds(timestamp.toUInt());
106+
107+
return ((seconds > 0) ? QDateTime::fromTime_t(seconds) : QDateTime());
108+
#else
109+
const qint64 seconds(timestamp.toLongLong());
110+
111+
return ((seconds != 0) ? QDateTime::fromSecsSinceEpoch(seconds) : QDateTime());
112+
#endif
113+
}
114+
102115
bool BookmarksImportJob::areDuplicatesAllowed() const
103116
{
104117
return m_areDuplicatesAllowed;

src/core/Importer.h

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class BookmarksImportJob : public ImportJob
111111
void setCurrentFolder(BookmarksModel::Bookmark *folder);
112112
BookmarksModel::Bookmark* getCurrentFolder() const;
113113
BookmarksModel::Bookmark* getImportFolder() const;
114+
QDateTime getDateTime(const QString &timestamp) const;
114115
bool areDuplicatesAllowed() const;
115116

116117
private:

src/core/SessionsManager.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,7 @@ bool SessionsManager::restoreSession(const SessionInformation &session, MainWind
558558
m_sessionTitle = session.title;
559559
}
560560

561-
QVariantMap parameters;
562-
563-
if (isPrivate)
564-
{
565-
parameters[QLatin1String("hints")] = PrivateOpen;
566-
}
561+
const QVariantMap parameters({{QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
567562

568563
for (int i = 0; i < session.windows.count(); ++i)
569564
{

src/core/TransfersManager.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,12 @@ void TransfersManager::addTransfer(Transfer *transfer)
10461046
}
10471047
else
10481048
{
1049-
HistoryManager::addEntry(transfer->getSource());
1049+
const QString scheme(transfer->getSource().scheme());
1050+
1051+
if (scheme == QLatin1String("http") || scheme == QLatin1String("https"))
1052+
{
1053+
HistoryManager::addEntry(transfer->getSource());
1054+
}
10501055
}
10511056
}
10521057

src/core/WebBackend.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class WebBackend : public QObject, public Addon
8585
virtual QVector<SpellCheckManager::DictionaryInformation> getDictionaries() const;
8686
AddonType getType() const override;
8787
virtual BackendCapabilities getCapabilities() const;
88+
virtual bool hasSslSupport() const = 0;
8889
};
8990

9091
}

src/main.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,7 @@ int main(int argc, char *argv[])
207207

208208
if (Application::getWindows().isEmpty())
209209
{
210-
QVariantMap parameters;
211-
212-
if (isPrivate)
213-
{
214-
parameters[QLatin1String("hints")] = SessionsManager::PrivateOpen;
215-
}
216-
217-
Application::createWindow(parameters);
210+
Application::createWindow({{QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
218211
}
219212

220213
return Application::exec();

src/modules/backends/web/qtwebengine/QtWebEnginePage.cpp

+49-3
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,21 @@ QtWebEngineWebWidget* QtWebEnginePage::createWidget(SessionsManager::OpenHints h
337337
return widget;
338338
}
339339

340-
QString QtWebEnginePage::createJavaScriptList(QStringList rules) const
340+
QString QtWebEnginePage::createJavaScriptList(const QStringList &rules) const
341341
{
342342
if (rules.isEmpty())
343343
{
344344
return {};
345345
}
346346

347+
QStringList parsedRules(rules);
348+
347349
for (int i = 0; i < rules.count(); ++i)
348350
{
349-
rules[i].replace(QLatin1Char('\''), QLatin1String("\\'"));
351+
parsedRules[i].replace(QLatin1Char('\''), QLatin1String("\\'"));
350352
}
351353

352-
return QLatin1Char('\'') + rules.join(QLatin1String("','")) + QLatin1Char('\'');
354+
return QLatin1Char('\'') + parsedRules.join(QLatin1String("','")) + QLatin1Char('\'');
353355
}
354356

355357
QString QtWebEnginePage::createScriptSource(const QString &path, const QStringList &parameters) const
@@ -402,6 +404,13 @@ QVariant QtWebEnginePage::runScriptFile(const QString &path, const QStringList &
402404
return runScriptSource(createScriptSource(path, parameters));
403405
}
404406

407+
#if QTWEBENGINECORE_VERSION >= 0x050E00
408+
WebWidget::SslInformation QtWebEnginePage::getSslInformation() const
409+
{
410+
return m_sslInformation;
411+
}
412+
#endif
413+
405414
Session::Window::History QtWebEnginePage::getHistory() const
406415
{
407416
QWebEngineHistory *pageHistory(history());
@@ -526,6 +535,10 @@ bool QtWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType ty
526535
}
527536
}
528537

538+
#if QTWEBENGINECORE_VERSION >= 0x050E00
539+
m_sslInformation = {};
540+
#endif
541+
529542
if (type != NavigationTypeReload)
530543
{
531544
m_previousNavigationType = type;
@@ -584,6 +597,39 @@ bool QtWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType ty
584597
return true;
585598
}
586599

600+
#if QTWEBENGINECORE_VERSION >= 0x050E00
601+
bool QtWebEnginePage::certificateError(const QWebEngineCertificateError &error)
602+
{
603+
if (!m_widget || error.certificateChain().isEmpty())
604+
{
605+
return false;
606+
}
607+
608+
const QList<QSslError> errors(QSslCertificate::verify(error.certificateChain(), error.url().host()));
609+
610+
m_sslInformation.errors.reserve(m_sslInformation.errors.count() + errors.count());
611+
612+
for (int i = 0; i < errors.count(); ++i)
613+
{
614+
m_sslInformation.errors.append({errors.at(i), error.url()});
615+
}
616+
617+
const QString firstPartyUrl(m_widget->getUrl().toString());
618+
const QString thirdPartyUrl(error.url().toString());
619+
620+
if (m_widget->getOption(SettingsManager::Security_IgnoreSslErrorsOption, m_widget->getUrl()).toStringList().contains(QString::fromLatin1(error.certificateChain().first().digest().toBase64())))
621+
{
622+
Console::addMessage(QStringLiteral("[accepted] The page at %1 was allowed to display insecure content from %2").arg(firstPartyUrl, thirdPartyUrl), Console::SecurityCategory, Console::WarningLevel, thirdPartyUrl, -1, m_widget->getWindowIdentifier());
623+
624+
return true;
625+
}
626+
627+
Console::addMessage(QStringLiteral("[blocked] The page at %1 was not allowed to display insecure content from %2").arg(firstPartyUrl, thirdPartyUrl), Console::SecurityCategory, Console::WarningLevel, thirdPartyUrl, -1, m_widget->getWindowIdentifier());
628+
629+
return false;
630+
}
631+
#endif
632+
587633
bool QtWebEnginePage::javaScriptConfirm(const QUrl &url, const QString &message)
588634
{
589635
if (m_isIgnoringJavaScriptPopups)

src/modules/backends/web/qtwebengine/QtWebEnginePage.h

+18-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
#define OTTER_QTWEBENGINEPAGE_H
2323

2424
#include "../../../../core/SessionsManager.h"
25+
#include "../../../../ui/WebWidget.h"
2526

27+
#include <QtWebEngineCore/QtWebEngineCoreVersion>
28+
#if QTWEBENGINECORE_VERSION >= 0x050E00
29+
#include <QtWebEngineWidgets/QWebEngineCertificateError>
30+
#endif
2631
#include <QtWebEngineWidgets/QWebEnginePage>
2732

2833
namespace Otter
@@ -53,6 +58,9 @@ class QtWebEnginePage final : public QWebEnginePage
5358
QString createScriptSource(const QString &path, const QStringList &parameters = {}) const;
5459
QVariant runScriptSource(const QString &script);
5560
QVariant runScriptFile(const QString &path, const QStringList &parameters = {});
61+
#if QTWEBENGINECORE_VERSION >= 0x050E00
62+
WebWidget::SslInformation getSslInformation() const;
63+
#endif
5664
Session::Window::History getHistory() const;
5765
bool isPopup() const;
5866
bool isViewingMedia() const;
@@ -63,9 +71,12 @@ class QtWebEnginePage final : public QWebEnginePage
6371
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &note, int line, const QString &source) override;
6472
QWebEnginePage* createWindow(WebWindowType type) override;
6573
QtWebEngineWebWidget* createWidget(SessionsManager::OpenHints hints);
66-
QString createJavaScriptList(QStringList rules) const;
74+
QString createJavaScriptList(const QStringList &rules) const;
6775
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) override;
68-
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override;
76+
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
77+
#if QTWEBENGINECORE_VERSION >= 0x050E00
78+
bool certificateError(const QWebEngineCertificateError &error) override;
79+
#endif
6980
bool javaScriptConfirm(const QUrl &url, const QString &message) override;
7081
bool javaScriptPrompt(const QUrl &url, const QString &message, const QString &defaultValue, QString *result) override;
7182

@@ -75,17 +86,20 @@ protected slots:
7586

7687
private:
7788
QtWebEngineWebWidget *m_widget;
89+
#if QTWEBENGINECORE_VERSION >= 0x050E00
90+
WebWidget::SslInformation m_sslInformation;
91+
#endif
7892
QVector<QtWebEnginePage*> m_popups;
7993
QVector<HistoryEntryInformation> m_history;
80-
QWebEnginePage::NavigationType m_previousNavigationType;
94+
NavigationType m_previousNavigationType;
8195
bool m_isIgnoringJavaScriptPopups;
8296
bool m_isViewingMedia;
8397
bool m_isPopup;
8498

8599
signals:
86100
void requestedNewWindow(WebWidget *widget, SessionsManager::OpenHints hints, const QVariantMap &parameters);
87101
void requestedPopupWindow(const QUrl &parentUrl, const QUrl &popupUrl);
88-
void aboutToNavigate(const QUrl &url, QWebEnginePage::NavigationType navigationType);
102+
void aboutToNavigate(const QUrl &url, NavigationType navigationType);
89103
void viewingMediaChanged(bool isViewingMedia);
90104
};
91105

src/modules/backends/web/qtwebengine/QtWebEngineTransfer.cpp

+27-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@
1919

2020
#include "QtWebEngineTransfer.h"
2121

22+
#if QTWEBENGINECORE_VERSION >= 0x050E00
23+
#include <QtCore/QDir>
24+
#endif
2225
#include <QtCore/QFileInfo>
2326
#include <QtCore/QMimeDatabase>
2427

2528
namespace Otter
2629
{
2730

2831
QtWebEngineTransfer::QtWebEngineTransfer(QWebEngineDownloadItem *item, TransferOptions options, QObject *parent) : Transfer(options, parent),
29-
m_item(item),
30-
m_suggestedFileName(QFileInfo(item->path()).fileName())
32+
m_item(item)
33+
#if QTWEBENGINECORE_VERSION < 0x050E00
34+
, m_suggestedFileName(QFileInfo(item->path()).fileName())
35+
#endif
3136
{
3237
m_item->accept();
3338
m_item->setParent(this);
@@ -79,7 +84,16 @@ QUrl QtWebEngineTransfer::getSource() const
7984

8085
QString QtWebEngineTransfer::getSuggestedFileName()
8186
{
87+
#if QTWEBENGINECORE_VERSION >= 0x050E00
88+
if (!m_item)
89+
{
90+
return {};
91+
}
92+
93+
return m_item->suggestedFileName();
94+
#else
8295
return m_suggestedFileName;
96+
#endif
8397
}
8498

8599
QString QtWebEngineTransfer::getTarget() const
@@ -89,7 +103,11 @@ QString QtWebEngineTransfer::getTarget() const
89103
return Transfer::getTarget();
90104
}
91105

106+
#if QTWEBENGINECORE_VERSION >= 0x050E00
107+
return QDir(m_item->downloadDirectory()).absoluteFilePath(m_item->downloadFileName());
108+
#else
92109
return m_item->path();
110+
#endif
93111
}
94112

95113
QMimeType QtWebEngineTransfer::getMimeType() const
@@ -154,7 +172,14 @@ bool QtWebEngineTransfer::setTarget(const QString &target, bool canOverwriteExis
154172
return Transfer::setTarget(target, canOverwriteExisting);
155173
}
156174

175+
#if QTWEBENGINECORE_VERSION >= 0x050E00
176+
QFileInfo fileInformation(target);
177+
178+
m_item->setDownloadDirectory(fileInformation.path());
179+
m_item->setDownloadFileName(fileInformation.fileName());
180+
#else
157181
m_item->setPath(target);
182+
#endif
158183

159184
return true;
160185
}

0 commit comments

Comments
 (0)