From b3c445b4a4bf2cd06757a0db556ccc4fa993f4cc Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Thu, 25 Mar 2010 12:34:47 +0100 Subject: [PATCH] Bug 553489 - Part9: NotifyStep. r=sdwilsh --- .../places/src/AsyncFaviconHelpers.cpp | 30 +++++++++++++++++++ .../places/src/AsyncFaviconHelpers.h | 13 ++++++++ .../components/places/src/nsFaviconService.h | 7 +++-- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/toolkit/components/places/src/AsyncFaviconHelpers.cpp b/toolkit/components/places/src/AsyncFaviconHelpers.cpp index c428cb54bfc2..4e3bb24ee59f 100644 --- a/toolkit/components/places/src/AsyncFaviconHelpers.cpp +++ b/toolkit/components/places/src/AsyncFaviconHelpers.cpp @@ -932,6 +932,36 @@ AssociateIconWithPageStep::HandleCompletion(PRUint16 aReason) //////////////////////////////////////////////////////////////////////////////// +//// NotifyStep + +NS_IMPL_ISUPPORTS_INHERITED0( + NotifyStep +, AsyncFaviconStep +) + + +void +NotifyStep::Run() +{ + NS_ASSERTION(mStepper, "Step is not associated to a stepper"); + // If a new icon has been added to the database or an icon has been associated + // with a page, we want to notify. + FAVICONSTEP_CANCEL_IF_TRUE(mStepper->mData.Length() == 0, PR_FALSE); + + if (mStepper->mIconStatus & ICON_STATUS_SAVED || + mStepper->mIconStatus & ICON_STATUS_ASSOCIATED) { + nsFaviconService* fs = nsFaviconService::GetFaviconService(); + FAVICONSTEP_FAIL_IF_FALSE(fs); + fs->SendFaviconNotifications(mStepper->mPageURI, mStepper->mIconURI); + nsresult rv = fs->UpdateBookmarkRedirectFavicon(mStepper->mPageURI, + mStepper->mIconURI); + FAVICONSTEP_FAIL_IF_FALSE(NS_SUCCEEDED(rv)); + } + + // Proceed to next step. + nsresult rv = mStepper->Step(); + FAVICONSTEP_FAIL_IF_FALSE(NS_SUCCEEDED(rv)); +} } // namespace places } // namespace mozilla diff --git a/toolkit/components/places/src/AsyncFaviconHelpers.h b/toolkit/components/places/src/AsyncFaviconHelpers.h index 2e450dc0b72b..722c14430e69 100644 --- a/toolkit/components/places/src/AsyncFaviconHelpers.h +++ b/toolkit/components/places/src/AsyncFaviconHelpers.h @@ -378,6 +378,19 @@ public: void Run(); }; + +/** + * Notify favicon changes. + */ +class NotifyStep : public AsyncFaviconStep +{ +public: + NS_DECL_ISUPPORTS_INHERITED + + NotifyStep() {}; + void Run(); +}; + } // namespace places } // namespace mozilla diff --git a/toolkit/components/places/src/nsFaviconService.h b/toolkit/components/places/src/nsFaviconService.h index d9d82d2b2666..843b1c7e3cbe 100644 --- a/toolkit/components/places/src/nsFaviconService.h +++ b/toolkit/components/places/src/nsFaviconService.h @@ -163,6 +163,10 @@ public: return nsnull; } + nsresult UpdateBookmarkRedirectFavicon(nsIURI* aPage, nsIURI* aFavicon); + + void SendFaviconNotifications(nsIURI* aPage, nsIURI* aFaviconURI); + NS_DECL_ISUPPORTS NS_DECL_NSIFAVICONSERVICE @@ -213,9 +217,6 @@ private: nsresult SetFaviconUrlForPageInternal(nsIURI* aURI, nsIURI* aFavicon, PRBool* aHasData); - nsresult UpdateBookmarkRedirectFavicon(nsIURI* aPage, nsIURI* aFavicon); - void SendFaviconNotifications(nsIURI* aPage, nsIURI* aFaviconURI); - friend class FaviconLoadListener; bool mShuttingDown;