Bug 700296 (Places) - Remove dynamic containers implementation from Places.

r=dietrich
This commit is contained in:
Marco Bonardo 2011-11-29 02:22:51 +01:00
Родитель 2074fdb7a7
Коммит ed95219739
16 изменённых файлов: 80 добавлений и 867 удалений

Просмотреть файл

@ -447,7 +447,6 @@ PlacesController.prototype = {
* "tagChild" node is a child of a tag
* "folder" node is a folder
* "query" node is a query
* "dynamiccontainer" node is a dynamic container
* "separator" node is a separator line
* "host" node is a host
*
@ -490,9 +489,6 @@ PlacesController.prototype = {
}
}
break;
case Ci.nsINavHistoryResultNode.RESULT_TYPE_DYNAMIC_CONTAINER:
nodeData["dynamiccontainer"] = true;
break;
case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER:
case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT:
nodeData["folder"] = true;

Просмотреть файл

@ -632,6 +632,12 @@ Database::InitSchema(bool* aDatabaseMigrated)
// Firefox 8 uses schema version 12.
if (currentSchemaVersion < 13) {
rv = MigrateV13Up();
NS_ENSURE_SUCCESS(rv, rv);
}
// Firefox 11 uses schema version 13.
// Schema Upgrades must add migration code here.
}
}
@ -1257,6 +1263,30 @@ Database::MigrateV11Up()
return NS_OK;
}
nsresult
Database::MigrateV13Up()
{
MOZ_ASSERT(NS_IsMainThread());
// Dynamic containers are no more supported.
// For existing profiles, we may not have a moz_bookmarks.guid column
nsCOMPtr<mozIStorageAsyncStatement> deleteDynContainersStmt;
nsresult rv = mMainConn->CreateAsyncStatement(NS_LITERAL_CSTRING(
"DELETE FROM moz_bookmarks WHERE type = :item_type"),
getter_AddRefs(deleteDynContainersStmt));
rv = deleteDynContainersStmt->BindInt32ByName(
NS_LITERAL_CSTRING("item_type"),
nsINavBookmarksService::TYPE_DYNAMIC_CONTAINER
);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<mozIStoragePendingStatement> ps;
rv = deleteDynContainersStmt->ExecuteAsync(nsnull, getter_AddRefs(ps));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
void
Database::Shutdown()
{

Просмотреть файл

@ -47,7 +47,7 @@
// This is the schema version, update it at any schema change and add a
// corresponding migrateVxx method below.
#define DATABASE_SCHEMA_VERSION 12
#define DATABASE_SCHEMA_VERSION 13
// Fired after Places inited.
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
@ -289,6 +289,7 @@ protected:
nsresult MigrateV10Up();
nsresult MigrateV11Up();
nsresult CheckAndUpdateGUIDs();
nsresult MigrateV13Up();
private:
~Database();

Просмотреть файл

@ -487,7 +487,7 @@ let PlacesDBUtils = {
cleanupStatements.push(fixInvalidKeywords);
// D.6 fix wrong item types
// Folders, separators and dynamic containers should not have an fk.
// Folders and separators should not have an fk.
// If they have a valid fk convert them to bookmarks. Later in D.9 we
// will move eventual children to unsorted bookmarks.
let fixBookmarksAsFolders = DBConn.createAsyncStatement(
@ -495,13 +495,12 @@ let PlacesDBUtils = {
"SELECT folder_id FROM moz_bookmarks_roots " + // skip roots
") AND id IN ( " +
"SELECT id FROM moz_bookmarks b " +
"WHERE type IN (:folder_type, :separator_type, :dynamic_type) " +
"WHERE type IN (:folder_type, :separator_type) " +
"AND fk NOTNULL " +
")");
fixBookmarksAsFolders.params["bookmark_type"] = PlacesUtils.bookmarks.TYPE_BOOKMARK;
fixBookmarksAsFolders.params["folder_type"] = PlacesUtils.bookmarks.TYPE_FOLDER;
fixBookmarksAsFolders.params["separator_type"] = PlacesUtils.bookmarks.TYPE_SEPARATOR;
fixBookmarksAsFolders.params["dynamic_type"] = PlacesUtils.bookmarks.TYPE_DYNAMIC_CONTAINER;
cleanupStatements.push(fixBookmarksAsFolders);
// D.7 fix wrong item types
@ -519,23 +518,8 @@ let PlacesDBUtils = {
fixFoldersAsBookmarks.params["folder_type"] = PlacesUtils.bookmarks.TYPE_FOLDER;
cleanupStatements.push(fixFoldersAsBookmarks);
// D.8 fix wrong item types
// Dynamic containers should have a folder_type, if they don't have any
// convert them to folders.
let fixFoldersAsDynamic = DBConn.createAsyncStatement(
"UPDATE moz_bookmarks SET type = :folder_type WHERE id NOT IN ( " +
"SELECT folder_id FROM moz_bookmarks_roots " + // skip roots
") AND id IN ( " +
"SELECT id FROM moz_bookmarks b " +
"WHERE type = :dynamic_type " +
"AND folder_type IS NULL " +
")");
fixFoldersAsDynamic.params["dynamic_type"] = PlacesUtils.bookmarks.TYPE_DYNAMIC_CONTAINER;
fixFoldersAsDynamic.params["folder_type"] = PlacesUtils.bookmarks.TYPE_FOLDER;
cleanupStatements.push(fixFoldersAsDynamic);
// D.9 fix wrong parents
// Items cannot have dynamic containers, separators or other bookmarks
// Items cannot have separators or other bookmarks
// as parent, if they have bad parent move them to unsorted bookmarks.
let fixInvalidParents = DBConn.createAsyncStatement(
"UPDATE moz_bookmarks SET parent = :unsorted_folder WHERE id NOT IN ( " +
@ -544,13 +528,12 @@ let PlacesDBUtils = {
"SELECT id FROM moz_bookmarks b " +
"WHERE EXISTS " +
"(SELECT id FROM moz_bookmarks WHERE id = b.parent " +
"AND type IN (:bookmark_type, :separator_type, :dynamic_type) " +
"AND type IN (:bookmark_type, :separator_type) " +
"LIMIT 1) " +
")");
fixInvalidParents.params["unsorted_folder"] = PlacesUtils.unfiledBookmarksFolderId;
fixInvalidParents.params["bookmark_type"] = PlacesUtils.bookmarks.TYPE_BOOKMARK;
fixInvalidParents.params["separator_type"] = PlacesUtils.bookmarks.TYPE_SEPARATOR;
fixInvalidParents.params["dynamic_type"] = PlacesUtils.bookmarks.TYPE_DYNAMIC_CONTAINER;
cleanupStatements.push(fixInvalidParents);
// D.10 recalculate positions

Просмотреть файл

@ -410,7 +410,7 @@ var PlacesUtils = {
* @returns true if the node is readonly, false otherwise
*/
nodeIsReadOnly: function PU_nodeIsReadOnly(aNode) {
if (this.nodeIsFolder(aNode) || this.nodeIsDynamicContainer(aNode)) {
if (this.nodeIsFolder(aNode)) {
if (this._readOnly.indexOf(aNode.itemId) != -1)
return true;
}
@ -469,8 +469,7 @@ var PlacesUtils = {
*/
containerTypes: [Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY,
Ci.nsINavHistoryResultNode.RESULT_TYPE_DYNAMIC_CONTAINER],
Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY],
nodeIsContainer: function PU_nodeIsContainer(aNode) {
return this.containerTypes.indexOf(aNode.type) != -1;
},
@ -492,21 +491,6 @@ var PlacesUtils = {
this.nodeIsHost(aNode));
},
/**
* Determines whether or not a result-node is a dynamic-container item.
* The dynamic container result node type is for dynamically created
* containers (e.g. for the file browser service where you get your folders
* in bookmark menus).
* @param aNode
* A result node
* @returns true if the node is a dynamic container item, false otherwise
*/
nodeIsDynamicContainer: function PU_nodeIsDynamicContainer(aNode) {
if (aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_DYNAMIC_CONTAINER)
return true;
return false;
},
/**
* Determines if a container item id is a livemark.
* @param aItemId

Просмотреть файл

@ -49,7 +49,6 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsNetUtil.h"
#include "nsIDynamicContainer.h"
#include "nsUnicharUtils.h"
#include "nsPrintfCString.h"
#include "nsIUUIDGenerator.h"
@ -77,8 +76,7 @@ using namespace mozilla;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_Position = 14;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_Type = 15;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_PlaceID = 16;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_ServiceContractId = 17;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_Guid = 18;
const PRInt32 nsNavBookmarks::kGetChildrenIndex_Guid = 17;
using namespace mozilla::places;
@ -525,7 +523,6 @@ nsNavBookmarks::InsertBookmarkInDB(PRInt64 aPlaceId,
const nsACString& aTitle,
PRTime aDateAdded,
PRTime aLastModified,
const nsAString& aServiceContractId,
PRInt64* _itemId,
nsACString& _guid)
{
@ -536,10 +533,10 @@ nsNavBookmarks::InsertBookmarkInDB(PRInt64 aPlaceId,
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"INSERT INTO moz_bookmarks "
"(id, fk, type, parent, position, title, folder_type, "
"(id, fk, type, parent, position, title, "
"dateAdded, lastModified, guid) "
"VALUES (:item_id, :page_id, :item_type, :parent, :item_index, "
":item_title, :folder_type, :date_added, :last_modified, "
":item_title, :date_added, :last_modified, "
"GENERATE_GUID())"
);
NS_ENSURE_STATE(stmt);
@ -572,15 +569,6 @@ nsNavBookmarks::InsertBookmarkInDB(PRInt64 aPlaceId,
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("item_title"), aTitle);
NS_ENSURE_SUCCESS(rv, rv);
if (aServiceContractId.IsEmpty()) {
rv = stmt->BindNullByName(NS_LITERAL_CSTRING("folder_type"));
}
else {
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("folder_type"),
aServiceContractId);
}
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("date_added"), aDateAdded);
NS_ENSURE_SUCCESS(rv, rv);
@ -672,9 +660,8 @@ nsNavBookmarks::InsertBookmark(PRInt64 aFolder,
nsCString title;
TruncateTitle(aTitle, title);
rv = InsertBookmarkInDB(placeId, BOOKMARK, aFolder, index,
title, dateAdded, nsnull, EmptyString(),
aNewBookmarkId, guid);
rv = InsertBookmarkInDB(placeId, BOOKMARK, aFolder, index, title, dateAdded,
nsnull, aNewBookmarkId, guid);
NS_ENSURE_SUCCESS(rv, rv);
// Recalculate frecency for this entry, since it changed.
@ -750,15 +737,6 @@ nsNavBookmarks::RemoveItem(PRInt64 aItemId)
NS_ENSURE_SUCCESS(rv, rv);
if (bookmark.type == TYPE_FOLDER) {
// If this is a dynamic container, try to notify its service.
if (!bookmark.serviceCID.IsEmpty()) {
nsCOMPtr<nsIDynamicContainer> svc =
do_GetService(bookmark.serviceCID.get());
if (svc) {
(void)svc->OnContainerRemoving(bookmark.id);
}
}
// Remove all of the folder's children.
rv = RemoveFolderChildren(bookmark.id);
NS_ENSURE_SUCCESS(rv, rv);
@ -862,29 +840,12 @@ nsNavBookmarks::CreateFolder(PRInt64 aParent, const nsACString& aName,
// be changed, we'll use a local variable to hold it. The true argument
// will cause notifications to be sent to bookmark observers.
PRInt32 localIndex = aIndex;
nsresult rv = CreateContainerWithID(-1, aParent, aName, EmptyString(),
true, &localIndex, aNewFolder);
nsresult rv = CreateContainerWithID(-1, aParent, aName, true, &localIndex,
aNewFolder);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::CreateDynamicContainer(PRInt64 aParent,
const nsACString& aName,
const nsAString& aContractId,
PRInt32 aIndex,
PRInt64* aNewFolder)
{
NS_ENSURE_FALSE(aContractId.IsEmpty(), NS_ERROR_INVALID_ARG);
nsresult rv = CreateContainerWithID(-1, aParent, aName, aContractId,
false, &aIndex, aNewFolder);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::GetFolderReadonly(PRInt64 aFolder, bool* aResult)
{
@ -929,7 +890,6 @@ nsresult
nsNavBookmarks::CreateContainerWithID(PRInt64 aItemId,
PRInt64 aParent,
const nsACString& aTitle,
const nsAString& aContractId,
bool aIsBookmarkFolder,
PRInt32* aIndex,
PRInt64* aNewFolder)
@ -958,13 +918,11 @@ nsNavBookmarks::CreateContainerWithID(PRInt64 aItemId,
*aNewFolder = aItemId;
PRTime dateAdded = PR_Now();
nsCAutoString guid;
ItemType containerType = aIsBookmarkFolder ? FOLDER
: DYNAMIC_CONTAINER;
nsCString title;
TruncateTitle(aTitle, title);
rv = InsertBookmarkInDB(-1, containerType, aParent, index,
title, dateAdded, nsnull, aContractId, aNewFolder,
rv = InsertBookmarkInDB(-1, FOLDER, aParent, index,
title, dateAdded, nsnull, aNewFolder,
guid);
NS_ENSURE_SUCCESS(rv, rv);
@ -977,7 +935,7 @@ nsNavBookmarks::CreateContainerWithID(PRInt64 aItemId,
NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
nsINavBookmarkObserver,
OnItemAdded(*aNewFolder, aParent, index, containerType,
OnItemAdded(*aNewFolder, aParent, index, FOLDER,
nsnull, title, dateAdded, guid, folderGuid));
*aIndex = index;
@ -1021,7 +979,7 @@ nsNavBookmarks::InsertSeparator(PRInt64 aParent,
nsCAutoString guid;
PRTime dateAdded = PR_Now();
rv = InsertBookmarkInDB(-1, SEPARATOR, aParent, index, voidString, dateAdded,
nsnull, EmptyString(), aNewItemId, guid);
nsnull, aNewItemId, guid);
NS_ENSURE_SUCCESS(rv, rv);
rv = transaction.Commit();
@ -1143,8 +1101,7 @@ nsNavBookmarks::GetDescendantChildren(PRInt64 aFolderId,
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, "
"b.folder_type, b.guid "
"b.parent, null, h.frecency, b.position, b.type, b.fk, b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -1178,16 +1135,7 @@ nsNavBookmarks::GetDescendantChildren(PRInt64 aFolderId,
rv = stmt->GetUTF8String(nsNavHistory::kGetInfoIndex_URL, child.url);
NS_ENSURE_SUCCESS(rv, rv);
}
else if (child.type == TYPE_FOLDER) {
bool isNull;
rv = stmt->GetIsNull(kGetChildrenIndex_ServiceContractId, &isNull);
NS_ENSURE_SUCCESS(rv, rv);
if (!isNull) {
rv = stmt->GetUTF8String(kGetChildrenIndex_ServiceContractId,
child.serviceCID);
NS_ENSURE_SUCCESS(rv, rv);
}
}
// Append item to children's array.
aFolderChildrenArray.AppendElement(child);
}
@ -1248,17 +1196,6 @@ nsNavBookmarks::RemoveFolderChildren(PRInt64 aFolderId)
if (child.type == TYPE_FOLDER) {
foldersToRemove.AppendLiteral(",");
foldersToRemove.AppendInt(child.id);
// If this is a dynamic container, try to notify its service that we
// are going to remove it.
// XXX (bug 484094) this should use a bookmark observer!
if (!child.serviceCID.IsEmpty()) {
nsCOMPtr<nsIDynamicContainer> svc =
do_GetService(child.serviceCID.get());
if (svc) {
(void)svc->OnContainerRemoving(child.id);
}
}
}
BEGIN_CRITICAL_BOOKMARK_CACHE_SECTION(child.id);
@ -1501,15 +1438,6 @@ nsNavBookmarks::MoveItem(PRInt64 aItemId, PRInt64 aNewParent, PRInt32 aIndex)
bookmark.guid,
bookmark.parentGuid,
newParentGuid));
// notify dynamic container provider if there is one
if (!bookmark.serviceCID.IsEmpty()) {
nsCOMPtr<nsIDynamicContainer> svc =
do_GetService(bookmark.serviceCID.get());
if (svc) {
(void)svc->OnContainerMoved(bookmark.id, aNewParent, newIndex);
}
}
return NS_OK;
}
@ -1528,8 +1456,7 @@ nsNavBookmarks::FetchItemInfo(PRInt64 aItemId,
// LEFT JOIN since not all bookmarks have an associated place.
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT b.id, h.url, b.title, b.position, b.fk, b.parent, b.type, "
"b.folder_type, b.dateAdded, b.lastModified, b.guid, "
"t.guid, t.parent "
"b.dateAdded, b.lastModified, b.guid, t.guid, t.parent "
"FROM moz_bookmarks b "
"LEFT JOIN moz_bookmarks t ON t.id = b.parent "
"LEFT JOIN moz_places h ON h.id = b.fk "
@ -1569,28 +1496,19 @@ nsNavBookmarks::FetchItemInfo(PRInt64 aItemId,
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->GetInt32(6, &_bookmark.type);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->GetIsNull(7, &isNull);
rv = stmt->GetInt64(7, &_bookmark.dateAdded);
NS_ENSURE_SUCCESS(rv, rv);
if (isNull) {
_bookmark.serviceCID.SetIsVoid(true);
}
else {
rv = stmt->GetUTF8String(7, _bookmark.serviceCID);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = stmt->GetInt64(8, &_bookmark.dateAdded);
rv = stmt->GetInt64(8, &_bookmark.lastModified);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->GetInt64(9, &_bookmark.lastModified);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->GetUTF8String(10, _bookmark.guid);
rv = stmt->GetUTF8String(9, _bookmark.guid);
NS_ENSURE_SUCCESS(rv, rv);
// Getting properties of the root would show no parent.
rv = stmt->GetIsNull(11, &isNull);
rv = stmt->GetIsNull(10, &isNull);
NS_ENSURE_SUCCESS(rv, rv);
if (!isNull) {
rv = stmt->GetUTF8String(11, _bookmark.parentGuid);
rv = stmt->GetUTF8String(10, _bookmark.parentGuid);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->GetInt64(12, &_bookmark.grandParentId);
rv = stmt->GetInt64(11, &_bookmark.grandParentId);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
@ -1942,21 +1860,6 @@ nsNavBookmarks::GetItemType(PRInt64 aItemId, PRUint16* _type)
}
nsresult
nsNavBookmarks::GetFolderType(PRInt64 aItemId,
nsACString& _type)
{
NS_ENSURE_ARG_MIN(aItemId, 1);
BookmarkData bookmark;
nsresult rv = FetchItemInfo(aItemId, bookmark);
NS_ENSURE_SUCCESS(rv, rv);
_type = bookmark.serviceCID;
return NS_OK;
}
nsresult
nsNavBookmarks::ResultNodeForContainer(PRInt64 aItemId,
nsNavHistoryQueryOptions* aOptions,
@ -1966,21 +1869,10 @@ nsNavBookmarks::ResultNodeForContainer(PRInt64 aItemId,
nsresult rv = FetchItemInfo(aItemId, bookmark);
NS_ENSURE_SUCCESS(rv, rv);
if (bookmark.type == TYPE_DYNAMIC_CONTAINER) {
*aNode = new nsNavHistoryContainerResultNode(EmptyCString(),
bookmark.title,
EmptyCString(),
nsINavHistoryResultNode::RESULT_TYPE_DYNAMIC_CONTAINER,
true,
bookmark.serviceCID,
aOptions);
(*aNode)->mItemId = bookmark.id;
}
else if (bookmark.type == TYPE_FOLDER) { // TYPE_FOLDER
if (bookmark.type == TYPE_FOLDER) { // TYPE_FOLDER
*aNode = new nsNavHistoryFolderResultNode(bookmark.title,
aOptions,
bookmark.id,
EmptyCString());
bookmark.id);
}
else {
return NS_ERROR_INVALID_ARG;
@ -2012,7 +1904,7 @@ nsNavBookmarks::QueryFolderChildren(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, "
"b.folder_type, b.guid "
"b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -2078,17 +1970,11 @@ nsNavBookmarks::ProcessFolderNodeRow(
return NS_OK;
}
}
else if (itemType == TYPE_FOLDER || itemType == TYPE_DYNAMIC_CONTAINER) {
else if (itemType == TYPE_FOLDER) {
if (aOptions->ExcludeReadOnlyFolders()) {
// If the folder is read-only, skip it.
bool readOnly;
if (itemType == TYPE_DYNAMIC_CONTAINER) {
readOnly = true;
}
else {
readOnly = false;
GetFolderReadonly(id, &readOnly);
}
bool readOnly = false;
GetFolderReadonly(id, &readOnly);
if (readOnly)
return NS_OK;
}
@ -2141,7 +2027,7 @@ nsNavBookmarks::QueryFolderChildrenAsync(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, "
"b.folder_type, b.guid "
"b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "

Просмотреть файл

@ -220,7 +220,6 @@ public:
*/
nsresult CreateContainerWithID(PRInt64 aId, PRInt64 aParent,
const nsACString& aTitle,
const nsAString& aContractId,
bool aIsBookmarkFolder,
PRInt32* aIndex,
PRInt64* aNewFolder);
@ -318,8 +317,6 @@ private:
nsACString& _guid,
PRInt64* _parentId);
nsresult GetFolderType(PRInt64 aFolder, nsACString& aType);
nsresult GetLastChildId(PRInt64 aFolder, PRInt64* aItemId);
/**
@ -356,7 +353,6 @@ private:
BOOKMARK = TYPE_BOOKMARK,
FOLDER = TYPE_FOLDER,
SEPARATOR = TYPE_SEPARATOR,
DYNAMIC_CONTAINER = TYPE_DYNAMIC_CONTAINER
};
/**
@ -381,9 +377,6 @@ private:
* @param [optional] aLastModified
* The last modified date for the insertion.
* It defaults to aDateAdded.
* @param [optional] aServiceContractId
* The contract id for a dynamic container.
* Pass EmptyCString() for other type of containers.
*
* @return The new item id that has been inserted.
*
@ -396,7 +389,6 @@ private:
const nsACString& aTitle,
PRTime aDateAdded,
PRTime aLastModified,
const nsAString& aServiceContractId,
PRInt64* _itemId,
nsACString& _guid);
@ -425,7 +417,6 @@ private:
static const PRInt32 kGetChildrenIndex_Type;
static const PRInt32 kGetChildrenIndex_PlaceID;
static const PRInt32 kGetChildrenIndex_FolderTitle;
static const PRInt32 kGetChildrenIndex_ServiceContractId;
static const PRInt32 kGetChildrenIndex_Guid;
class RemoveFolderTransaction : public nsITransaction {
@ -446,11 +437,6 @@ private:
rv = bookmarks->GetItemTitle(mID, mTitle);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString type;
rv = bookmarks->GetFolderType(mID, type);
NS_ENSURE_SUCCESS(rv, rv);
CopyUTF8toUTF16(type, mType);
return bookmarks->RemoveItem(mID);
}
@ -458,7 +444,7 @@ private:
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
PRInt64 newFolder;
return bookmarks->CreateContainerWithID(mID, mParent, mTitle, mType, true,
return bookmarks->CreateContainerWithID(mID, mParent, mTitle, true,
&mIndex, &newFolder);
}
@ -480,7 +466,6 @@ private:
PRInt64 mID;
PRInt64 mParent;
nsCString mTitle;
nsString mType;
PRInt32 mIndex;
};

Просмотреть файл

@ -56,7 +56,6 @@
#include "prtime.h"
#include "prprf.h"
#include "nsIDynamicContainer.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIClassInfo.h"
#include "nsIProgrammingLanguage.h"
@ -498,14 +497,13 @@ NS_INTERFACE_MAP_END_INHERITING(nsNavHistoryResultNode)
nsNavHistoryContainerResultNode::nsNavHistoryContainerResultNode(
const nsACString& aURI, const nsACString& aTitle,
const nsACString& aIconURI, PRUint32 aContainerType, bool aReadOnly,
const nsACString& aDynamicContainerType, nsNavHistoryQueryOptions* aOptions) :
nsNavHistoryQueryOptions* aOptions) :
nsNavHistoryResultNode(aURI, aTitle, 0, 0, aIconURI),
mResult(nsnull),
mContainerType(aContainerType),
mExpanded(false),
mChildrenReadOnly(aReadOnly),
mOptions(aOptions),
mDynamicContainerType(aDynamicContainerType),
mAsyncCanceledState(NOT_CANCELED)
{
}
@ -514,7 +512,6 @@ nsNavHistoryContainerResultNode::nsNavHistoryContainerResultNode(
const nsACString& aURI, const nsACString& aTitle,
PRTime aTime,
const nsACString& aIconURI, PRUint32 aContainerType, bool aReadOnly,
const nsACString& aDynamicContainerType,
nsNavHistoryQueryOptions* aOptions) :
nsNavHistoryResultNode(aURI, aTitle, 0, aTime, aIconURI),
mResult(nsnull),
@ -522,7 +519,6 @@ nsNavHistoryContainerResultNode::nsNavHistoryContainerResultNode(
mExpanded(false),
mChildrenReadOnly(aReadOnly),
mOptions(aOptions),
mDynamicContainerType(aDynamicContainerType),
mAsyncCanceledState(NOT_CANCELED)
{
}
@ -655,24 +651,7 @@ nsNavHistoryContainerResultNode::OpenContainer()
NS_ASSERTION(!mExpanded, "Container must not be expanded to open it");
mExpanded = true;
nsresult rv;
if (IsDynamicContainer()) {
// dynamic container API may want to fill us
nsCOMPtr<nsIDynamicContainer> svc = do_GetService(mDynamicContainerType.get(), &rv);
if (NS_SUCCEEDED(rv)) {
svc->OnContainerNodeOpening(this, GetGeneratingOptions());
} else {
NS_WARNING("Unable to get dynamic container for ");
NS_WARNING(mDynamicContainerType.get());
}
PRInt32 oldAccessCount = mAccessCount;
FillStats();
rv = ReverseUpdateStats(mAccessCount - oldAccessCount);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = NotifyOnStateChange(STATE_CLOSED);
nsresult rv = NotifyOnStateChange(STATE_CLOSED);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -706,14 +685,6 @@ nsNavHistoryContainerResultNode::CloseContainer(bool aSuppressNotifications)
}
mExpanded = false;
if (IsDynamicContainer()) {
// Notify dynamic containers that we are closing.
nsCOMPtr<nsIDynamicContainer> svc =
do_GetService(mDynamicContainerType.get());
if (svc)
svc->OnContainerNodeClosed(this);
}
}
// Be sure to set this to null before notifying observers. It signifies that
@ -2082,197 +2053,6 @@ nsNavHistoryContainerResultNode::GetChildrenReadOnly(bool *aChildrenReadOnly)
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::GetDynamicContainerType(
nsACString& aDynamicContainerType)
{
aDynamicContainerType = mDynamicContainerType;
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendURINode(
const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount,
PRTime aTime, const nsACString& aIconURI, nsINavHistoryResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
// If we are child of an ExcludeItems parent or root, we should not append
// URI Nodes.
if ((mResult && mResult->mRootNode->mOptions->ExcludeItems()) ||
(mParent && mParent->mOptions->ExcludeItems()))
return NS_OK;
nsRefPtr<nsNavHistoryResultNode> result =
new nsNavHistoryResultNode(aURI, aTitle, aAccessCount, aTime, aIconURI);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// append to our list
nsresult rv = InsertChildAt(result, mChildren.Count());
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*_retval = result);
return NS_OK;
}
#if 0 // UNTESTED, commented out until it can be tested
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendVisitNode(
const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount,
PRTime aTime, const nsACString& aIconURI, PRInt64 aSession,
nsINavHistoryVisitResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
nsRefPtr<nsNavHistoryVisitResultNode> result =
new nsNavHistoryVisitResultNode(aURI, aTitle, aAccessCount, aTime,
aIconURI, aSession);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// append to our list
if (! mChildren.AppendObject(result))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval = result);
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendFullVisitNode(
const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount,
PRTime aTime, const nsACString& aIconURI, PRInt64 aSession,
PRInt64 aVisitId, PRInt64 aReferringVisitId, PRInt32 aTransitionType,
nsINavHistoryFullVisitResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
nsRefPtr<nsNavHistoryFullVisitResultNode> result =
new nsNavHistoryFullVisitResultNode(aURI, aTitle, aAccessCount, aTime,
aIconURI, aSession, aVisitId,
aReferringVisitId, aTransitionType);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// append to our list
if (! mChildren.AppendObject(result))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval = result);
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendContainerNode(
const nsACString& aTitle, const nsACString& aIconURI,
PRUint32 aContainerType, const nsACString& aDynamicContainerType,
nsINavHistoryContainerResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
if (! IsTypeContainer(aContainerType) || IsTypeFolder(aContainerType) ||
IsTypeQuery(aContainerType))
return NS_ERROR_INVALID_ARG; // not proper container type
if (aContainerType == nsNavHistoryResultNode::RESULT_TYPE_DYNAMIC_CONTAINER &&
aRemoteContainerType.IsEmpty())
return NS_ERROR_INVALID_ARG; // dynamic containers must have d.c. type
if (aContainerType != nsNavHistoryResultNode::RESULT_TYPE_DYNAMIC_CONTAINER &&
! aDynamicContainerType.IsEmpty())
return NS_ERROR_INVALID_ARG; // non-dynamic containers must NOT have d.c. type
nsRefPtr<nsNavHistoryContainerResultNode> result =
new nsNavHistoryContainerResultNode(EmptyCString(), aTitle, aIconURI,
aContainerType, true,
aDynamicContainerType);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// append to our list
if (! mChildren.AppendObject(result))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval = result);
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendQueryNode(
const nsACString& aQueryURI, const nsACString& aTitle,
const nsACString& aIconURI, nsINavHistoryQueryResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
nsRefPtr<nsNavHistoryQueryResultNode> result =
new nsNavHistoryQueryResultNode(aQueryURI, aTitle, aIconURI);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// append to our list
if (! mChildren.AppendObject(result))
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval = result);
return NS_OK;
}
#endif
NS_IMETHODIMP
nsNavHistoryContainerResultNode::AppendFolderNode(
PRInt64 aFolderId, nsINavHistoryContainerResultNode** _retval)
{
*_retval = nsnull;
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
// create the node, it will be addrefed for us
nsRefPtr<nsNavHistoryResultNode> result;
nsresult rv = bookmarks->ResultNodeForContainer(aFolderId,
GetGeneratingOptions(),
getter_AddRefs(result));
NS_ENSURE_SUCCESS(rv, rv);
// append to our list
rv = InsertChildAt(result, mChildren.Count());
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*_retval = result->GetAsContainer());
return NS_OK;
}
#if 0 // UNTESTED, commented out until it can be tested
NS_IMETHODIMP
nsNavHistoryContainerResultNode::ClearContents()
{
if (!IsDynamicContainer())
return NS_ERROR_INVALID_ARG; // we must be a dynamic container
// we know if CanRemoteContainersChange() then we are a regular container
// and not a query or folder, so clearing doesn't need anything else to
// happen (like unregistering observers). Also, since this should only
// happen when the container is closed, we don't need to redraw the screen.
mChildren.Clear();
PRUint32 oldAccessCount = mAccessCount;
mAccessCount = 0;
mTime = 0;
rv = ReverseUpdateStats(-PRInt32(oldAccessCount));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
#endif
/**
* HOW QUERY UPDATING WORKS
*
@ -2300,7 +2080,7 @@ nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
const nsACString& aQueryURI) :
nsNavHistoryContainerResultNode(aQueryURI, aTitle, aIconURI,
nsNavHistoryResultNode::RESULT_TYPE_QUERY,
true, EmptyCString(), nsnull),
true, nsnull),
mLiveUpdate(QUERYUPDATE_COMPLEX_WITH_BOOKMARKS),
mHasSearchTerms(false),
mContentsValid(false),
@ -2314,7 +2094,7 @@ nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
nsNavHistoryQueryOptions* aOptions) :
nsNavHistoryContainerResultNode(EmptyCString(), aTitle, aIconURI,
nsNavHistoryResultNode::RESULT_TYPE_QUERY,
true, EmptyCString(), aOptions),
true, aOptions),
mQueries(aQueries),
mContentsValid(false),
mBatchChanges(0)
@ -2336,7 +2116,7 @@ nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
nsNavHistoryQueryOptions* aOptions) :
nsNavHistoryContainerResultNode(EmptyCString(), aTitle, aTime, aIconURI,
nsNavHistoryResultNode::RESULT_TYPE_QUERY,
true, EmptyCString(), aOptions),
true, aOptions),
mQueries(aQueries),
mContentsValid(false),
mBatchChanges(0)
@ -3480,10 +3260,10 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsNavHistoryFolderResultNode,
nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
const nsACString& aTitle, nsNavHistoryQueryOptions* aOptions,
PRInt64 aFolderId, const nsACString& aDynamicContainerType) :
PRInt64 aFolderId) :
nsNavHistoryContainerResultNode(EmptyCString(), aTitle, EmptyCString(),
nsNavHistoryResultNode::RESULT_TYPE_FOLDER,
false, aDynamicContainerType, aOptions),
false, aOptions),
mContentsValid(false),
mQueryItemId(-1),
mIsRegisteredFolderObserver(false)
@ -3521,16 +3301,6 @@ nsNavHistoryFolderResultNode::OpenContainer()
if (!mContentsValid) {
rv = FillChildren();
NS_ENSURE_SUCCESS(rv, rv);
if (IsDynamicContainer()) {
// dynamic container API may want to change the bookmarks for this folder.
nsCOMPtr<nsIDynamicContainer> svc = do_GetService(mDynamicContainerType.get(), &rv);
if (NS_SUCCEEDED(rv)) {
svc->OnContainerNodeOpening(TO_CONTAINER(this), mOptions);
} else {
NS_WARNING("Unable to get dynamic container for ");
NS_WARNING(mDynamicContainerType.get());
}
}
}
mExpanded = true;
@ -3857,21 +3627,6 @@ nsNavHistoryFolderResultNode::HandleCompletion(PRUint16 aReason)
nsresult rv = OnChildrenFilled();
NS_ENSURE_SUCCESS(rv, rv);
if (IsDynamicContainer()) {
// The dynamic container service may want to change the bookmarks of this
// folder.
nsCOMPtr<nsIDynamicContainer> svc =
do_GetService(mDynamicContainerType.get(), &rv);
if (NS_SUCCEEDED(rv)) {
svc->OnContainerNodeOpening(
static_cast<nsNavHistoryContainerResultNode*>(this), mOptions);
}
else {
NS_WARNING("Unable to get dynamic container for ");
NS_WARNING(mDynamicContainerType.get());
}
}
mExpanded = true;
mAsyncPendingStmt = nsnull;
@ -4117,8 +3872,7 @@ nsNavHistoryFolderResultNode::OnItemAdded(PRInt64 aItemId,
rv = history->BookmarkIdToResultNode(aItemId, mOptions, getter_AddRefs(node));
NS_ENSURE_SUCCESS(rv, rv);
}
else if (aItemType == nsINavBookmarksService::TYPE_FOLDER ||
aItemType == nsINavBookmarksService::TYPE_DYNAMIC_CONTAINER) {
else if (aItemType == nsINavBookmarksService::TYPE_FOLDER) {
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
rv = bookmarks->ResultNodeForContainer(aItemId, mOptions, getter_AddRefs(node));

Просмотреть файл

@ -310,8 +310,7 @@ public:
// 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.
bool IsTypeContainer(PRUint32 type) {
return (type == nsINavHistoryResultNode::RESULT_TYPE_DYNAMIC_CONTAINER ||
type == nsINavHistoryResultNode::RESULT_TYPE_QUERY ||
return (type == nsINavHistoryResultNode::RESULT_TYPE_QUERY ||
type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER ||
type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER_SHORTCUT);
}
@ -320,11 +319,6 @@ public:
GetType(&type);
return IsTypeContainer(type);
}
bool IsDynamicContainer() {
PRUint32 type;
GetType(&type);
return (type == nsINavHistoryResultNode::RESULT_TYPE_DYNAMIC_CONTAINER);
}
static bool IsTypeURI(PRUint32 type) {
return (type == nsINavHistoryResultNode::RESULT_TYPE_URI ||
type == nsINavHistoryResultNode::RESULT_TYPE_VISIT ||
@ -492,25 +486,7 @@ public:
PRInt64 aItemId, bool aRecursive, \
nsINavHistoryResultNode** _retval) \
{ return nsNavHistoryContainerResultNode::FindNodeByDetails(aURIString, aTime, aItemId, \
aRecursive, _retval); } \
NS_IMETHOD GetDynamicContainerType(nsACString& aDynamicContainerType) \
{ return nsNavHistoryContainerResultNode::GetDynamicContainerType(aDynamicContainerType); } \
NS_IMETHOD AppendURINode(const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount, PRTime aTime, const nsACString& aIconURI, nsINavHistoryResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendURINode(aURI, aTitle, aAccessCount, aTime, aIconURI, _retval); } \
NS_IMETHOD AppendFolderNode(PRInt64 aFolderId, nsINavHistoryContainerResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendFolderNode(aFolderId, _retval); }
/* Untested container API functions
NS_IMETHOD AppendVisitNode(const nsACString& aURI, const nsACString & aTitle, PRUint32 aAccessCount, PRTime aTime, const nsACString & aIconURI, PRInt64 aSession, nsINavHistoryVisitResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendVisitNode(aURI, aTitle, aAccessCount, aTime, aIconURI, aSession, _retval); } \
NS_IMETHOD AppendFullVisitNode(const nsACString& aURI, const nsACString & aTitle, PRUint32 aAccessCount, PRTime aTime, const nsACString & aIconURI, PRInt64 aSession, PRInt64 aVisitId, PRInt64 aReferringVisitId, PRInt32 aTransitionType, nsINavHistoryFullVisitResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendFullVisitNode(aURI, aTitle, aAccessCount, aTime, aIconURI, aSession, aVisitId, aReferringVisitId, aTransitionType, _retval); } \
NS_IMETHOD AppendContainerNode(const nsACString & aTitle, const nsACString & aIconURI, PRUint32 aContainerType, const nsACString & aRemoteContainerType, nsINavHistoryContainerResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendContainerNode(aTitle, aIconURI, aContainerType, aRemoteContainerType, _retval); } \
NS_IMETHOD AppendQueryNode(const nsACString& aQueryURI, const nsACString & aTitle, const nsACString & aIconURI, nsINavHistoryQueryResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::AppendQueryNode(aQueryURI, aTitle, aIconURI, _retval); } \
NS_IMETHOD ClearContents() \
{ return nsNavHistoryContainerResultNode::ClearContents(); }
*/
aRecursive, _retval); }
#define NS_NAVHISTORYCONTAINERRESULTNODE_IID \
{ 0x6e3bf8d3, 0x22aa, 0x4065, { 0x86, 0xbc, 0x37, 0x46, 0xb5, 0xb3, 0x2c, 0xe8 } }
@ -522,14 +498,12 @@ public:
nsNavHistoryContainerResultNode(
const nsACString& aURI, const nsACString& aTitle,
const nsACString& aIconURI, PRUint32 aContainerType,
bool aReadOnly, const nsACString& aDynamicContainerType,
nsNavHistoryQueryOptions* aOptions);
bool aReadOnly, nsNavHistoryQueryOptions* aOptions);
nsNavHistoryContainerResultNode(
const nsACString& aURI, const nsACString& aTitle,
PRTime aTime,
const nsACString& aIconURI, PRUint32 aContainerType,
bool aReadOnly, const nsACString& aDynamicContainerType,
nsNavHistoryQueryOptions* aOptions);
bool aReadOnly, nsNavHistoryQueryOptions* aOptions);
virtual nsresult Refresh();
virtual ~nsNavHistoryContainerResultNode();
@ -578,9 +552,6 @@ public:
nsCOMPtr<nsNavHistoryQueryOptions> mOptions;
// ID of a dynamic container interface that we can use GetService to get.
nsCString mDynamicContainerType;
void FillStats();
nsresult ReverseUpdateStats(PRInt32 aAccessCountChange);
@ -807,8 +778,7 @@ class nsNavHistoryFolderResultNode : public nsNavHistoryContainerResultNode,
public:
nsNavHistoryFolderResultNode(const nsACString& aTitle,
nsNavHistoryQueryOptions* options,
PRInt64 aFolderId,
const nsACString& aDynamicContainerType);
PRInt64 aFolderId);
virtual ~nsNavHistoryFolderResultNode();

Просмотреть файл

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
const CURRENT_SCHEMA_VERSION = 12;
const CURRENT_SCHEMA_VERSION = 13;
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";

Просмотреть файл

@ -1,99 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License
* at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and
* limitations under the License.
*
* The Original Code is Places Dynamic Containers unit test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Asaf Romano <mano@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the
* terms of either the GNU General Public License Version 2 or later
* (the "GPL"), or the GNU Lesser General Public License Version 2.1
* or later (the "LGPL"), in which case the provisions of the GPL or
* the LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of
* either the GPL or the LGPL, and not to allow others to use your
* version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the
* notice and other provisions required by the GPL or the LGPL. If you
* do not delete the provisions above, a recipient may use your
* version of this file under the terms of any one of the MPL, the GPL
* or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function RemoteContainerSampleService() {
}
RemoteContainerSampleService.prototype = {
get bms() {
if (!this._bms)
this._bms = Cc[BMS_CONTRACTID].getService(Ci.nsINavBookmarksService);
return this._bms;
},
get history() {
if (!this._history)
this._history = Cc[NH_CONTRACTID].getService(Ci.nsINavHistoryService);
return this._history;
},
// IO Service
get ios() {
if (!this._ios)
this._ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return this._ios;
},
// nsIDynamicContainer
onContainerRemoving: function(container) { },
onContainerMoved: function() { },
onContainerNodeOpening: function(container, options) {
container.appendURINode("http://foo.tld/", "uri 1", 0, 0, null);
var folder = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService).
getItemAnnotation(container.itemId, "exposedFolder");
container.appendFolderNode(folder);
},
onContainerNodeClosed: function() { },
createInstance: function LS_createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return this.QueryInterface(iid);
},
classID: Components.ID("{0d42adc5-f07a-4da2-b8da-3e2ef114cb67}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDynamicContainer]),
};
const NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteContainerSampleService]);

