diff options
Diffstat (limited to 'chromium/content/browser/manifest')
4 files changed, 14 insertions, 22 deletions
diff --git a/chromium/content/browser/manifest/manifest_browsertest.cc b/chromium/content/browser/manifest/manifest_browsertest.cc index e77855bd836..cecb5b151cd 100644 --- a/chromium/content/browser/manifest/manifest_browsertest.cc +++ b/chromium/content/browser/manifest/manifest_browsertest.cc @@ -131,12 +131,14 @@ class ManifestBrowserTest : public ContentBrowserTest, // WebContentsObserver: void DidUpdateFaviconURL( + RenderFrameHost* rfh, const std::vector<blink::mojom::FaviconURLPtr>& candidates) override { manifests_reported_when_favicon_url_updated_.push_back( reported_manifest_urls_.size()); } void DidUpdateWebManifestURL( + RenderFrameHost* rfh, const base::Optional<GURL>& manifest_url) override { if (!manifest_url) { reported_manifest_urls_.emplace_back(); diff --git a/chromium/content/browser/manifest/manifest_icon_downloader.cc b/chromium/content/browser/manifest/manifest_icon_downloader.cc index bb5cb8b6245..a43b1a0b88d 100644 --- a/chromium/content/browser/manifest/manifest_icon_downloader.cc +++ b/chromium/content/browser/manifest/manifest_icon_downloader.cc @@ -12,7 +12,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/numerics/safe_conversions.h" -#include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" @@ -126,8 +125,8 @@ void ManifestIconDownloader::OnIconFetched( // webapp storage system as well. if (chosen.height() > ideal_icon_size_in_px || chosen.width() > ideal_icon_width_in_px) { - base::PostTask(FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&ManifestIconDownloader::ScaleIcon, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&ManifestIconDownloader::ScaleIcon, ideal_icon_width_in_px, ideal_icon_size_in_px, chosen, std::move(callback))); return; @@ -146,8 +145,8 @@ void ManifestIconDownloader::ScaleIcon(int ideal_icon_width_in_px, bitmap, skia::ImageOperations::RESIZE_BEST, ideal_icon_width_in_px, ideal_icon_height_in_px); - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(std::move(callback), scaled)); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), scaled)); } int ManifestIconDownloader::FindClosestBitmapIndex( diff --git a/chromium/content/browser/manifest/manifest_manager_host.cc b/chromium/content/browser/manifest/manifest_manager_host.cc index 68ea016c62e..2b847ca01fe 100644 --- a/chromium/content/browser/manifest/manifest_manager_host.cc +++ b/chromium/content/browser/manifest/manifest_manager_host.cc @@ -22,7 +22,7 @@ ManifestManagerHost::ManifestManagerHost(RenderFrameHost* render_frame_host) } ManifestManagerHost::~ManifestManagerHost() { - OnConnectionError(); + DispatchPendingCallbacks(); } void ManifestManagerHost::BindObserver( @@ -31,14 +31,6 @@ void ManifestManagerHost::BindObserver( manifest_url_change_observer_receiver_.Bind(std::move(receiver)); } -ManifestManagerHost* ManifestManagerHost::GetOrCreateForCurrentDocument( - RenderFrameHostImpl* rfh) { - DCHECK(rfh->is_main_frame()); - if (!GetForCurrentDocument(rfh)) - CreateForCurrentDocument(rfh); - return GetForCurrentDocument(rfh); -} - void ManifestManagerHost::GetManifest(GetManifestCallback callback) { auto& manifest_manager = GetManifestManager(); int request_id = callbacks_.Add( @@ -63,7 +55,7 @@ blink::mojom::ManifestManager& ManifestManagerHost::GetManifestManager() { return *manifest_manager_; } -void ManifestManagerHost::OnConnectionError() { +void ManifestManagerHost::DispatchPendingCallbacks() { std::vector<GetManifestCallback> callbacks; for (CallbackMap::iterator it(&callbacks_); !it.IsAtEnd(); it.Advance()) { callbacks.push_back(std::move(*it.GetCurrentValue())); @@ -71,7 +63,10 @@ void ManifestManagerHost::OnConnectionError() { callbacks_.Clear(); for (auto& callback : callbacks) std::move(callback).Run(GURL(), blink::Manifest()); +} +void ManifestManagerHost::OnConnectionError() { + DispatchPendingCallbacks(); if (GetForCurrentDocument(manifest_manager_frame_)) { DeleteForCurrentDocument(manifest_manager_frame_); } @@ -91,12 +86,10 @@ void ManifestManagerHost::ManifestUrlChanged( if (!manifest_manager_frame_->IsCurrent()) return; - // TODO(yuzus): |NotifyManifestUrlChanged| should start taking a - // |RenderFrameHost| parameter. WebContents* web_contents = WebContents::FromRenderFrameHost(manifest_manager_frame_); static_cast<WebContentsImpl*>(web_contents) - ->NotifyManifestUrlChanged(manifest_url); + ->NotifyManifestUrlChanged(manifest_manager_frame_, manifest_url); } RENDER_DOCUMENT_HOST_USER_DATA_KEY_IMPL(ManifestManagerHost) diff --git a/chromium/content/browser/manifest/manifest_manager_host.h b/chromium/content/browser/manifest/manifest_manager_host.h index 57f51dc9fad..f706c20bdb8 100644 --- a/chromium/content/browser/manifest/manifest_manager_host.h +++ b/chromium/content/browser/manifest/manifest_manager_host.h @@ -21,7 +21,6 @@ struct Manifest; namespace content { class RenderFrameHost; -class RenderFrameHostImpl; // ManifestManagerHost is a helper class that allows callers to get the Manifest // associated with the main frame of the observed WebContents. It handles the @@ -48,9 +47,6 @@ class ManifestManagerHost mojo::PendingAssociatedReceiver<blink::mojom::ManifestUrlChangeObserver> receiver); - static ManifestManagerHost* GetOrCreateForCurrentDocument( - RenderFrameHostImpl* rfh); - private: explicit ManifestManagerHost(RenderFrameHost* render_frame_host); @@ -59,6 +55,8 @@ class ManifestManagerHost using CallbackMap = base::IDMap<std::unique_ptr<GetManifestCallback>>; blink::mojom::ManifestManager& GetManifestManager(); + + void DispatchPendingCallbacks(); void OnConnectionError(); void OnRequestManifestResponse(int request_id, |