From a99922affdc7953f092dcfcf34ea741567a5bddc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 28 Jul 2014 16:35:16 +0200 Subject: Add api to get the favicon URL Adds one of the missing pieces of the QWebFrame and QWebView APIs. Unlike the QtWebKit version this only fetches the favicon URL, and not the icon. This is because we do not want to implement an icon database, and that the icon would be loaded asynchronous anyway, bringing no guarantee to be a valid icon/image yet. Change-Id: I227311ae3676044da850e687b82bee752b5079c8 Reviewed-by: Jocelyn Turcotte --- src/core/web_contents_adapter.cpp | 12 ++++++++++++ src/core/web_contents_adapter.h | 1 + 2 files changed, 13 insertions(+) (limited to 'src/core') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 235534f18..3dcef4ba4 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -62,6 +62,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/favicon_status.h" #include "content/public/common/page_state.h" #include "content/public/common/page_zoom.h" #include "content/public/common/renderer_preferences.h" @@ -472,6 +473,17 @@ QUrl WebContentsAdapter::requestedUrl() const return QUrl(); } +QUrl WebContentsAdapter::iconUrl() const +{ + Q_D(const WebContentsAdapter); + if (content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry()) { + content::FaviconStatus favicon = entry->GetFavicon(); + if (favicon.valid) + return toQt(favicon.url); + } + return QUrl(); +} + QString WebContentsAdapter::pageTitle() const { Q_D(const WebContentsAdapter); diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 8e665ee2c..a20d55959 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -76,6 +76,7 @@ public: QUrl requestedUrl() const; QString pageTitle() const; QString selectedText() const; + QUrl iconUrl() const; void undo(); void redo(); -- cgit v1.2.3