Просмотреть файл

@ -1,2 +0,0 @@
component {0d42adc5-f07a-4da2-b8da-3e2ef114cb67} nsDynamicContainerServiceSample.js
contract @mozilla.org/browser/remote-container-sample;1 {0d42adc5-f07a-4da2-b8da-3e2ef114cb67}

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Places Dynamic Containers unit test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Marco Bonardo <mak77@bonardo.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
try {
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var ans = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
} catch (ex) {
do_throw("Could not get services\n");
}
// create and add bookmarks observer
var observer = {
onBeginUpdateBatch: function() {},
onEndUpdateBatch: function() {},
onItemAdded: function(id, folder, index, itemType, uri) {
do_check_true(id > 0);
},
onBeforeItemRemoved: function() {},
onItemRemoved: function() {},
onItemChanged: function() {},
onItemVisited: function() {},
onItemMoved: function() {},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsINavBookmarkObserver) ||
iid.equals(Ci.nsISupports)) {
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
}
};
bms.addObserver(observer, false);
// main
function run_test() {
// load our dynamic-container sample service
do_load_manifest("nsDynamicContainerServiceSample.manifest");
var testRoot = bms.createFolder(bms.placesRoot, "test root", bms.DEFAULT_INDEX);
var options = hs.getNewQueryOptions();
var query = hs.getNewQuery();
query.setFolders([testRoot], 1);
var result = hs.executeQuery(query, options);
var rootNode = result.root;
rootNode.containerOpen = true;
// create our dynamic container while the containing folder is open
var remoteContainer =
bms.createDynamicContainer(testRoot, "remote container sample",
"@mozilla.org/browser/remote-container-sample;1",
bms.DEFAULT_INDEX);
rootNode.containerOpen = false;
}

