diff options
author | Michal Klocek <michal.klocek@qt.io> | 2018-05-14 10:20:34 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2018-05-17 12:44:30 +0000 |
commit | 216f19d52ce9e920349da9247afc2c8e85df2c56 (patch) | |
tree | 2e546b04f1acfa1572f2e8c8e80b37fcb1105a17 /src/core/favicon_manager.h | |
parent | 0d330addcf37820e516737167bf174d2c35c4010 (diff) |
Reduce boilerplate code for FaviconManager
Remove private implementation for FaviconManager
Make FaviconManager non QObject since there no reason
to do so.
Change-Id: I8e341f9bd2dbc6f3fa977693383bbbf7349ab0b0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/favicon_manager.h')
-rw-r--r-- | src/core/favicon_manager.h | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/src/core/favicon_manager.h b/src/core/favicon_manager.h index e351831c2..28244f90b 100644 --- a/src/core/favicon_manager.h +++ b/src/core/favicon_manager.h @@ -41,7 +41,7 @@ #define FAVICON_MANAGER_H #include "qtwebenginecoreglobal.h" - +#include <memory> #include <QtCore/QMap> #include <QtCore/QObject> #include <QtCore/QSize> @@ -50,9 +50,25 @@ #include "web_engine_settings.h" +class GURL; +class SkBitmap; + +namespace gfx { +class Size; +} + +namespace content { +class WebContents; +} + +namespace base { +template<class T> +class WeakPtrFactory; +} + namespace QtWebEngineCore { -class FaviconManagerPrivate; +class WebContentsAdapterClient; // Based on src/3rdparty/chromium/content/public/common/favicon_url.h class QWEBENGINE_EXPORT FaviconInfo { @@ -81,9 +97,10 @@ public: }; -class QWEBENGINE_EXPORT FaviconManager : public QObject { - Q_OBJECT +class QWEBENGINE_EXPORT FaviconManager { + public: + FaviconManager(content::WebContents *, WebContentsAdapterClient *); ~FaviconManager(); QIcon getIcon(const QUrl &url = QUrl()) const; @@ -91,24 +108,28 @@ public: QList<FaviconInfo> getFaviconInfoList(bool) const; private: - FaviconManager(FaviconManagerPrivate *); - void update(const QList<FaviconInfo> &); void updateCandidates(const QList<FaviconInfo> &); void resetCandidates(); bool hasCandidate() const; - QUrl candidateIconUrl(bool touchIconsEnabled) const; void generateCandidateIcon(bool touchIconsEnabled); + int downloadIcon(const QUrl &); + void iconDownloadFinished(int, int, const GURL &, const std::vector<SkBitmap> &, const std::vector<gfx::Size> &); + void storeIcon(int, const QIcon &); + void downloadPendingRequests(); + void propagateIcon(const QUrl &) const; +private: + content::WebContents *m_webContents; + WebContentsAdapterClient *m_viewClient; QMap<QUrl, FaviconInfo> m_faviconInfoMap; int m_candidateCount; QIcon m_candidateIcon; - - Q_DISABLE_COPY(FaviconManager) - Q_DECLARE_PRIVATE(FaviconManager) - QScopedPointer<FaviconManagerPrivate> d_ptr; - + QMap<QUrl, QIcon> m_icons; + QMap<int, QUrl> m_inProgressRequests; + QMap<int, QUrl> m_pendingRequests; + std::unique_ptr<base::WeakPtrFactory<FaviconManager>> m_weakFactory; friend class WebContentsDelegateQt; }; |