mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 1093886 - Respect places.history.enabled to disable nsAndroidHistory. r=mfinkle
This commit is contained in:
parent
550edd741f
commit
70b1c2b64e
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user