Просмотреть файл

@ -1,126 +0,0 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Places Dynamic Containers unit test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Asaf Romano <mano@mozilla.com> (Original Author)
* Marco Bonardo <mak77@bonardo.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
} catch (ex) {
do_throw("Could not get services\n");
}
// main
function run_test() {
// load our dynamic-container sample service
do_load_manifest("nsDynamicContainerServiceSample.manifest");
var testRoot = bmsvc.createFolder(bmsvc.placesRoot, "test root", bmsvc.DEFAULT_INDEX);
var exposedFolder = bmsvc.createFolder(testRoot, "exposed folder", bmsvc.DEFAULT_INDEX);
var efId1 = bmsvc.insertBookmark(exposedFolder, uri("http://uri1.tld"), bmsvc.DEFAULT_INDEX, "");
// create our dynamic container
var remoteContainer =
bmsvc.createDynamicContainer(testRoot, "remote container sample",
"@mozilla.org/browser/remote-container-sample;1",
bmsvc.DEFAULT_INDEX);
// the service will read this annotation and append a folder node for
// |exposedFolder| to |remoteContainer|
annosvc.setItemAnnotation(remoteContainer, "exposedFolder",
exposedFolder, 0, 0);
// query |remoteContainer|
var options = histsvc.getNewQueryOptions();
var query = histsvc.getNewQuery();
query.setFolders([remoteContainer], 1);
var result = histsvc.executeQuery(query, options);
var rootNode = result.root;
// two nodes should be at the top lop of this container after opening it,
// the first is an arbitrary uri node ("http://foo.tld/"), the second is a
// folder node representing |exposedFolder|.
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 2);
do_check_eq(rootNode.getChild(0).uri, "http://foo.tld/");
var folder = rootNode.getChild(1).QueryInterface(Ci.nsINavHistoryContainerResultNode);
do_check_eq(folder.itemId, exposedFolder);
folder.containerOpen = true;
do_check_eq(folder.childCount, 1);
// check live update of a folder exposed within a remote container
bmsvc.insertBookmark(exposedFolder, uri("http://uri2.tld"), bmsvc.DEFAULT_INDEX, "");
do_check_eq(folder.childCount, 2);
folder.containerOpen = false;
rootNode.containerOpen = false;
// Bug 457681
// Make the dynamic container read-only and check that it appear in the result
bmsvc.setFolderReadonly(remoteContainer, true);
options = histsvc.getNewQueryOptions();
query = histsvc.getNewQuery();
query.setFolders([testRoot], 1);
result = histsvc.executeQuery(query, options);
rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 2);
do_check_eq(rootNode.getChild(1).title, "remote container sample");
rootNode.containerOpen = false;
// Bug 457686
// If the dynamic container is child of an excludeItems query it should not
// append uri nodes.
// The dynamic container should only return an empty folder on opening.
options = histsvc.getNewQueryOptions();
options.excludeItems = true;
query = histsvc.getNewQuery();
query.setFolders([remoteContainer], 1);
result = histsvc.executeQuery(query, options);
rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 1);
folder = rootNode.getChild(0).QueryInterface(Ci.nsINavHistoryContainerResultNode);
do_check_eq(folder.itemId, exposedFolder);
folder.containerOpen = true;
do_check_eq(folder.childCount, 0);
folder.containerOpen = false;
rootNode.containerOpen = false;
}

