Bug 799609 - Disable Places in B2G - Part 2 - Allow docshell and content to build without Places

Expose NotifyVisited API and fix code so it can be built with alternative history implementations.
r=jlebar
This commit is contained in:
Marco Bonardo 2012-11-09 10:55:54 +01:00
parent 46624ddc00
commit dd1dc9fc79
6 changed files with 42 additions and 24 deletions

View File

@ -90,17 +90,19 @@ Link::LinkState() const
}
// We have a good href, so register with History.
nsresult rv = mHistory->RegisterVisitedCallback(hrefURI, self);
if (NS_SUCCEEDED(rv)) {
self->mRegistered = true;
if (mHistory) {
nsresult rv = mHistory->RegisterVisitedCallback(hrefURI, self);
if (NS_SUCCEEDED(rv)) {
self->mRegistered = true;
// Assume that we are not visited until we are told otherwise.
self->mLinkState = eLinkState_Unvisited;
// Assume that we are not visited until we are told otherwise.
self->mLinkState = eLinkState_Unvisited;
// And make sure we are in the document's link map.
nsIDocument *doc = element->GetCurrentDoc();
if (doc) {
doc->AddStyleRelevantLink(self);
// And make sure we are in the document's link map.
nsIDocument *doc = element->GetCurrentDoc();
if (doc) {
doc->AddStyleRelevantLink(self);
}
}
}
}
@ -468,10 +470,12 @@ Link::UnregisterFromHistory()
NS_ASSERTION(mCachedURI, "mRegistered is true, but we have no cached URI?!");
// And tell History to stop tracking us.
nsresult rv = mHistory->UnregisterVisitedCallback(mCachedURI, this);
NS_ASSERTION(NS_SUCCEEDED(rv), "This should only fail if we misuse the API!");
if (NS_SUCCEEDED(rv)) {
mRegistered = false;
if (mHistory) {
nsresult rv = mHistory->UnregisterVisitedCallback(mCachedURI, this);
NS_ASSERTION(NS_SUCCEEDED(rv), "This should only fail if we misuse the API!");
if (NS_SUCCEEDED(rv)) {
mRegistered = false;
}
}
}

View File

@ -18,8 +18,9 @@ namespace mozilla {
class Link;
}
// 0057c9d3-b98e-4933-bdc5-0275d06705e1
#define IHISTORY_IID \
{0x6f733924, 0x6321, 0x4384, {0x01, 0xee, 0x8e, 0x7d, 0xfb, 0xde, 0xe7, 0xa8}}
{0x0057c9d3, 0xb98e, 0x4933, {0xbd, 0xc5, 0x02, 0x75, 0xd0, 0x67, 0x05, 0xe1}}
class IHistory : public nsISupports
{
@ -117,6 +118,14 @@ public:
* The title string.
*/
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
/**
* Notifies about the visited status of a given URI.
*
* @param aURI
* The URI to notify about.
*/
NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
@ -129,7 +138,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
NS_IMETHOD VisitURI(nsIURI *aURI, \
nsIURI *aLastVisitedURI, \
uint32_t aFlags); \
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle);
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle); \
NS_IMETHOD NotifyVisited(nsIURI* aURI);
} // namespace mozilla

View File

@ -128,8 +128,10 @@
#include "nsIStrictTransportSecurityService.h"
#include "nsStructuredCloneContainer.h"
#include "nsIStructuredCloneContainer.h"
#ifdef MOZ_PLACES
#include "nsIFaviconService.h"
#include "mozIAsyncFavicons.h"
#endif
// Editor-related
#include "nsIEditingSession.h"
@ -8237,6 +8239,7 @@ nsDocShell::CheckLoadingPermissions()
namespace
{
#ifdef MOZ_PLACES
// Callback used by CopyFavicon to inform the favicon service that one URI
// (mNewURI) has the same favicon URI (OnComplete's aFaviconURI) as another.
class nsCopyFaviconCallback MOZ_FINAL : public nsIFaviconDataCallback
@ -8279,10 +8282,12 @@ private:
};
NS_IMPL_ISUPPORTS1(nsCopyFaviconCallback, nsIFaviconDataCallback)
#endif
// Tell the favicon service that aNewURI has the same favicon as aOldURI.
void CopyFavicon(nsIURI *aOldURI, nsIURI *aNewURI, bool inPrivateBrowsing)
{
#ifdef MOZ_PLACES
nsCOMPtr<mozIAsyncFavicons> favSvc =
do_GetService("@mozilla.org/browser/favicon-service;1");
if (favSvc) {
@ -8290,6 +8295,7 @@ void CopyFavicon(nsIURI *aOldURI, nsIURI *aNewURI, bool inPrivateBrowsing)
new nsCopyFaviconCallback(aNewURI, inPrivateBrowsing);
favSvc->GetFaviconURLForPage(aOldURI, callback);
}
#endif
}
} // anonymous namespace

View File

@ -53,7 +53,7 @@
#include "nsDebugImpl.h"
#include "nsLayoutStylesheetCache.h"
#include "History.h"
#include "IHistory.h"
#include "nsDocShellCID.h"
#include "nsNetUtil.h"
@ -115,7 +115,6 @@ using namespace mozilla::hal_sandbox;
using namespace mozilla::ipc;
using namespace mozilla::layers;
using namespace mozilla::net;
using namespace mozilla::places;
#if defined(MOZ_WIDGET_GONK)
using namespace mozilla::system;
#endif
@ -902,7 +901,10 @@ ContentChild::RecvNotifyVisited(const URIParams& aURI)
if (!newURI) {
return false;
}
History::GetService()->NotifyVisited(newURI);
nsCOMPtr<IHistory> history = services::GetHistoryService();
if (history) {
history->NotifyVisited(newURI);
}
return true;
}

View File

@ -17,7 +17,7 @@
#include "AppProcessPermissions.h"
#include "CrashReporterParent.h"
#include "History.h"
#include "IHistory.h"
#include "IDBFactory.h"
#include "IndexedDBParent.h"
#include "IndexedDatabaseManager.h"
@ -123,7 +123,6 @@ using namespace mozilla::hal_sandbox;
using namespace mozilla::ipc;
using namespace mozilla::layers;
using namespace mozilla::net;
using namespace mozilla::places;
namespace mozilla {
namespace dom {
@ -1613,7 +1612,6 @@ ContentParent::RecvStartVisitedQuery(const URIParams& aURI)
return false;
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point.");
if (history) {
history->RegisterVisitedCallback(newURI, nullptr);
}
@ -1632,7 +1630,6 @@ ContentParent::RecvVisitURI(const URIParams& uri,
}
nsCOMPtr<nsIURI> ourReferrer = DeserializeURI(referrer);
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point");
if (history) {
history->VisitURI(ourURI, ourReferrer, flags);
}
@ -1649,7 +1646,6 @@ ContentParent::RecvSetURITitle(const URIParams& uri,
return false;
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point");
if (history) {
history->SetURITitle(ourURI, title);
}

View File

@ -85,7 +85,7 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir)/../../content/base/src \
-I$(srcdir)/../../content/events/src \
-I$(srcdir)/../../toolkit/components/places \
-I$(srcdir)/../../docshell/base \
-I$(topsrcdir)/chrome/src \
-I$(topsrcdir)/uriloader/exthandler \
-I$(srcdir)/../../netwerk/base/src \