mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Fix bug # 170622: Bookmarks deletion cmd needs to go through RDF composite db cmd APIs. Bookmarks need to NS_RDF_ASSERTION_REJECTED on unknown nodes. Bookmarking a group of tabs fix. r=blake sr=jag
This commit is contained in:
parent
05311863ab
commit
099af79d56
@ -990,8 +990,9 @@
|
|||||||
argsArray.AppendElement(rValue);
|
argsArray.AppendElement(rValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec the command in the Bookmarks datasource.
|
// Exec the command in the Composite (not Bookmarks) datasource
|
||||||
this.bookmarksDS.DoCommand(sourcesArray, rCommand, argsArray);
|
// so that command aggregation works
|
||||||
|
this.db.DoCommand(sourcesArray, rCommand, argsArray);
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
@ -1289,8 +1290,24 @@
|
|||||||
// assume its parent is the root
|
// assume its parent is the root
|
||||||
parent = ksRDF.GetResource("NC:BookmarksRoot");
|
parent = ksRDF.GetResource("NC:BookmarksRoot");
|
||||||
}
|
}
|
||||||
ksRDFC.Init(this.bookmarksDS, parent);
|
|
||||||
ksRDFC.RemoveElement(resource, true);
|
/*
|
||||||
|
Use RDF datasource command APIs instead of trying to
|
||||||
|
directly manipulate the bookmarks datasource graph via:
|
||||||
|
|
||||||
|
ksRDFC.Init(this.bookmarksDS, parent);
|
||||||
|
ksRDFC.RemoveElement(resource, true);
|
||||||
|
*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
var args = [{ property: this.NC_NS + "parent",
|
||||||
|
resource: parent.Value }];
|
||||||
|
this.doBookmarksCommand(resource.Value, this.NC_NS_CMD + "deletebookmark", args);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
nextIndex = j;
|
nextIndex = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2620,7 +2620,7 @@ nsresult
|
|||||||
nsBookmarksService::InsertResource(nsIRDFResource* aResource,
|
nsBookmarksService::InsertResource(nsIRDFResource* aResource,
|
||||||
nsIRDFResource* aParentFolder, PRInt32 aIndex)
|
nsIRDFResource* aParentFolder, PRInt32 aIndex)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv = NS_OK;
|
||||||
// Add to container if the parent folder is non null
|
// Add to container if the parent folder is non null
|
||||||
if (aParentFolder) {
|
if (aParentFolder) {
|
||||||
nsCOMPtr<nsIRDFContainer> container(do_GetService("@mozilla.org/rdf/container;1", &rv));
|
nsCOMPtr<nsIRDFContainer> container(do_GetService("@mozilla.org/rdf/container;1", &rv));
|
||||||
@ -2864,6 +2864,13 @@ nsBookmarksService::IsBookmarkedInternal(nsIRDFResource *bookmark, PRBool *isBoo
|
|||||||
if (!isBookmarkedFlag) return(NS_ERROR_UNEXPECTED);
|
if (!isBookmarkedFlag) return(NS_ERROR_UNEXPECTED);
|
||||||
if (!mInner) return(NS_ERROR_UNEXPECTED);
|
if (!mInner) return(NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
|
// bookmark root is special (it isn't contained in a rdf seq)
|
||||||
|
if (bookmark == kNC_BookmarksRoot)
|
||||||
|
{
|
||||||
|
*isBookmarkedFlag = PR_TRUE;
|
||||||
|
return(NS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
*isBookmarkedFlag = PR_FALSE;
|
*isBookmarkedFlag = PR_FALSE;
|
||||||
|
|
||||||
// make sure it is referred to by an ordinal (i.e. is contained in a rdf seq)
|
// make sure it is referred to by an ordinal (i.e. is contained in a rdf seq)
|
||||||
@ -4277,7 +4284,9 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *aRelativeNode,
|
|||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType)
|
nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src,
|
||||||
|
nsISupportsArray *aArguments,
|
||||||
|
PRInt32 parentArgIndex)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
@ -4288,13 +4297,6 @@ nsBookmarksService::deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA
|
|||||||
nsCOMPtr<nsIRDFResource> argParent = do_QueryInterface(aNode);
|
nsCOMPtr<nsIRDFResource> argParent = do_QueryInterface(aNode);
|
||||||
if (!argParent) return(NS_ERROR_NO_INTERFACE);
|
if (!argParent) return(NS_ERROR_NO_INTERFACE);
|
||||||
|
|
||||||
// make sure its an object of the correct type (bookmark, folder, separator, ...)
|
|
||||||
PRBool isCorrectObjectType = PR_FALSE;
|
|
||||||
if (NS_FAILED(rv = mInner->HasAssertion(src, kRDF_type,
|
|
||||||
objType, PR_TRUE, &isCorrectObjectType)))
|
|
||||||
return(rv);
|
|
||||||
if (!isCorrectObjectType) return(NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIRDFContainer> container;
|
nsCOMPtr<nsIRDFContainer> container;
|
||||||
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull,
|
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull,
|
||||||
NS_GET_IID(nsIRDFContainer), getter_AddRefs(container))))
|
NS_GET_IID(nsIRDFContainer), getter_AddRefs(container))))
|
||||||
@ -4538,22 +4540,11 @@ nsBookmarksService::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aComma
|
|||||||
if (NS_FAILED(rv)) return(rv);
|
if (NS_FAILED(rv)) return(rv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (aCommand == kNC_BookmarkCommand_DeleteBookmark)
|
else if (aCommand == kNC_BookmarkCommand_DeleteBookmark ||
|
||||||
|
aCommand == kNC_BookmarkCommand_DeleteBookmarkFolder ||
|
||||||
|
aCommand == kNC_BookmarkCommand_DeleteBookmarkSeparator)
|
||||||
{
|
{
|
||||||
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
|
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments, loop)))
|
||||||
loop, kNC_Bookmark)))
|
|
||||||
return(rv);
|
|
||||||
}
|
|
||||||
else if (aCommand == kNC_BookmarkCommand_DeleteBookmarkFolder)
|
|
||||||
{
|
|
||||||
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
|
|
||||||
loop, kNC_Folder)))
|
|
||||||
return(rv);
|
|
||||||
}
|
|
||||||
else if (aCommand == kNC_BookmarkCommand_DeleteBookmarkSeparator)
|
|
||||||
{
|
|
||||||
if (NS_FAILED(rv = deleteBookmarkItem(src, aArguments,
|
|
||||||
loop, kNC_BookmarkSeparator)))
|
|
||||||
return(rv);
|
return(rv);
|
||||||
}
|
}
|
||||||
else if (aCommand == kNC_BookmarkCommand_SetNewBookmarkFolder)
|
else if (aCommand == kNC_BookmarkCommand_SetNewBookmarkFolder)
|
||||||
@ -5459,13 +5450,12 @@ nsBookmarksService::CanAccept(nsIRDFResource* aSource,
|
|||||||
nsIRDFResource* aProperty,
|
nsIRDFResource* aProperty,
|
||||||
nsIRDFNode* aTarget)
|
nsIRDFNode* aTarget)
|
||||||
{
|
{
|
||||||
// XXX This is really crippled, and needs to be stricter. We want
|
|
||||||
// to exclude any property that isn't talking about a known
|
|
||||||
// bookmark.
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
PRBool canAcceptFlag = PR_FALSE, isOrdinal;
|
PRBool isBookmarkedFlag = PR_FALSE, canAcceptFlag = PR_FALSE, isOrdinal;
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv = gRDFC->IsOrdinalProperty(aProperty, &isOrdinal)))
|
if (NS_SUCCEEDED(rv = IsBookmarkedInternal(aSource, &isBookmarkedFlag)) &&
|
||||||
|
(isBookmarkedFlag == PR_TRUE) &&
|
||||||
|
(NS_SUCCEEDED(rv = gRDFC->IsOrdinalProperty(aProperty, &isOrdinal))))
|
||||||
{
|
{
|
||||||
if (isOrdinal == PR_TRUE)
|
if (isOrdinal == PR_TRUE)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ protected:
|
|||||||
|
|
||||||
nsresult getArgumentN(nsISupportsArray *arguments, nsIRDFResource *res, PRInt32 offset, nsIRDFNode **argValue);
|
nsresult getArgumentN(nsISupportsArray *arguments, nsIRDFResource *res, PRInt32 offset, nsIRDFNode **argValue);
|
||||||
nsresult insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, nsIRDFResource *objType);
|
nsresult insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, nsIRDFResource *objType);
|
||||||
nsresult deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType);
|
nsresult deleteBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex);
|
||||||
nsresult setFolderHint(nsIRDFResource *src, nsIRDFResource *objType);
|
nsresult setFolderHint(nsIRDFResource *src, nsIRDFResource *objType);
|
||||||
nsresult getFolderViaHint(nsIRDFResource *src, PRBool fallbackFlag, nsIRDFResource **folder);
|
nsresult getFolderViaHint(nsIRDFResource *src, PRBool fallbackFlag, nsIRDFResource **folder);
|
||||||
nsresult importBookmarks(nsISupportsArray *aArguments);
|
nsresult importBookmarks(nsISupportsArray *aArguments);
|
||||||
|
Loading…
Reference in New Issue
Block a user