Просмотреть файл

@ -358,7 +358,6 @@ tests.push({
_bookmarkId: null,
_separatorId: null,
_folderId: null,
_dynamicContainerId: null,
_placeId: null,
setup: function() {
@ -372,8 +371,6 @@ tests.push({
this._separatorId = addBookmark(null, bs.TYPE_SEPARATOR, this._tagId);
// Insert a folder in the tag
this._folderId = addBookmark(null, bs.TYPE_FOLDER, this._tagId);
// Insert a dynamic container in the tag
this._dynamicContainerId = addBookmark(null, bs.TYPE_DYNAMIC_CONTAINER, this._tagId);
},
check: function() {
@ -392,11 +389,6 @@ tests.push({
stmt.params["type"] = bs.TYPE_FOLDER;
stmt.params["parent"] = this._tagId;
do_check_false(stmt.executeStep());
stmt.reset();
// Check that dynamic container is no more there
stmt.params["type"] = bs.TYPE_DYNAMIC_CONTAINER;
stmt.params["parent"] = this._tagId;
do_check_false(stmt.executeStep());
stmt.finalize();
}
});
@ -546,7 +538,6 @@ tests.push({
_separatorId: null,
_folderId: null,
_dynamicContainerId: null,
_placeId: null,
setup: function() {
@ -556,8 +547,6 @@ tests.push({
this._separatorId = addBookmark(this._placeId, bs.TYPE_SEPARATOR);
// Add a folder with a fk
this._folderId = addBookmark(this._placeId, bs.TYPE_FOLDER);
// Add a dynamic container with a fk
this._dynamicContainerId = addBookmark(this._placeId, bs.TYPE_DYNAMIC_CONTAINER, null, null, "test");
},
check: function() {
@ -570,10 +559,6 @@ tests.push({
stmt.params["item_id"] = this._folderId;
stmt.params["type"] = bs.TYPE_BOOKMARK;
do_check_true(stmt.executeStep());
stmt.reset();
stmt.params["item_id"] = this._dynamicContainerId;
stmt.params["type"] = bs.TYPE_BOOKMARK;
do_check_true(stmt.executeStep());
stmt.finalize();
}
});
@ -614,47 +599,14 @@ tests.push({
//------------------------------------------------------------------------------
tests.push({
name: "D.8",
desc: "Fix wrong item types | dynamic containers",
_validDynamicContainerId: null,
_invalidDynamicContainerId: null,
setup: function() {
// Add a valid dynamic container with a folder type
this._validDynamicContainerId = addBookmark(null, bs.TYPE_DYNAMIC_CONTAINER, null, null, "test");
// Add an invalid dynamic container without a folder type
this._invalidDynamicContainerId = addBookmark(null, bs.TYPE_DYNAMIC_CONTAINER, null, null, null);
},
check: function() {
// Check valid dynamic container is still there
let stmt = mDBConn.createStatement("SELECT id FROM moz_bookmarks WHERE id = :item_id AND type = :type");
stmt.params["item_id"] = this._validDynamicContainerId;
stmt.params["type"] = bs.TYPE_DYNAMIC_CONTAINER;
do_check_true(stmt.executeStep());
stmt.reset();
// Check invalid dynamic container has been converted to a normal folder
stmt.params["item_id"] = this._invalidDynamicContainerId;
stmt.params["type"] = bs.TYPE_FOLDER;
do_check_true(stmt.executeStep());
stmt.finalize();
}
});
//------------------------------------------------------------------------------
tests.push({
name: "D.9",
desc: "Fix wrong parents",
_bookmarkId: null,
_separatorId: null,
_dynamicContainerId: null,
_bookmarkId1: null,
_bookmarkId2: null,
_bookmarkId3: null,
_placeId: null,
setup: function() {
@ -664,12 +616,9 @@ tests.push({
this._bookmarkId = addBookmark(this._placeId, bs.TYPE_BOOKMARK);
// Insert a separator
this._separatorId = addBookmark(null, bs.TYPE_SEPARATOR);
// Insert a dynamic container
this.dynamicContainerId = addBookmark(null, bs.TYPE_DYNAMIC_CONTAINER, null, null, "test");
// Create 3 children of these items
this._bookmarkId1 = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._bookmarkId);
this._bookmarkId2 = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._separatorId);
this._bookmarkId3 = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._dynamicContainerId);
},
check: function() {
@ -682,10 +631,6 @@ tests.push({
stmt.params["item_id"] = this._bookmarkId2;
stmt.params["parent"] = bs.unfiledBookmarksFolder;
do_check_true(stmt.executeStep());
stmt.reset();
stmt.params["item_id"] = this._bookmarkId3;
stmt.params["parent"] = bs.unfiledBookmarksFolder;
do_check_true(stmt.executeStep());
stmt.finalize();
}
});

Просмотреть файл

@ -39,7 +39,6 @@ skip-if = os == "android"
[test_451499.js]
[test_452777.js]
[test_454977.js]
[test_457698_crash.js]
[test_463863.js]
[test_485442_crash_bug_nsNavHistoryQuery_GetUri.js]
[test_486978_sort_by_date_queries.js]
@ -70,7 +69,6 @@ fail-if = os == "android"
[test_download_history.js]
# Bug 676989: test fails consistently on Android
fail-if = os == "android"
[test_dynamic_containers.js]
[test_exclude_livemarks.js]
[test_faviconService_expireAllFavicons.js]
[test_favicons.js]