From 2db9af9251c54cfc6eab46df5b77559f3c8c0a0b Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@digia.com>
Date: Tue, 19 Aug 2014 11:40:46 +0200
Subject: [PATCH] Add iconUrl() to QWebEngineHistoryItem

Change-Id: I61bda1aafc7513acdaeda99ef493ce50363d352e
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
---
 src/core/web_contents_adapter.cpp              | 10 ++++++++++
 src/core/web_contents_adapter.h                |  1 +
 src/webenginewidgets/api/qwebenginehistory.cpp |  6 ++++++
 src/webenginewidgets/api/qwebenginehistory.h   |  1 +
 4 files changed, 18 insertions(+)

diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index a4a8bbe23..0bed6b038 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -592,6 +592,16 @@ QDateTime WebContentsAdapter::getNavigationEntryTimestamp(int index)
     return entry ? toQt(entry->GetTimestamp()) : QDateTime();
 }
 
+QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index)
+{
+    Q_D(WebContentsAdapter);
+    content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+    if (!entry)
+        return QUrl();
+    content::FaviconStatus favicon = entry->GetFavicon();
+    return favicon.valid ? toQt(favicon.url) : QUrl();
+}
+
 void WebContentsAdapter::clearNavigationHistory()
 {
     Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index ee8ed0aea..3adec2141 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -95,6 +95,7 @@ public:
     QUrl getNavigationEntryUrl(int index);
     QString getNavigationEntryTitle(int index);
     QDateTime getNavigationEntryTimestamp(int index);
+    QUrl getNavigationEntryIconUrl(int index);
     void clearNavigationHistory();
     void serializeNavigationHistory(QDataStream &output);
     void setZoomFactor(qreal);
diff --git a/src/webenginewidgets/api/qwebenginehistory.cpp b/src/webenginewidgets/api/qwebenginehistory.cpp
index 8d4267b53..33dc0cae8 100644
--- a/src/webenginewidgets/api/qwebenginehistory.cpp
+++ b/src/webenginewidgets/api/qwebenginehistory.cpp
@@ -97,6 +97,12 @@ QDateTime QWebEngineHistoryItem::lastVisited() const
     return d->page ? d->page->webContents()->getNavigationEntryTimestamp(d->index) : QDateTime();
 }
 
+QUrl QWebEngineHistoryItem::iconUrl() const
+{
+    Q_D(const QWebEngineHistoryItem);
+    return d->page ? d->page->webContents()->getNavigationEntryIconUrl(d->index) : QUrl();
+}
+
 bool QWebEngineHistoryItem::isValid() const
 {
     Q_D(const QWebEngineHistoryItem);
diff --git a/src/webenginewidgets/api/qwebenginehistory.h b/src/webenginewidgets/api/qwebenginehistory.h
index b56cdd883..5061facd6 100644
--- a/src/webenginewidgets/api/qwebenginehistory.h
+++ b/src/webenginewidgets/api/qwebenginehistory.h
@@ -46,6 +46,7 @@ public:
 
     QString title() const;
     QDateTime lastVisited() const;
+    QUrl iconUrl() const;
 
     bool isValid() const;
 private:
-- 
GitLab