fix for regression bug #364018
cannot drag and drop url from location bar or webpage to bookmark toolbar. r=mano git-svn-id: svn://10.0.0.236/trunk@217483 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
cbc4777865
commit
ad2f3218b9
@ -1897,18 +1897,44 @@ var BookmarksUtils = {
|
||||
return selection;
|
||||
},
|
||||
|
||||
getTitleForURLFromHistory: function(aURL, aDefaultName)
|
||||
{
|
||||
#ifndef MOZ_PLACES
|
||||
// look up in the history ds to retrieve the name
|
||||
var rSource = RDF.GetResource(aURL);
|
||||
var HISTDS = RDF.GetDataSource("rdf:history");
|
||||
var nameArc = RDF.GetResource(gNC_NS+"Name");
|
||||
var rName = HISTDS.GetTarget(rSource, nameArc, true);
|
||||
return (rName ? rName.QueryInterface(kRDFLITIID).Value : aDefaultName);
|
||||
#else
|
||||
var histsvc =
|
||||
Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Components.interfaces.nsINavHistoryService);
|
||||
|
||||
// query for the URL
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_URI;
|
||||
var query = histsvc.getNewQuery();
|
||||
query.uri = IOSVC.newURI(aURL, null, null);
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
for (var i=0; i < cc; ++i) {
|
||||
var node = root.getChild(i);
|
||||
if (node.title)
|
||||
return node.title;
|
||||
}
|
||||
|
||||
return (aDefaultName ? aDefaultName : aURL);
|
||||
#endif
|
||||
},
|
||||
|
||||
createBookmark: function (aName, aURL, aCharSet, aDefaultName)
|
||||
{
|
||||
if (!aName) {
|
||||
// look up in the history ds to retrieve the name
|
||||
var rSource = RDF.GetResource(aURL);
|
||||
var HISTDS = RDF.GetDataSource("rdf:history");
|
||||
var nameArc = RDF.GetResource(gNC_NS+"Name");
|
||||
var rName = HISTDS.GetTarget(rSource, nameArc, true);
|
||||
aName = rName ? rName.QueryInterface(kRDFLITIID).Value : aDefaultName;
|
||||
if (!aName)
|
||||
aName = aURL;
|
||||
}
|
||||
if (!aName)
|
||||
aName = this.getTitleForURLFromHistory(aURL, aDefaultName);
|
||||
|
||||
if (!aCharSet) {
|
||||
var fw = document.commandDispatcher.focusedWindow;
|
||||
if (fw)
|
||||
@ -1917,21 +1943,6 @@ var BookmarksUtils = {
|
||||
return BMSVC.createBookmark(aName, aURL, null, null, aCharSet, null);
|
||||
},
|
||||
|
||||
createLivemark: function (aName, aURL, aFeedURL, aDefaultName)
|
||||
{
|
||||
if (!aName) {
|
||||
// look up in the history ds to retrieve the name
|
||||
var rSource = RDF.GetResource(aURL);
|
||||
var HISTDS = RDF.GetDataSource("rdf:history");
|
||||
var nameArc = RDF.GetResource(gNC_NS+"Name");
|
||||
var rName = HISTDS.GetTarget(rSource, nameArc, true);
|
||||
aName = rName ? rName.QueryInterface(kRDFLITIID).Value : aDefaultName;
|
||||
if (!aName)
|
||||
aName = aURL;
|
||||
}
|
||||
return BMSVC.createLivemark(aName, aURL, aFeedURL, null);
|
||||
},
|
||||
|
||||
flushDataSource: function ()
|
||||
{
|
||||
var remoteDS = BMDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user