summaryrefslogtreecommitdiffstats
path: root/src/core/favicon_driver_qt.h
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2022-06-20 10:16:44 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2022-06-23 08:37:43 +0200
commit3c30a71eaca8edd76cbc15f46632a6f7bbebc7fb (patch)
tree71953c5d64cd9e97f926c5bd2db38df9c2471d87 /src/core/favicon_driver_qt.h
parent9b9d789fcb8f63a8998f1eefe44f2a1c8156c362 (diff)
Adapt FaviconDriverQt to Chromium 98
This change adapts upstream Chromium's favicon::ContentFaviconDriver fixes: * Call constructor that takes a WebContents for WebContentsUserData. http://crrev.com/c/3278400 * Rename RenderDocumentHostUserData to DocumentUserData http://crrev.com/c/3208909 * Make helper macros behave consistently for //content/public UserData types http://crrev.com/c/3198788 * Introduce RenderDocumentHostUserData::render_frame_host accessor. http://crrev.com/c/3176183 * [SPC] Support SVG card art icons with no intrinsic size http://crrev.com/c/3148035 * Do not request favicons on regular page reload http://crrev.com/c/3097606 * Replace blink::Manifest with blink::mojom::Manifest http://crrev.com/c/3060401 * [mparch] Move UpdateManifestURL() to PageImpl http://crrev.com/c/2972153 * [content] Introduce WebContents::GetPrimaryPage http://crrev.com/c/2969524 * [mparch] Update a manifest url on the prerendering activation http://crrev.com/c/2952744 * [mparch] Move WebContents::GetManifest to Page. http://crrev.com/c/2955119 * [content] Introduce content::Page http://crrev.com/c/2916488 * Reland "[mparch] Update ContentFaviconDriver" http://crrev.com/c/2852141 * favicons: fix manifest crash http://crrev.com/c/2343718 * favicons: adds CoreFaviconService http://crrev.com/c/2313098 Pick-to: 6.4 Change-Id: I54a3eab98a4b168b22c42a10823ea88eb8fd6f4a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/favicon_driver_qt.h')
-rw-r--r--src/core/favicon_driver_qt.h46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/core/favicon_driver_qt.h b/src/core/favicon_driver_qt.h
index 864291566..96bd682a2 100644
--- a/src/core/favicon_driver_qt.h
+++ b/src/core/favicon_driver_qt.h
@@ -19,7 +19,9 @@
#include "components/favicon/core/favicon_driver.h"
#include "components/favicon/core/favicon_handler.h"
+#include "content/public/browser/document_user_data.h"
#include "content/public/browser/favicon_status.h"
+#include "content/public/browser/navigation_handle_user_data.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
@@ -29,7 +31,7 @@ class WebContents;
}
namespace favicon {
-class FaviconService;
+class CoreFaviconService;
}
namespace QtWebEngineCore {
@@ -51,7 +53,7 @@ class FaviconDriverQt : public favicon::FaviconDriver,
{
public:
static void CreateForWebContents(content::WebContents *webContents,
- favicon::FaviconService *faviconService,
+ favicon::CoreFaviconService *faviconService,
WebContentsAdapterClient *viewClient);
// FaviconDriver implementation.
@@ -60,15 +62,38 @@ public:
bool FaviconIsValid() const override;
GURL GetActiveURL() override;
+ GURL GetManifestURL(content::RenderFrameHost *rfh);
GURL GetFaviconURL() const;
protected:
- FaviconDriverQt(content::WebContents *webContent, favicon::FaviconService *faviconService,
+ FaviconDriverQt(content::WebContents *webContent, favicon::CoreFaviconService *faviconService,
WebContentsAdapterClient *viewClient);
private:
friend class content::WebContentsUserData<FaviconDriverQt>;
+ // TODO(crbug.com/1205018): these two classes are current used to ensure that
+ // we disregard manifest URL updates that arrive prior to onload firing.
+ struct DocumentManifestData : public content::DocumentUserData<DocumentManifestData>
+ {
+ explicit DocumentManifestData(content::RenderFrameHost *rfh);
+ ~DocumentManifestData() override;
+ DOCUMENT_USER_DATA_KEY_DECL();
+ bool has_manifest_url = false;
+ };
+
+ struct NavigationManifestData : public content::NavigationHandleUserData<NavigationManifestData>
+ {
+ explicit NavigationManifestData(content::NavigationHandle &navigation_handle);
+ ~NavigationManifestData() override;
+ NAVIGATION_HANDLE_USER_DATA_KEY_DECL();
+ bool has_manifest_url = false;
+ };
+
+ // Callback when a manifest is downloaded.
+ void OnDidDownloadManifest(ManifestDownloadCallback callback, const GURL &manifest_url,
+ blink::mojom::ManifestPtr manifest);
+
// FaviconHandler::Delegate implementation.
int DownloadImage(const GURL &url, int max_image_size, ImageDownloadCallback callback) override;
void DownloadManifest(const GURL &url, ManifestDownloadCallback callback) override;
@@ -83,15 +108,13 @@ private:
void OnHandlerCompleted(favicon::FaviconHandler *handler) override;
// content::WebContentsObserver implementation.
- void DidUpdateFaviconURL(content::RenderFrameHost *render_frame_host,
+ void DidUpdateFaviconURL(content::RenderFrameHost *rfh,
const std::vector<blink::mojom::FaviconURLPtr> &candidates) override;
- void DidUpdateWebManifestURL(content::RenderFrameHost *target_frame,
- const GURL &manifest_url) override;
+ void DidUpdateWebManifestURL(content::RenderFrameHost *rfh, const GURL &manifest_url) override;
void DidStartNavigation(content::NavigationHandle *navigation_handle) override;
void DidFinishNavigation(content::NavigationHandle *navigation_handle) override;
- void DocumentOnLoadCompletedInMainFrame(content::RenderFrameHost *render_frame_host) override;
- // Informs FaviconService that the favicon for |url| is out of date. If
+ // Informs CoreFaviconService that the favicon for |url| is out of date. If
// |force_reload| is true, then discard information about favicon download
// failures.
void SetFaviconOutOfDateForPage(const GURL &url, bool force_reload);
@@ -105,20 +128,17 @@ private:
// KeyedService used by FaviconDriverImpl. It may be null during testing,
// but if it is defined, it must outlive the FaviconDriverImpl.
- favicon::FaviconService *m_faviconService;
+ raw_ptr<favicon::CoreFaviconService> m_faviconService;
WebContentsAdapterClient *m_viewClient;
- // FaviconHandlers used to download the different kind of favicons.
+ // FaviconHandlers are used to download the different kind of favicons.
std::vector<std::unique_ptr<favicon::FaviconHandler>> m_handlers;
GURL m_bypassCachePageURL;
- bool m_documentOnLoadCompleted = false;
// nullopt until the actual list is reported via DidUpdateFaviconURL().
absl::optional<std::vector<blink::mojom::FaviconURLPtr>> m_faviconUrls;
- // Web Manifest URL or empty URL if none.
- GURL m_manifestUrl;
int m_completedHandlersCount = 0;
FaviconStatusQt m_latestFavicon;