re-introduce Google S2 favicon service to icon fetching mechanism

This commit is contained in:
Martin Rotter 2022-01-19 08:22:26 +01:00
parent f951dbfe74
commit 7d7ee4140d
3 changed files with 58 additions and 51 deletions

View file

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.1.2" date="2022-01-18"/>
<release version="4.1.2" date="2022-01-19"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View file

@ -17,10 +17,7 @@
SkinFactory::SkinFactory(QObject* parent) : QObject(parent) {}
void SkinFactory::loadCurrentSkin() {
QList<QString> skin_names_to_try;
skin_names_to_try.append(selectedSkinName());
skin_names_to_try.append(QSL(APP_SKIN_DEFAULT));
QList<QString> skin_names_to_try = { selectedSkinName(), QSL(APP_SKIN_DEFAULT) };
bool skin_parsed;
Skin skin_data;
QString skin_name;

View file

@ -183,8 +183,9 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
}
}
else {
// Use favicon fetching service.
QString host = QUrl(url.first).host();
// Duck Duck Go.
QUrl url_full = QUrl(url.first);
QString host = url_full.host();
if (host.startsWith(QSL("www."))) {
host = host.mid(4);
@ -192,7 +193,15 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
const QString ddg_icon_service = QSL("https://external-content.duckduckgo.com/ip3/%1.ico").arg(host);
network_result = performNetworkOperation(ddg_icon_service,
// Google S2.
host = url_full.scheme() + QSL("://") + url_full.host();
const QString gs2_icon_service = QSL("https://t2.gstatic.com/faviconV2?"
"client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&"
"url=%1").arg(host);
for (const QString& service : { ddg_icon_service, gs2_icon_service }) {
network_result = performNetworkOperation(service,
timeout,
QByteArray(),
icon_data,
@ -210,7 +219,8 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
output = QIcon(icon_pixmap);
if (!output.isNull()) {
break;
return network_result;
}
}
}
}