Bug 1093886 - Respect places.history.enabled to disable nsAndroidHistory. r=mfinkle

This commit is contained in:
Richard Newman 2014-11-04 16:55:34 -08:00
parent 769f5a80cb
commit 8502e8ba87
2 changed files with 29 additions and 0 deletions

View File

@ -10,8 +10,14 @@
#include "mozilla/Services.h"
#include "nsIObserverService.h"
#include "mozilla/Preferences.h"
#define NS_LINK_VISITED_EVENT_TOPIC "link-visited"
// We copy Places here.
// Note that we don't yet observe this pref at runtime.
#define PREF_HISTORY_ENABLED "places.history.enabled"
using namespace mozilla;
using mozilla::dom::Link;
@ -33,7 +39,9 @@ nsAndroidHistory::GetSingleton()
}
nsAndroidHistory::nsAndroidHistory()
: mHistoryEnabled(true)
{
LoadPrefs();
}
NS_IMETHODIMP
@ -105,6 +113,16 @@ nsAndroidHistory::AppendToRecentlyVisitedURIs(nsIURI* aURI) {
}
}
bool
nsAndroidHistory::ShouldRecordHistory() {
return mHistoryEnabled;
}
void
nsAndroidHistory::LoadPrefs() {
mHistoryEnabled = Preferences::GetBool(PREF_HISTORY_ENABLED, true);
}
inline bool
nsAndroidHistory::IsRecentlyVisitedURI(nsIURI* aURI) {
bool equals = false;
@ -266,6 +284,12 @@ nsAndroidHistory::CanAddURI(nsIURI* aURI, bool* canAdd)
NS_ENSURE_ARG(aURI);
NS_ENSURE_ARG_POINTER(canAdd);
// See if we're disabled.
if (!ShouldRecordHistory()) {
*canAdd = false;
return NS_OK;
}
nsAutoCString scheme;
nsresult rv = aURI->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -41,9 +41,14 @@ private:
static nsAndroidHistory* sHistory;
// Will mimic the value of the places.history.enabled preference.
bool mHistoryEnabled;
nsDataHashtable<nsStringHashKey, nsTArray<mozilla::dom::Link *> *> mListeners;
nsTPriorityQueue<nsString> mPendingURIs;
void LoadPrefs();
bool ShouldRecordHistory();
nsresult CanAddURI(nsIURI* aURI, bool* canAdd);
/**