2006-07-18 17:06:47 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-07-18 17:06:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The definitions of objects that make up a history query result set. This file
|
|
|
|
* should only be included by nsNavHistory.h, include that if you want these
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsNavHistoryResult_h_
|
|
|
|
#define nsNavHistoryResult_h_
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsDataHashtable.h"
|
2007-10-19 06:26:34 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-04-09 18:30:29 +00:00
|
|
|
#include "mozilla/storage.h"
|
|
|
|
#include "Helpers.h"
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2006-07-18 17:07:10 +00:00
|
|
|
class nsNavHistory;
|
2006-07-18 17:09:28 +00:00
|
|
|
class nsNavHistoryQuery;
|
2006-07-18 17:06:47 +00:00
|
|
|
class nsNavHistoryQueryOptions;
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
class nsNavHistoryContainerResultNode;
|
|
|
|
class nsNavHistoryFolderResultNode;
|
|
|
|
class nsNavHistoryQueryResultNode;
|
|
|
|
class nsNavHistoryVisitResultNode;
|
|
|
|
|
|
|
|
/**
|
2012-08-22 15:56:38 +00:00
|
|
|
* hashkey wrapper using int64_t KeyType
|
2006-07-18 17:09:05 +00:00
|
|
|
*
|
|
|
|
* @see nsTHashtable::EntryType for specification
|
|
|
|
*
|
|
|
|
* This just truncates the 64-bit int to a 32-bit one for using a hash number.
|
|
|
|
* It is used for bookmark folder IDs, which should be way less than 2^32.
|
|
|
|
*/
|
|
|
|
class nsTrimInt64HashKey : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
typedef const int64_t& KeyType;
|
|
|
|
typedef const int64_t* KeyTypePointer;
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
nsTrimInt64HashKey(KeyTypePointer aKey) : mValue(*aKey) { }
|
|
|
|
nsTrimInt64HashKey(const nsTrimInt64HashKey& toCopy) : mValue(toCopy.mValue) { }
|
|
|
|
~nsTrimInt64HashKey() { }
|
|
|
|
|
|
|
|
KeyType GetKey() const { return mValue; }
|
2011-09-29 06:19:26 +00:00
|
|
|
bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
2012-09-28 06:57:33 +00:00
|
|
|
{ return static_cast<uint32_t>((*aKey) & UINT32_MAX); }
|
2011-10-17 14:59:28 +00:00
|
|
|
enum { ALLOW_MEMMOVE = true };
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
const int64_t mValue;
|
2006-07-18 17:09:05 +00:00
|
|
|
};
|
|
|
|
|
2006-07-18 17:14:44 +00:00
|
|
|
|
2006-07-18 17:06:47 +00:00
|
|
|
// Declare methods for implementing nsINavBookmarkObserver
|
|
|
|
// and nsINavHistoryObserver (some methods, such as BeginUpdateBatch overlap)
|
2012-12-20 22:45:00 +00:00
|
|
|
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
|
2006-07-18 17:06:47 +00:00
|
|
|
NS_DECL_NSINAVBOOKMARKOBSERVER \
|
2011-06-30 20:05:49 +00:00
|
|
|
NS_IMETHOD OnTitleChanged(nsIURI* aURI, const nsAString& aPageTitle, \
|
|
|
|
const nsACString& aGUID); \
|
2011-06-30 13:34:10 +00:00
|
|
|
NS_IMETHOD OnBeforeDeleteURI(nsIURI *aURI, const nsACString& aGUID, \
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t aReason); \
|
2011-06-30 13:34:10 +00:00
|
|
|
NS_IMETHOD OnDeleteURI(nsIURI *aURI, const nsACString& aGUID, \
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t aReason); \
|
2006-07-18 17:06:47 +00:00
|
|
|
NS_IMETHOD OnClearHistory(); \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD OnPageChanged(nsIURI *aURI, uint32_t aChangedAttribute, \
|
2011-06-30 20:06:56 +00:00
|
|
|
const nsAString &aNewValue, \
|
|
|
|
const nsACString &aGUID); \
|
2011-06-08 15:10:29 +00:00
|
|
|
NS_IMETHOD OnDeleteVisits(nsIURI* aURI, PRTime aVisitTime, \
|
2013-01-05 09:21:04 +00:00
|
|
|
const nsACString& aGUID, uint16_t aReason, \
|
|
|
|
uint32_t aTransitionType);
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2012-12-20 22:45:00 +00:00
|
|
|
// The internal version has an output aAdded parameter, it is incremented by
|
|
|
|
// query nodes when the visited uri belongs to them. If no such query exists,
|
|
|
|
// the history result creates a new query node dynamically.
|
|
|
|
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_INTERNAL \
|
|
|
|
NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
|
|
|
|
NS_IMETHOD OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, \
|
|
|
|
int64_t aSessionId, int64_t aReferringId, \
|
|
|
|
uint32_t aTransitionType, const nsACString& aGUID, \
|
|
|
|
bool aHidden, uint32_t* aAdded);
|
|
|
|
|
|
|
|
// The external version is used by results.
|
|
|
|
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_EXTERNAL \
|
|
|
|
NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
|
|
|
|
NS_IMETHOD OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, \
|
|
|
|
int64_t aSessionId, int64_t aReferringId, \
|
|
|
|
uint32_t aTransitionType, const nsACString& aGUID, \
|
|
|
|
bool aHidden);
|
|
|
|
|
2006-07-18 17:14:44 +00:00
|
|
|
// nsNavHistoryResult
|
|
|
|
//
|
|
|
|
// nsNavHistory creates this object and fills in mChildren (by getting
|
|
|
|
// it through GetTopLevel()). Then FilledAllResults() is called to finish
|
|
|
|
// object initialization.
|
|
|
|
|
|
|
|
#define NS_NAVHISTORYRESULT_IID \
|
|
|
|
{ 0x455d1d40, 0x1b9b, 0x40e6, { 0xa6, 0x41, 0x8b, 0xb7, 0xe8, 0x82, 0x23, 0x87 } }
|
|
|
|
|
|
|
|
class nsNavHistoryResult : public nsSupportsWeakReference,
|
|
|
|
public nsINavHistoryResult,
|
|
|
|
public nsINavBookmarkObserver,
|
|
|
|
public nsINavHistoryObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static nsresult NewHistoryResult(nsINavHistoryQuery** aQueries,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aQueryCount,
|
2006-07-18 17:14:44 +00:00
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsNavHistoryContainerResultNode* aRoot,
|
2010-11-12 21:14:47 +00:00
|
|
|
bool aBatchInProgress,
|
2006-07-18 17:14:44 +00:00
|
|
|
nsNavHistoryResult** result);
|
|
|
|
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYRESULT_IID)
|
|
|
|
|
2007-10-19 06:26:34 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2006-07-18 17:14:44 +00:00
|
|
|
NS_DECL_NSINAVHISTORYRESULT
|
2012-12-20 22:45:00 +00:00
|
|
|
NS_DECL_BOOKMARK_HISTORY_OBSERVER_EXTERNAL
|
2007-10-19 06:26:34 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsNavHistoryResult, nsINavHistoryResult)
|
2006-07-18 17:14:44 +00:00
|
|
|
|
2007-06-19 16:25:11 +00:00
|
|
|
void AddHistoryObserver(nsNavHistoryQueryResultNode* aNode);
|
2012-08-22 15:56:38 +00:00
|
|
|
void AddBookmarkFolderObserver(nsNavHistoryFolderResultNode* aNode, int64_t aFolder);
|
2007-06-19 16:25:11 +00:00
|
|
|
void AddAllBookmarksObserver(nsNavHistoryQueryResultNode* aNode);
|
|
|
|
void RemoveHistoryObserver(nsNavHistoryQueryResultNode* aNode);
|
2012-08-22 15:56:38 +00:00
|
|
|
void RemoveBookmarkFolderObserver(nsNavHistoryFolderResultNode* aNode, int64_t aFolder);
|
2007-06-19 16:25:11 +00:00
|
|
|
void RemoveAllBookmarksObserver(nsNavHistoryQueryResultNode* aNode);
|
2009-06-15 11:09:40 +00:00
|
|
|
void StopObserving();
|
2006-07-18 17:14:44 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// two-stage init, use NewHistoryResult to construct
|
|
|
|
nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot);
|
2009-04-18 12:12:01 +00:00
|
|
|
virtual ~nsNavHistoryResult();
|
2006-07-18 17:14:44 +00:00
|
|
|
nsresult Init(nsINavHistoryQuery** aQueries,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aQueryCount,
|
2006-07-18 17:14:44 +00:00
|
|
|
nsNavHistoryQueryOptions *aOptions);
|
|
|
|
|
|
|
|
nsRefPtr<nsNavHistoryContainerResultNode> mRootNode;
|
|
|
|
|
|
|
|
nsCOMArray<nsINavHistoryQuery> mQueries;
|
|
|
|
nsCOMPtr<nsNavHistoryQueryOptions> mOptions;
|
|
|
|
|
|
|
|
// One of nsNavHistoryQueryOptions.SORY_BY_* This is initialized to mOptions.sortingMode,
|
|
|
|
// but may be overridden if the user clicks on one of the columns.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t mSortingMode;
|
2009-06-15 11:09:40 +00:00
|
|
|
// If root node is closed and we try to apply a sortingMode, it would not
|
|
|
|
// work. So we will apply it when the node will be reopened and populated.
|
|
|
|
// This var states the fact we need to apply sortingMode in such a situation.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mNeedsToApplySortingMode;
|
2006-07-18 17:14:44 +00:00
|
|
|
|
2007-04-22 22:20:25 +00:00
|
|
|
// The sorting annotation to be used for in SORT_BY_ANNOTATION_* modes
|
|
|
|
nsCString mSortingAnnotation;
|
|
|
|
|
2006-07-18 17:14:44 +00:00
|
|
|
// node observers
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsHistoryObserver;
|
|
|
|
bool mIsBookmarkFolderObserver;
|
|
|
|
bool mIsAllBookmarksObserver;
|
2007-06-19 16:25:11 +00:00
|
|
|
|
2009-04-18 12:12:01 +00:00
|
|
|
typedef nsTArray< nsRefPtr<nsNavHistoryQueryResultNode> > QueryObserverList;
|
|
|
|
QueryObserverList mHistoryObservers;
|
|
|
|
QueryObserverList mAllBookmarksObservers;
|
|
|
|
|
|
|
|
typedef nsTArray< nsRefPtr<nsNavHistoryFolderResultNode> > FolderObserverList;
|
|
|
|
nsDataHashtable<nsTrimInt64HashKey, FolderObserverList*> mBookmarkFolderObservers;
|
2012-08-22 15:56:38 +00:00
|
|
|
FolderObserverList* BookmarkFolderObserversForId(int64_t aFolderId, bool aCreate);
|
2006-07-18 17:14:44 +00:00
|
|
|
|
2010-11-12 21:14:47 +00:00
|
|
|
typedef nsTArray< nsRefPtr<nsNavHistoryContainerResultNode> > ContainerObserverList;
|
|
|
|
|
2006-07-18 17:14:44 +00:00
|
|
|
void RecursiveExpandCollapse(nsNavHistoryContainerResultNode* aContainer,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aExpand);
|
2006-07-18 17:14:44 +00:00
|
|
|
|
|
|
|
void InvalidateTree();
|
2007-08-14 14:20:42 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mBatchInProgress;
|
2010-03-12 11:14:47 +00:00
|
|
|
|
|
|
|
nsMaybeWeakPtrArray<nsINavHistoryResultObserver> mObservers;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mSuppressNotifications;
|
2010-11-12 21:14:47 +00:00
|
|
|
|
|
|
|
ContainerObserverList mRefreshParticipants;
|
|
|
|
void requestRefresh(nsNavHistoryContainerResultNode* aContainer);
|
2006-07-18 17:14:44 +00:00
|
|
|
};
|
|
|
|
|
2006-11-14 23:12:10 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryResult, NS_NAVHISTORYRESULT_IID)
|
2006-07-18 17:14:44 +00:00
|
|
|
|
2006-07-18 17:06:47 +00:00
|
|
|
// nsNavHistoryResultNode
|
|
|
|
//
|
|
|
|
// This is the base class for every node in a result set. The result itself
|
|
|
|
// is a node (nsNavHistoryResult inherits from this), as well as every
|
|
|
|
// leaf and branch on the tree.
|
|
|
|
|
|
|
|
#define NS_NAVHISTORYRESULTNODE_IID \
|
|
|
|
{0x54b61d38, 0x57c1, 0x11da, {0x95, 0xb8, 0x00, 0x13, 0x21, 0xc9, 0xf6, 0x9e}}
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// These are all the simple getters, they can be used for the result node
|
2006-07-18 17:11:38 +00:00
|
|
|
// implementation and all subclasses. More complex are GetIcon, GetParent
|
|
|
|
// (which depends on the definition of container result node), and GetUri
|
|
|
|
// (which is overridded for lazy construction for some containers).
|
2008-01-09 03:54:37 +00:00
|
|
|
#define NS_IMPLEMENT_SIMPLE_RESULTNODE_NO_GETITEMMID \
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_IMETHOD GetTitle(nsACString& aTitle) \
|
|
|
|
{ aTitle = mTitle; return NS_OK; } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetAccessCount(uint32_t* aAccessCount) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ *aAccessCount = mAccessCount; return NS_OK; } \
|
|
|
|
NS_IMETHOD GetTime(PRTime* aTime) \
|
|
|
|
{ *aTime = mTime; return NS_OK; } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetIndentLevel(int32_t* aIndentLevel) \
|
2006-07-18 17:14:21 +00:00
|
|
|
{ *aIndentLevel = mIndentLevel; return NS_OK; } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetBookmarkIndex(int32_t* aIndex) \
|
2007-02-26 00:54:36 +00:00
|
|
|
{ *aIndex = mBookmarkIndex; return NS_OK; } \
|
2007-05-19 00:40:55 +00:00
|
|
|
NS_IMETHOD GetDateAdded(PRTime* aDateAdded) \
|
|
|
|
{ *aDateAdded = mDateAdded; return NS_OK; } \
|
|
|
|
NS_IMETHOD GetLastModified(PRTime* aLastModified) \
|
|
|
|
{ *aLastModified = mLastModified; return NS_OK; }
|
|
|
|
|
2008-01-09 03:54:37 +00:00
|
|
|
#define NS_IMPLEMENT_SIMPLE_RESULTNODE \
|
|
|
|
NS_IMPLEMENT_SIMPLE_RESULTNODE_NO_GETITEMMID \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetItemId(int64_t* aId) \
|
2008-01-09 03:54:37 +00:00
|
|
|
{ *aId = mItemId; return NS_OK; }
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// This is used by the base classes instead of
|
|
|
|
// NS_FORWARD_NSINAVHISTORYRESULTNODE(nsNavHistoryResultNode) because they
|
2006-07-18 17:11:38 +00:00
|
|
|
// need to redefine GetType and GetUri rather than forwarding them. This
|
|
|
|
// implements all the simple getters instead of forwarding because they are so
|
|
|
|
// short and we can save a virtual function call.
|
|
|
|
//
|
|
|
|
// (GetUri is redefined only by QueryResultNode and FolderResultNode because
|
|
|
|
// the queries might not necessarily be parsed. The rest just return the node's
|
|
|
|
// buffer.)
|
2008-01-09 03:54:37 +00:00
|
|
|
#define NS_FORWARD_COMMON_RESULTNODE_TO_BASE_NO_GETITEMMID \
|
|
|
|
NS_IMPLEMENT_SIMPLE_RESULTNODE_NO_GETITEMMID \
|
2009-10-01 16:53:26 +00:00
|
|
|
NS_IMETHOD GetIcon(nsACString& aIcon) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return nsNavHistoryResultNode::GetIcon(aIcon); } \
|
|
|
|
NS_IMETHOD GetParent(nsINavHistoryContainerResultNode** aParent) \
|
|
|
|
{ return nsNavHistoryResultNode::GetParent(aParent); } \
|
2007-10-25 02:02:28 +00:00
|
|
|
NS_IMETHOD GetParentResult(nsINavHistoryResult** aResult) \
|
|
|
|
{ return nsNavHistoryResultNode::GetParentResult(aResult); } \
|
2007-12-20 19:07:58 +00:00
|
|
|
NS_IMETHOD GetTags(nsAString& aTags) \
|
2009-10-01 16:53:26 +00:00
|
|
|
{ return nsNavHistoryResultNode::GetTags(aTags); }
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2008-01-09 03:54:37 +00:00
|
|
|
#define NS_FORWARD_COMMON_RESULTNODE_TO_BASE \
|
|
|
|
NS_FORWARD_COMMON_RESULTNODE_TO_BASE_NO_GETITEMMID \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetItemId(int64_t* aId) \
|
2008-01-09 03:54:37 +00:00
|
|
|
{ *aId = mItemId; return NS_OK; }
|
|
|
|
|
2006-07-18 17:06:47 +00:00
|
|
|
class nsNavHistoryResultNode : public nsINavHistoryResultNode
|
|
|
|
{
|
|
|
|
public:
|
2006-07-18 17:11:38 +00:00
|
|
|
nsNavHistoryResultNode(const nsACString& aURI, const nsACString& aTitle,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aAccessCount, PRTime aTime,
|
2006-07-18 17:11:38 +00:00
|
|
|
const nsACString& aIconURI);
|
2006-07-18 17:12:48 +00:00
|
|
|
virtual ~nsNavHistoryResultNode() {}
|
2006-07-18 17:06:47 +00:00
|
|
|
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYRESULTNODE_IID)
|
|
|
|
|
2007-10-19 06:26:34 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsNavHistoryResultNode)
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_IMPLEMENT_SIMPLE_RESULTNODE
|
2009-10-01 16:53:26 +00:00
|
|
|
NS_IMETHOD GetIcon(nsACString& aIcon);
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_IMETHOD GetParent(nsINavHistoryContainerResultNode** aParent);
|
2007-10-25 02:02:28 +00:00
|
|
|
NS_IMETHOD GetParentResult(nsINavHistoryResult** aResult);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type)
|
2006-07-18 17:11:38 +00:00
|
|
|
{ *type = nsNavHistoryResultNode::RESULT_TYPE_URI; return NS_OK; }
|
|
|
|
NS_IMETHOD GetUri(nsACString& aURI)
|
|
|
|
{ aURI = mURI; return NS_OK; }
|
2007-12-20 19:07:58 +00:00
|
|
|
NS_IMETHOD GetTags(nsAString& aTags);
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
virtual void OnRemoving();
|
|
|
|
|
2007-06-18 23:55:58 +00:00
|
|
|
// Called from result's onItemChanged, see also bookmark observer declaration in
|
|
|
|
// nsNavHistoryFolderResultNode
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD OnItemChanged(int64_t aItemId,
|
2007-06-18 23:55:58 +00:00
|
|
|
const nsACString &aProperty,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsAnnotationProperty,
|
2009-10-01 16:53:26 +00:00
|
|
|
const nsACString &aValue,
|
|
|
|
PRTime aNewLastModified,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t aItemType,
|
|
|
|
int64_t aParentId,
|
2011-05-13 19:24:22 +00:00
|
|
|
const nsACString& aGUID,
|
|
|
|
const nsACString& aParentGUID);
|
2007-06-18 23:55:58 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
public:
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
nsNavHistoryResult* GetResult();
|
2006-07-18 17:09:28 +00:00
|
|
|
nsNavHistoryQueryOptions* GetGeneratingOptions();
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
// These functions test the type. We don't use a virtual function since that
|
|
|
|
// would take a vtable slot for every one of (potentially very many) nodes.
|
|
|
|
// Note that GetType() already has a vtable slot because its on the iface.
|
2012-08-22 15:56:38 +00:00
|
|
|
bool IsTypeContainer(uint32_t type) {
|
2011-11-29 01:22:51 +00:00
|
|
|
return (type == nsINavHistoryResultNode::RESULT_TYPE_QUERY ||
|
2006-11-21 23:02:16 +00:00
|
|
|
type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER ||
|
2008-02-27 04:48:51 +00:00
|
|
|
type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER_SHORTCUT);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsContainer() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:09:05 +00:00
|
|
|
GetType(&type);
|
|
|
|
return IsTypeContainer(type);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
static bool IsTypeURI(uint32_t type) {
|
2006-07-18 17:09:05 +00:00
|
|
|
return (type == nsINavHistoryResultNode::RESULT_TYPE_URI ||
|
2013-01-29 22:30:13 +00:00
|
|
|
type == nsINavHistoryResultNode::RESULT_TYPE_VISIT);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsURI() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:09:05 +00:00
|
|
|
GetType(&type);
|
|
|
|
return IsTypeURI(type);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
static bool IsTypeVisit(uint32_t type) {
|
2013-01-29 22:30:13 +00:00
|
|
|
return type == nsINavHistoryResultNode::RESULT_TYPE_VISIT;
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsVisit() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:09:05 +00:00
|
|
|
GetType(&type);
|
|
|
|
return IsTypeVisit(type);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
static bool IsTypeFolder(uint32_t type) {
|
2008-01-25 19:01:18 +00:00
|
|
|
return (type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER ||
|
|
|
|
type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER_SHORTCUT);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsFolder() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:09:05 +00:00
|
|
|
GetType(&type);
|
|
|
|
return IsTypeFolder(type);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
static bool IsTypeQuery(uint32_t type) {
|
2006-07-18 17:09:05 +00:00
|
|
|
return (type == nsINavHistoryResultNode::RESULT_TYPE_QUERY);
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsQuery() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:09:05 +00:00
|
|
|
GetType(&type);
|
|
|
|
return IsTypeQuery(type);
|
2006-07-18 17:06:47 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsSeparator() {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type;
|
2006-07-18 17:12:25 +00:00
|
|
|
GetType(&type);
|
|
|
|
return (type == nsINavHistoryResultNode::RESULT_TYPE_SEPARATOR);
|
|
|
|
}
|
2006-07-18 17:09:05 +00:00
|
|
|
nsNavHistoryContainerResultNode* GetAsContainer() {
|
|
|
|
NS_ASSERTION(IsContainer(), "Not a container");
|
2007-07-08 07:08:04 +00:00
|
|
|
return reinterpret_cast<nsNavHistoryContainerResultNode*>(this);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
|
|
|
nsNavHistoryVisitResultNode* GetAsVisit() {
|
|
|
|
NS_ASSERTION(IsVisit(), "Not a visit");
|
2007-07-08 07:08:04 +00:00
|
|
|
return reinterpret_cast<nsNavHistoryVisitResultNode*>(this);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
|
|
|
nsNavHistoryFolderResultNode* GetAsFolder() {
|
|
|
|
NS_ASSERTION(IsFolder(), "Not a folder");
|
2007-07-08 07:08:04 +00:00
|
|
|
return reinterpret_cast<nsNavHistoryFolderResultNode*>(this);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
|
|
|
nsNavHistoryQueryResultNode* GetAsQuery() {
|
|
|
|
NS_ASSERTION(IsQuery(), "Not a query");
|
2007-07-08 07:08:04 +00:00
|
|
|
return reinterpret_cast<nsNavHistoryQueryResultNode*>(this);
|
2006-07-18 17:09:05 +00:00
|
|
|
}
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2008-05-27 15:48:31 +00:00
|
|
|
nsRefPtr<nsNavHistoryContainerResultNode> mParent;
|
2006-07-18 17:11:38 +00:00
|
|
|
nsCString mURI; // not necessarily valid for containers, call GetUri
|
2006-07-18 17:09:05 +00:00
|
|
|
nsCString mTitle;
|
2007-12-20 19:07:58 +00:00
|
|
|
nsString mTags;
|
2011-04-29 16:12:20 +00:00
|
|
|
bool mAreTagsSorted;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mAccessCount;
|
|
|
|
int64_t mTime;
|
2006-07-18 17:09:05 +00:00
|
|
|
nsCString mFaviconURI;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mBookmarkIndex;
|
|
|
|
int64_t mItemId;
|
|
|
|
int64_t mFolderId;
|
2007-05-19 00:40:55 +00:00
|
|
|
PRTime mDateAdded;
|
|
|
|
PRTime mLastModified;
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// The indent level of this node. The root node will have a value of -1. The
|
|
|
|
// root's children will have a value of 0, and so on.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mIndentLevel;
|
2011-04-13 20:15:41 +00:00
|
|
|
|
2012-12-20 22:45:00 +00:00
|
|
|
// Frecency of the page. Valid only for URI nodes.
|
|
|
|
int32_t mFrecency;
|
|
|
|
|
|
|
|
// Hidden status of the page. Valid only for URI nodes.
|
|
|
|
bool mHidden;
|
2013-01-07 17:54:38 +00:00
|
|
|
|
|
|
|
// Transition type used when this node represents a single visit.
|
2013-01-29 23:25:01 +00:00
|
|
|
uint32_t mTransitionType;
|
2006-07-18 17:09:05 +00:00
|
|
|
};
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:13:11 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryResultNode, NS_NAVHISTORYRESULTNODE_IID)
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// nsNavHistoryVisitResultNode
|
|
|
|
|
|
|
|
#define NS_IMPLEMENT_VISITRESULT \
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_IMETHOD GetUri(nsACString& aURI) { aURI = mURI; return NS_OK; } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetSessionId(int64_t* aSessionId) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ *aSessionId = mSessionId; return NS_OK; }
|
|
|
|
|
2006-07-18 17:11:38 +00:00
|
|
|
class nsNavHistoryVisitResultNode : public nsNavHistoryResultNode,
|
2006-07-18 17:09:05 +00:00
|
|
|
public nsINavHistoryVisitResultNode
|
|
|
|
{
|
|
|
|
public:
|
2006-07-18 17:11:38 +00:00
|
|
|
nsNavHistoryVisitResultNode(const nsACString& aURI, const nsACString& aTitle,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aAccessCount, PRTime aTime,
|
|
|
|
const nsACString& aIconURI, int64_t aSession);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_FORWARD_COMMON_RESULTNODE_TO_BASE
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type)
|
2006-07-18 17:09:51 +00:00
|
|
|
{ *type = nsNavHistoryResultNode::RESULT_TYPE_VISIT; return NS_OK; }
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_IMPLEMENT_VISITRESULT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t mSessionId;
|
2006-07-18 17:09:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// nsNavHistoryContainerResultNode
|
|
|
|
//
|
|
|
|
// This is the base class for all nodes that can have children. It is
|
|
|
|
// overridden for nodes that are dynamically populated such as queries and
|
|
|
|
// folders. It is used directly for simple containers such as host groups
|
|
|
|
// in history views.
|
|
|
|
|
|
|
|
// derived classes each provide their own implementation of has children and
|
|
|
|
// forward the rest to us using this macro
|
2006-07-18 17:13:34 +00:00
|
|
|
#define NS_FORWARD_CONTAINERNODE_EXCEPT_HASCHILDREN_AND_READONLY \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetState(uint16_t* _state) \
|
2010-04-09 18:30:29 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetState(_state); } \
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetContainerOpen(bool *aContainerOpen) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetContainerOpen(aContainerOpen); } \
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD SetContainerOpen(bool aContainerOpen) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::SetContainerOpen(aContainerOpen); } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetChildCount(uint32_t *aChildCount) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetChildCount(aChildCount); } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetChild(uint32_t index, nsINavHistoryResultNode **_retval) \
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetChild(index, _retval); } \
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetChildIndex(nsINavHistoryResultNode* aNode, uint32_t* _retval) \
|
2010-02-25 18:30:09 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetChildIndex(aNode, _retval); } \
|
|
|
|
NS_IMETHOD FindNodeByDetails(const nsACString& aURIString, PRTime aTime, \
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t aItemId, bool aRecursive, \
|
2010-02-25 18:30:09 +00:00
|
|
|
nsINavHistoryResultNode** _retval) \
|
|
|
|
{ return nsNavHistoryContainerResultNode::FindNodeByDetails(aURIString, aTime, aItemId, \
|
2011-11-29 01:22:51 +00:00
|
|
|
aRecursive, _retval); }
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2006-07-18 17:14:21 +00:00
|
|
|
#define NS_NAVHISTORYCONTAINERRESULTNODE_IID \
|
|
|
|
{ 0x6e3bf8d3, 0x22aa, 0x4065, { 0x86, 0xbc, 0x37, 0x46, 0xb5, 0xb3, 0x2c, 0xe8 } }
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
class nsNavHistoryContainerResultNode : public nsNavHistoryResultNode,
|
|
|
|
public nsINavHistoryContainerResultNode
|
|
|
|
{
|
|
|
|
public:
|
2006-07-18 17:11:38 +00:00
|
|
|
nsNavHistoryContainerResultNode(
|
|
|
|
const nsACString& aURI, const nsACString& aTitle,
|
2012-08-22 15:56:38 +00:00
|
|
|
const nsACString& aIconURI, uint32_t aContainerType,
|
2011-11-29 01:22:51 +00:00
|
|
|
bool aReadOnly, nsNavHistoryQueryOptions* aOptions);
|
2008-02-27 04:48:51 +00:00
|
|
|
nsNavHistoryContainerResultNode(
|
|
|
|
const nsACString& aURI, const nsACString& aTitle,
|
|
|
|
PRTime aTime,
|
2012-08-22 15:56:38 +00:00
|
|
|
const nsACString& aIconURI, uint32_t aContainerType,
|
2011-11-29 01:22:51 +00:00
|
|
|
bool aReadOnly, nsNavHistoryQueryOptions* aOptions);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2010-11-12 21:14:47 +00:00
|
|
|
virtual nsresult Refresh();
|
2009-04-18 12:12:01 +00:00
|
|
|
virtual ~nsNavHistoryContainerResultNode();
|
|
|
|
|
2006-07-18 17:14:21 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYCONTAINERRESULTNODE_IID)
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-10-19 06:26:34 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsNavHistoryContainerResultNode, nsNavHistoryResultNode)
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_FORWARD_COMMON_RESULTNODE_TO_BASE
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type)
|
2006-07-18 17:09:05 +00:00
|
|
|
{ *type = mContainerType; return NS_OK; }
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_IMETHOD GetUri(nsACString& aURI)
|
|
|
|
{ aURI = mURI; return NS_OK; }
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_DECL_NSINAVHISTORYCONTAINERRESULTNODE
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void OnRemoving();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AreChildrenVisible();
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// Overridded by descendents to populate.
|
2006-07-18 17:09:05 +00:00
|
|
|
virtual nsresult OpenContainer();
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult CloseContainer(bool aSuppressNotifications = false);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2010-04-09 18:30:29 +00:00
|
|
|
virtual nsresult OpenContainerAsync();
|
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// This points to the result that owns this container. All containers have
|
2006-07-18 17:09:05 +00:00
|
|
|
// their result pointer set so we can quickly get to the result without having
|
|
|
|
// to walk the tree. Yet, this also saves us from storing a million pointers
|
|
|
|
// for every leaf node to the result.
|
2007-10-19 06:26:34 +00:00
|
|
|
nsRefPtr<nsNavHistoryResult> mResult;
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// For example, RESULT_TYPE_QUERY. Query and Folder results override GetType
|
2006-07-18 17:09:28 +00:00
|
|
|
// so this is not used, but is still kept in sync.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mContainerType;
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// When there are children, this stores the open state in the tree
|
|
|
|
// this is set to the default in the constructor.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mExpanded;
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// Filled in by the result type generator in nsNavHistory.
|
2006-07-18 17:09:05 +00:00
|
|
|
nsCOMArray<nsNavHistoryResultNode> mChildren;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mChildrenReadOnly;
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2007-08-02 20:19:44 +00:00
|
|
|
nsCOMPtr<nsNavHistoryQueryOptions> mOptions;
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
void FillStats();
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult ReverseUpdateStats(int32_t aAccessCountChange);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2010-03-12 11:14:47 +00:00
|
|
|
// Sorting methods.
|
2006-07-18 17:09:05 +00:00
|
|
|
typedef nsCOMArray<nsNavHistoryResultNode>::nsCOMArrayComparatorFunc SortComparator;
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint16_t GetSortType();
|
2007-04-22 22:20:25 +00:00
|
|
|
virtual void GetSortingAnnotation(nsACString& aSortingAnnotation);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static SortComparator GetSortingComparator(uint16_t aSortType);
|
2007-04-22 22:20:25 +00:00
|
|
|
virtual void RecursiveSort(const char* aData,
|
2006-07-18 17:12:25 +00:00
|
|
|
SortComparator aComparator);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t FindInsertionPoint(nsNavHistoryResultNode* aNode, SortComparator aComparator,
|
2011-09-29 06:19:26 +00:00
|
|
|
const char* aData, bool* aItemExists);
|
2012-08-22 15:56:38 +00:00
|
|
|
bool DoesChildNeedResorting(uint32_t aIndex, SortComparator aComparator,
|
2007-04-22 22:20:25 +00:00
|
|
|
const char* aData);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_StringLess(const nsAString& a, const nsAString& b);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_Bookmark(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_TitleLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_TitleGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_DateLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_DateGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_URILess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_URIGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_VisitCountLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_VisitCountGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_KeywordLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_KeywordGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_AnnotationLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_AnnotationGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_DateAddedLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_DateAddedGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_LastModifiedLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_LastModifiedGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_TagsLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_TagsGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_FrecencyLess(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t SortComparison_FrecencyGreater(nsNavHistoryResultNode* a,
|
2011-04-13 20:15:41 +00:00
|
|
|
nsNavHistoryResultNode* b,
|
|
|
|
void* closure);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
// finding children: THESE DO NOT ADDREF
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNavHistoryResultNode* FindChildURI(nsIURI* aURI, uint32_t* aNodeIndex)
|
2006-07-18 17:09:05 +00:00
|
|
|
{
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString spec;
|
2006-07-18 17:09:05 +00:00
|
|
|
if (NS_FAILED(aURI->GetSpec(spec)))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-07-18 17:09:05 +00:00
|
|
|
return FindChildURI(spec, aNodeIndex);
|
|
|
|
}
|
2006-07-18 17:11:38 +00:00
|
|
|
nsNavHistoryResultNode* FindChildURI(const nsACString& aSpec,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t* aNodeIndex);
|
2006-07-18 17:09:05 +00:00
|
|
|
nsNavHistoryContainerResultNode* FindChildContainerByName(const nsACString& aTitle,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t* aNodeIndex);
|
2006-07-18 17:09:05 +00:00
|
|
|
// returns the index of the given node, -1 if not found
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t FindChild(nsNavHistoryResultNode* aNode)
|
2006-07-18 17:09:05 +00:00
|
|
|
{ return mChildren.IndexOf(aNode); }
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult InsertChildAt(nsNavHistoryResultNode* aNode, int32_t aIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsTemporary = false);
|
2006-07-18 17:09:05 +00:00
|
|
|
nsresult InsertSortedChild(nsNavHistoryResultNode* aNode,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsTemporary = false,
|
|
|
|
bool aIgnoreDuplicates = false);
|
2012-08-22 15:56:38 +00:00
|
|
|
bool EnsureItemPosition(uint32_t aIndex);
|
2006-07-18 17:09:05 +00:00
|
|
|
void MergeResults(nsCOMArray<nsNavHistoryResultNode>* aNodes);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult ReplaceChildURIAt(uint32_t aIndex, nsNavHistoryResultNode* aNode);
|
|
|
|
nsresult RemoveChildAt(int32_t aIndex, bool aIsTemporary = false);
|
2006-07-18 17:09:28 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void RecursiveFindURIs(bool aOnlyOne,
|
2006-07-18 17:11:15 +00:00
|
|
|
nsNavHistoryContainerResultNode* aContainer,
|
|
|
|
const nsCString& aSpec,
|
|
|
|
nsCOMArray<nsNavHistoryResultNode>* aMatches);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult UpdateURIs(bool aRecursive, bool aOnlyOne, bool aUpdateSort,
|
2010-03-12 11:14:47 +00:00
|
|
|
const nsCString& aSpec,
|
|
|
|
nsresult (*aCallback)(nsNavHistoryResultNode*,void*, nsNavHistoryResult*),
|
|
|
|
void* aClosure);
|
2006-07-18 17:11:15 +00:00
|
|
|
nsresult ChangeTitles(nsIURI* aURI, const nsACString& aNewTitle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRecursive, bool aOnlyOne);
|
2010-04-09 18:30:29 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum AsyncCanceledState {
|
|
|
|
NOT_CANCELED, CANCELED, CANCELED_RESTART_NEEDED
|
|
|
|
};
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void CancelAsyncOpen(bool aRestart);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult NotifyOnStateChange(uint16_t aOldState);
|
2010-04-09 18:30:29 +00:00
|
|
|
|
|
|
|
nsCOMPtr<mozIStoragePendingStatement> mAsyncPendingStmt;
|
2011-07-27 06:43:37 +00:00
|
|
|
AsyncCanceledState mAsyncCanceledState;
|
2006-07-18 17:06:47 +00:00
|
|
|
};
|
|
|
|
|
2006-11-14 23:12:10 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryContainerResultNode,
|
|
|
|
NS_NAVHISTORYCONTAINERRESULTNODE_IID)
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
// nsNavHistoryQueryResultNode
|
2006-07-18 17:06:47 +00:00
|
|
|
//
|
2006-07-18 17:09:05 +00:00
|
|
|
// Overridden container type for complex queries over history and/or
|
|
|
|
// bookmarks. This keeps itself in sync by listening to history and
|
|
|
|
// bookmark notifications.
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
class nsNavHistoryQueryResultNode : public nsNavHistoryContainerResultNode,
|
|
|
|
public nsINavHistoryQueryResultNode
|
2006-07-18 17:06:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-04-28 17:59:39 +00:00
|
|
|
nsNavHistoryQueryResultNode(const nsACString& aTitle,
|
|
|
|
const nsACString& aIconURI,
|
|
|
|
const nsACString& aQueryURI);
|
2006-07-18 17:09:28 +00:00
|
|
|
nsNavHistoryQueryResultNode(const nsACString& aTitle,
|
|
|
|
const nsACString& aIconURI,
|
|
|
|
const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
2008-02-27 04:48:51 +00:00
|
|
|
nsNavHistoryQueryOptions* aOptions);
|
|
|
|
nsNavHistoryQueryResultNode(const nsACString& aTitle,
|
|
|
|
const nsACString& aIconURI,
|
|
|
|
PRTime aTime,
|
|
|
|
const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
2006-07-18 17:09:05 +00:00
|
|
|
nsNavHistoryQueryOptions* aOptions);
|
|
|
|
|
2009-04-18 12:12:01 +00:00
|
|
|
virtual ~nsNavHistoryQueryResultNode();
|
|
|
|
|
2007-05-23 01:23:24 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_FORWARD_COMMON_RESULTNODE_TO_BASE
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type)
|
2006-07-18 17:09:51 +00:00
|
|
|
{ *type = nsNavHistoryResultNode::RESULT_TYPE_QUERY; return NS_OK; }
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_IMETHOD GetUri(nsACString& aURI); // does special lazy creation
|
2006-07-18 17:13:34 +00:00
|
|
|
NS_FORWARD_CONTAINERNODE_EXCEPT_HASCHILDREN_AND_READONLY
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetHasChildren(bool* aHasChildren);
|
|
|
|
NS_IMETHOD GetChildrenReadOnly(bool *aChildrenReadOnly)
|
2006-07-18 17:13:34 +00:00
|
|
|
{ return nsNavHistoryContainerResultNode::GetChildrenReadOnly(aChildrenReadOnly); }
|
2007-05-23 01:23:24 +00:00
|
|
|
NS_DECL_NSINAVHISTORYQUERYRESULTNODE
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool CanExpand();
|
|
|
|
bool IsContainersQuery();
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
virtual nsresult OpenContainer();
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2012-12-20 22:45:00 +00:00
|
|
|
NS_DECL_BOOKMARK_HISTORY_OBSERVER_INTERNAL
|
2006-07-18 17:09:05 +00:00
|
|
|
virtual void OnRemoving();
|
|
|
|
|
|
|
|
public:
|
2006-07-18 17:11:38 +00:00
|
|
|
// this constructs lazily mURI from mQueries and mOptions, call
|
|
|
|
// VerifyQueriesSerialized either this or mQueries/mOptions should be valid
|
2006-07-18 17:09:05 +00:00
|
|
|
nsresult VerifyQueriesSerialized();
|
|
|
|
|
2006-07-18 17:11:38 +00:00
|
|
|
// these may be constructed lazily from mURI, call VerifyQueriesParsed
|
|
|
|
// either this or mURI should be valid
|
2006-07-18 17:09:28 +00:00
|
|
|
nsCOMArray<nsNavHistoryQuery> mQueries;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mLiveUpdate; // one of QUERYUPDATE_* in nsNavHistory.h
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mHasSearchTerms;
|
2006-07-18 17:09:05 +00:00
|
|
|
nsresult VerifyQueriesParsed();
|
|
|
|
|
2008-05-23 16:22:54 +00:00
|
|
|
// safe options getter, ensures queries are parsed
|
|
|
|
nsNavHistoryQueryOptions* Options();
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// this indicates whether the query contents are valid, they don't go away
|
|
|
|
// after the container is closed until a notification comes in
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mContentsValid;
|
2006-07-18 17:09:05 +00:00
|
|
|
|
|
|
|
nsresult FillChildren();
|
2011-09-29 06:19:26 +00:00
|
|
|
void ClearChildren(bool unregister);
|
2006-07-18 17:09:05 +00:00
|
|
|
nsresult Refresh();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint16_t GetSortType();
|
2007-04-22 22:20:25 +00:00
|
|
|
virtual void GetSortingAnnotation(nsACString& aSortingAnnotation);
|
2009-01-14 22:38:30 +00:00
|
|
|
virtual void RecursiveSort(const char* aData,
|
|
|
|
SortComparator aComparator);
|
2011-04-29 16:12:20 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mRemovingURI;
|
|
|
|
nsresult NotifyIfTagsChanged(nsIURI* aURI);
|
2011-08-31 11:46:22 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mBatchChanges;
|
2013-01-07 17:54:38 +00:00
|
|
|
|
|
|
|
// Tracks transition type filters shared by all mQueries.
|
|
|
|
nsTArray<uint32_t> mTransitions;
|
2006-07-18 17:09:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// nsNavHistoryFolderResultNode
|
|
|
|
//
|
|
|
|
// Overridden container type for bookmark folders. It will keep the contents
|
|
|
|
// of the folder in sync with the bookmark service.
|
|
|
|
|
|
|
|
class nsNavHistoryFolderResultNode : public nsNavHistoryContainerResultNode,
|
2010-04-09 18:30:29 +00:00
|
|
|
public nsINavHistoryQueryResultNode,
|
|
|
|
public mozilla::places::AsyncStatementCallback
|
2006-07-18 17:09:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-07-18 17:09:28 +00:00
|
|
|
nsNavHistoryFolderResultNode(const nsACString& aTitle,
|
|
|
|
nsNavHistoryQueryOptions* options,
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t aFolderId);
|
2006-07-18 17:09:05 +00:00
|
|
|
|
2008-03-28 18:32:23 +00:00
|
|
|
virtual ~nsNavHistoryFolderResultNode();
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-01-09 03:54:37 +00:00
|
|
|
NS_FORWARD_COMMON_RESULTNODE_TO_BASE_NO_GETITEMMID
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type) {
|
2008-01-25 19:01:18 +00:00
|
|
|
if (mQueryItemId != -1) {
|
|
|
|
*type = nsNavHistoryResultNode::RESULT_TYPE_FOLDER_SHORTCUT;
|
|
|
|
} else {
|
|
|
|
*type = nsNavHistoryResultNode::RESULT_TYPE_FOLDER;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-07-18 17:11:38 +00:00
|
|
|
NS_IMETHOD GetUri(nsACString& aURI);
|
2006-07-18 17:13:34 +00:00
|
|
|
NS_FORWARD_CONTAINERNODE_EXCEPT_HASCHILDREN_AND_READONLY
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetHasChildren(bool* aHasChildren);
|
|
|
|
NS_IMETHOD GetChildrenReadOnly(bool *aChildrenReadOnly);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetItemId(int64_t *aItemId);
|
2006-07-18 17:09:05 +00:00
|
|
|
NS_DECL_NSINAVHISTORYQUERYRESULTNODE
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
virtual nsresult OpenContainer();
|
|
|
|
|
2010-04-09 18:30:29 +00:00
|
|
|
virtual nsresult OpenContainerAsync();
|
|
|
|
NS_DECL_ASYNCSTATEMENTCALLBACK
|
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
// This object implements a bookmark observer interface without deriving from
|
|
|
|
// the bookmark observers. This is called from the result's actual observer
|
|
|
|
// and it knows all observers are FolderResultNodes
|
|
|
|
NS_DECL_NSINAVBOOKMARKOBSERVER
|
|
|
|
|
|
|
|
virtual void OnRemoving();
|
|
|
|
|
|
|
|
// this indicates whether the folder contents are valid, they don't go away
|
|
|
|
// after the container is closed until a notification comes in
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mContentsValid;
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2008-01-09 03:54:37 +00:00
|
|
|
// If the node is generated from a place:folder=X query, this is the query's
|
|
|
|
// itemId.
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t mQueryItemId;
|
2008-01-09 03:54:37 +00:00
|
|
|
|
2006-07-18 17:09:05 +00:00
|
|
|
nsresult FillChildren();
|
2011-09-29 06:19:26 +00:00
|
|
|
void ClearChildren(bool aUnregister);
|
2006-07-18 17:13:57 +00:00
|
|
|
nsresult Refresh();
|
2006-07-18 17:06:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool StartIncrementalUpdate();
|
2012-08-22 15:56:38 +00:00
|
|
|
void ReindexRange(int32_t aStartIndex, int32_t aEndIndex, int32_t aDelta);
|
2007-02-26 00:54:36 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNavHistoryResultNode* FindChildById(int64_t aItemId,
|
|
|
|
uint32_t* aNodeIndex);
|
2008-03-28 18:32:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-04-09 18:30:29 +00:00
|
|
|
nsresult OnChildrenFilled();
|
|
|
|
void EnsureRegisteredAsFolderObserver();
|
|
|
|
nsresult FillChildrenAsync();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsRegisteredFolderObserver;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mAsyncBookmarkIndex;
|
2006-07-18 17:06:47 +00:00
|
|
|
};
|
|
|
|
|
2006-07-18 17:12:25 +00:00
|
|
|
// nsNavHistorySeparatorResultNode
|
|
|
|
//
|
|
|
|
// Separator result nodes do not hold any data.
|
|
|
|
class nsNavHistorySeparatorResultNode : public nsNavHistoryResultNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsNavHistorySeparatorResultNode();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetType(uint32_t* type)
|
2006-07-18 17:12:25 +00:00
|
|
|
{ *type = nsNavHistoryResultNode::RESULT_TYPE_SEPARATOR; return NS_OK; }
|
|
|
|
};
|
2006-07-18 17:06:47 +00:00
|
|
|
|
|
|
|
#endif // nsNavHistoryResult_h_
|