зеркало из https://github.com/mozilla/gecko-dev.git
241028 - should be able to create smart keywords to forms that use the http POST method.
This commit is contained in:
Родитель
1280270843
Коммит
97ebd0e4ba
|
@ -244,7 +244,7 @@ function Startup()
|
|||
|
||||
if (uriToLoad && !gIsLoadingBlank) {
|
||||
if ("arguments" in window && window.arguments.length >= 3)
|
||||
loadURI(uriToLoad, window.arguments[2]);
|
||||
loadURI(uriToLoad, window.arguments[2], null);
|
||||
else
|
||||
loadOneOrMoreURIs(uriToLoad);
|
||||
}
|
||||
|
@ -775,12 +775,12 @@ function loadOneOrMoreURIs(aURIString)
|
|||
{
|
||||
if (aURIString.indexOf("|") != -1) {
|
||||
var urls = aURIString.split("|");
|
||||
loadURI(urls[0]);
|
||||
loadURI(urls[0], null, null);
|
||||
for (var i = 1; i < urls.length; ++i)
|
||||
gBrowser.addTab(urls[i]);
|
||||
}
|
||||
else
|
||||
loadURI(aURIString);
|
||||
loadURI(aURIString, null, null);
|
||||
}
|
||||
|
||||
function constructGoMenuItem(goMenu, beforeItem, url, title)
|
||||
|
@ -1023,15 +1023,17 @@ function BrowserCloseWindow()
|
|||
closeWindow(true);
|
||||
}
|
||||
|
||||
function loadURI(uri, referrer)
|
||||
function loadURI(uri, referrer, postData)
|
||||
{
|
||||
try {
|
||||
getWebNavigation().loadURI(uri, nsIWebNavigation.LOAD_FLAGS_NONE, referrer, null, null);
|
||||
if (postData === undefined)
|
||||
postData = null;
|
||||
getWebNavigation().loadURI(uri, nsIWebNavigation.LOAD_FLAGS_NONE, referrer, postData, null);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function BrowserLoadURL(aTriggeringEvent)
|
||||
function BrowserLoadURL(aTriggeringEvent, aPostData)
|
||||
{
|
||||
var url = gURLBar.value;
|
||||
if (url.match(/^view-source:/)) {
|
||||
|
@ -1041,7 +1043,7 @@ function BrowserLoadURL(aTriggeringEvent)
|
|||
aTriggeringEvent && 'altKey' in aTriggeringEvent &&
|
||||
aTriggeringEvent.altKey) {
|
||||
_content.focus();
|
||||
var t = gBrowser.addTab(url); // open link in new tab
|
||||
var t = gBrowser.addTab(url, aPostData); // open link in new tab
|
||||
gBrowser.selectedTab = t;
|
||||
gURLBar.value = url;
|
||||
event.preventDefault();
|
||||
|
@ -1050,42 +1052,82 @@ function BrowserLoadURL(aTriggeringEvent)
|
|||
event.stopPropagation();
|
||||
}
|
||||
else
|
||||
loadURI(url);
|
||||
loadURI(url, null, aPostData);
|
||||
_content.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function getShortcutOrURI(url)
|
||||
function getShortcutOrURI(aURL, aPostDataRef)
|
||||
{
|
||||
// rjc: added support for URL shortcuts (3/30/1999)
|
||||
try {
|
||||
var shortcutURL = BMSVC.resolveKeyword(url);
|
||||
var shortcutURL = BMSVC.resolveKeyword(aURL, aPostDataRef);
|
||||
if (!shortcutURL) {
|
||||
// rjc: add support for string substitution with shortcuts (4/4/2000)
|
||||
// (see bug # 29871 for details)
|
||||
var aOffset = url.indexOf(" ");
|
||||
var aOffset = aURL.indexOf(" ");
|
||||
if (aOffset > 0) {
|
||||
var cmd = url.substr(0, aOffset);
|
||||
var text = url.substr(aOffset+1);
|
||||
shortcutURL = BMSVC.resolveKeyword(cmd);
|
||||
var cmd = aURL.substr(0, aOffset);
|
||||
var text = aURL.substr(aOffset+1);
|
||||
shortcutURL = BMSVC.resolveKeyword(cmd, aPostDataRef);
|
||||
if (shortcutURL && text) {
|
||||
aOffset = shortcutURL.indexOf("%s");
|
||||
if (aOffset >= 0)
|
||||
shortcutURL = shortcutURL.substr(0, aOffset) + text + shortcutURL.substr(aOffset+2);
|
||||
if (aPostDataRef && aPostDataRef.value) {
|
||||
// XXXben - currently we only support "application/x-www-form-urlencoded"
|
||||
// enctypes.
|
||||
aPostDataRef.value = unescape(aPostDataRef.value);
|
||||
if (aPostDataRef.value.match(/%s/))
|
||||
aPostDataRef.value = getPostDataStream(aPostDataRef.value, text,
|
||||
"application/x-www-form-urlencoded");
|
||||
else {
|
||||
shortcutURL = null;
|
||||
aPostDataRef.value = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
shortcutURL = null;
|
||||
shortcutURL = shortcutURL.match(/%s/) ? shortcutURL.replace(/%s/, text) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shortcutURL)
|
||||
url = shortcutURL;
|
||||
aURL = shortcutURL;
|
||||
|
||||
} catch (ex) {
|
||||
}
|
||||
return url;
|
||||
return aURL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// XXXben - this is only useful if we ever support text/plain encoded forms in
|
||||
// smart keywords.
|
||||
function normalizePostData(aStringData)
|
||||
{
|
||||
var parts = aStringData.split("&");
|
||||
var result = "";
|
||||
for (var i = 0; i < parts.length; ++i) {
|
||||
var part = unescape(parts[i]);
|
||||
if (part != "")
|
||||
result += part + "\r\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
function getPostDataStream(aStringData, aKeyword, aType)
|
||||
{
|
||||
var dataStream = Components.classes["@mozilla.org/io/string-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIStringInputStream);
|
||||
aStringData = aStringData.replace(/%s/, aKeyword);
|
||||
dataStream.setData(aStringData, aStringData.length);
|
||||
|
||||
var mimeStream = Components.classes["@mozilla.org/network/mime-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIMIMEInputStream);
|
||||
mimeStream.addHeader("Content-Type", aType);
|
||||
mimeStream.addContentLength = true;
|
||||
mimeStream.setData(dataStream);
|
||||
return mimeStream.QueryInterface(Components.interfaces.nsIInputStream);
|
||||
}
|
||||
|
||||
|
||||
function readFromClipboard()
|
||||
{
|
||||
var url;
|
||||
|
@ -1293,7 +1335,8 @@ function handleURLBarRevert()
|
|||
|
||||
function handleURLBarCommand(aTriggeringEvent)
|
||||
{
|
||||
canonizeUrl(aTriggeringEvent);
|
||||
var postData = { };
|
||||
canonizeUrl(aTriggeringEvent, postData);
|
||||
|
||||
try {
|
||||
addToUrlbarHistory();
|
||||
|
@ -1302,10 +1345,10 @@ function handleURLBarCommand(aTriggeringEvent)
|
|||
// but don't let that interfere with the loading of the url.
|
||||
}
|
||||
|
||||
BrowserLoadURL(aTriggeringEvent);
|
||||
BrowserLoadURL(aTriggeringEvent, postData.value);
|
||||
}
|
||||
|
||||
function canonizeUrl(aTriggeringEvent)
|
||||
function canonizeUrl(aTriggeringEvent, aPostDataRef)
|
||||
{
|
||||
if (!gURLBar)
|
||||
return;
|
||||
|
@ -1329,7 +1372,7 @@ function canonizeUrl(aTriggeringEvent)
|
|||
url = "http://www." + url + ".net/";
|
||||
}
|
||||
|
||||
gURLBar.value = getShortcutOrURI(url);
|
||||
gURLBar.value = getShortcutOrURI(url, aPostDataRef);
|
||||
}
|
||||
|
||||
function UpdatePageProxyState()
|
||||
|
@ -1458,7 +1501,7 @@ function SearchBarPopupCommand(aEvent)
|
|||
|
||||
if (aEvent.target.id == "miAddEngines") {
|
||||
var regionBundle = document.getElementById("bundle_browser_region");
|
||||
loadURI(regionBundle.getString("searchEnginesURL"));
|
||||
loadURI(regionBundle.getString("searchEnginesURL"), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1789,7 @@ var goButtonObserver = {
|
|||
var xferData = aXferData.data.split("\n");
|
||||
var uri = xferData[0] ? xferData[0] : xferData[1];
|
||||
if (uri)
|
||||
loadURI(uri);
|
||||
loadURI(uri, null, null);
|
||||
},
|
||||
getSupportedFlavours: function ()
|
||||
{
|
||||
|
@ -1829,7 +1872,7 @@ function OpenSearch(tabName, searchStr, newTabFlag)
|
|||
//If it is a url go to URL. A Url is "://" or "." as commented above
|
||||
//Otherwise search on entry
|
||||
if (forceAsURL) {
|
||||
BrowserLoadURL()
|
||||
BrowserLoadURL(null, null)
|
||||
} else {
|
||||
if (searchStr) {
|
||||
var escapedSearchStr = encodeURIComponent(searchStr);
|
||||
|
@ -1854,7 +1897,7 @@ function OpenSearch(tabName, searchStr, newTabFlag)
|
|||
}
|
||||
|
||||
if (!newTabFlag) {
|
||||
loadURI(defaultSearchURL);
|
||||
loadURI(defaultSearchURL, null, null);
|
||||
}
|
||||
else {
|
||||
var newTab = getBrowser().addTab(defaultSearchURL);
|
||||
|
@ -3170,7 +3213,7 @@ nsContextMenu.prototype = {
|
|||
},
|
||||
// Open clicked-in frame in the same window
|
||||
showOnlyThisFrame : function () {
|
||||
window.loadURI(this.target.ownerDocument.location.href);
|
||||
window.loadURI(this.target.ownerDocument.location.href, null, null);
|
||||
},
|
||||
// View Partial Source
|
||||
viewPartialSource : function ( context ) {
|
||||
|
@ -3497,7 +3540,19 @@ nsContextMenu.prototype = {
|
|||
if (!form)
|
||||
return false;
|
||||
var method = form.method.toUpperCase();
|
||||
return (method == "GET" || method == "")
|
||||
|
||||
// These are the following types of forms we can create keywords for:
|
||||
//
|
||||
// method encoding type can create keyword
|
||||
// GET * YES
|
||||
// * YES
|
||||
// POST YES
|
||||
// POST application/x-www-form-urlencoded YES
|
||||
// POST text/plain NO (a little tricky to do)
|
||||
// POST multipart/form-data NO
|
||||
return (method == "GET" || method == "") ||
|
||||
(form.enctype == "application/x-www-form-urlencoded") ||
|
||||
(form.enctype == "");
|
||||
},
|
||||
|
||||
// Determines whether or not the separator with the specified ID should be
|
||||
|
@ -3603,11 +3658,12 @@ function asyncOpenWebPanel(event)
|
|||
{
|
||||
if (!linkNode.href) return true;
|
||||
if (linkNode.getAttribute("onclick")) return true;
|
||||
var url = getShortcutOrURI(linkNode.href);
|
||||
var postData = { };
|
||||
var url = getShortcutOrURI(linkNode.href, postData);
|
||||
if (!url)
|
||||
return true;
|
||||
markLinkVisited(linkNode.href, linkNode);
|
||||
loadURI(url);
|
||||
loadURI(url, null, postData.value);
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
@ -3709,7 +3765,8 @@ function middleMousePaste(event)
|
|||
var url = readFromClipboard();
|
||||
if (!url)
|
||||
return false;
|
||||
url = getShortcutOrURI(url);
|
||||
var postData = { };
|
||||
url = getShortcutOrURI(url, postData);
|
||||
if (!url)
|
||||
return false;
|
||||
|
||||
|
@ -3723,7 +3780,7 @@ function middleMousePaste(event)
|
|||
|
||||
if (!openNewTab) {
|
||||
// If ctrl wasn't down, then just load the url in the current win/tab.
|
||||
loadURI(url);
|
||||
loadURI(url, null, postData.value);
|
||||
} else {
|
||||
const nsIURIFixup = Components.interfaces.nsIURIFixup;
|
||||
if (!gURIFixup)
|
||||
|
@ -3732,7 +3789,7 @@ function middleMousePaste(event)
|
|||
|
||||
url = gURIFixup.createFixupURI(url, nsIURIFixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI).spec;
|
||||
|
||||
openNewTabWith(url, null, event, true);
|
||||
openNewTabWith(url, null, event, true, postData.value);
|
||||
}
|
||||
|
||||
event.preventBubble();
|
||||
|
@ -3797,7 +3854,9 @@ var contentAreaDNDObserver = {
|
|||
|
||||
switch (document.firstChild.getAttribute('windowtype')) {
|
||||
case "navigator:browser":
|
||||
loadURI(getShortcutOrURI(url));
|
||||
var postData = { };
|
||||
var uri = getShortcutOrURI(url, postData);
|
||||
loadURI(uri, null, postData.value);
|
||||
break;
|
||||
case "navigator:view-source":
|
||||
viewSource(url);
|
||||
|
@ -4455,18 +4514,39 @@ function AddKeywordForSearchField()
|
|||
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||
.getService(Components.interfaces.nsIURI);
|
||||
uri.spec = node.ownerDocument.URL;
|
||||
|
||||
var keywordURL = ioService.newURI(node.form.action, node.ownerDocument.characterSet, uri);
|
||||
var spec = keywordURL.spec;
|
||||
spec += "?" + escape(node.name) + "=%s";
|
||||
for (var i = 0; i < node.form.elements.length; ++i) {
|
||||
var e = node.form.elements[i];
|
||||
if (e.type.toLowerCase() == "text" || e.type.toLowerCase() == "hidden")
|
||||
spec += "&" + escape(e.name) + "=" + escape(e.value);
|
||||
var postData = "";
|
||||
|
||||
if (node.form.method.toUpperCase() == "POST" &&
|
||||
(node.form.enctype == "application/x-www-form-urlencoded" || node.form.enctype == "")) {
|
||||
for (var i = 0; i < node.form.elements.length; ++i) {
|
||||
var e = node.form.elements[i];
|
||||
if (e.type.toLowerCase() == "text" || e.type.toLowerCase() == "hidden" ||
|
||||
e.localName.toLowerCase() == "textarea")
|
||||
postData += escape(e.name + "=" + (e == node ? "%s" : e.value)) + "&";
|
||||
else if (e.localName.toLowerCase() == "select")
|
||||
postData += escape(e.name + "=" + e.options[e.selectedIndex].value) + "&";
|
||||
}
|
||||
}
|
||||
else {
|
||||
spec += "?" + escape(node.name) + "=%s";
|
||||
for (var i = 0; i < node.form.elements.length; ++i) {
|
||||
var e = node.form.elements[i];
|
||||
if (e == node) // avoid duplication of the target field value, which was populated above.
|
||||
continue;
|
||||
|
||||
if (e.type.toLowerCase() == "text" || e.type.toLowerCase() == "hidden" ||
|
||||
e.localName.toLowerCase() == "textarea")
|
||||
spec += "&" + escape(e.name) + "=" + escape(e.value);
|
||||
else if (e.localName.toLowerCase() == "select")
|
||||
spec += "&" + escape(e.name) + "=" + escape(e.options[e.selectedIndex].value);
|
||||
}
|
||||
}
|
||||
dump("*** SPEC = " + spec + "\n");
|
||||
openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
|
||||
"centerscreen,chrome,dialog,resizable,dependent",
|
||||
"", spec, null, node.ownerDocument.characterSet, null, null,
|
||||
false, "", true);
|
||||
false, "", true, postData);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* area.
|
||||
**/
|
||||
|
||||
function openNewTabWith(href, linkNode, event, securityCheck)
|
||||
function openNewTabWith(href, linkNode, event, securityCheck, postData)
|
||||
{
|
||||
if (securityCheck)
|
||||
urlSecurityCheck(href, document);
|
||||
|
@ -33,7 +33,7 @@ function openNewTabWith(href, linkNode, event, securityCheck)
|
|||
|
||||
// open link in new tab
|
||||
var browser = top.document.getElementById("content");
|
||||
var theTab = browser.addTab(href, getReferrer(document), originCharset);
|
||||
var theTab = browser.addTab(href, getReferrer(document), originCharset, postData);
|
||||
if (!loadInBackground)
|
||||
browser.selectedTab = theTab;
|
||||
|
||||
|
@ -41,7 +41,7 @@ function openNewTabWith(href, linkNode, event, securityCheck)
|
|||
markLinkVisited(href, linkNode);
|
||||
}
|
||||
|
||||
function openNewWindowWith(href, linkNode, securityCheck)
|
||||
function openNewWindowWith(href, linkNode, securityCheck, postData)
|
||||
{
|
||||
if (securityCheck)
|
||||
urlSecurityCheck(href, document);
|
||||
|
@ -55,7 +55,7 @@ function openNewWindowWith(href, linkNode, securityCheck)
|
|||
charsetArg = "charset=" + window._content.document.characterSet;
|
||||
|
||||
var referrer = getReferrer(document);
|
||||
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", href, charsetArg, referrer);
|
||||
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", href, charsetArg, referrer, postData);
|
||||
|
||||
if (linkNode)
|
||||
markLinkVisited(href, linkNode);
|
||||
|
|
|
@ -250,11 +250,11 @@ function onOK()
|
|||
for (var i = 0; i < groups.length; ++i) {
|
||||
url = getNormalizedURL(groups[i].url);
|
||||
BMDS.createBookmarkInContainer(groups[i].name, url, null, null,
|
||||
groups[i].charset, rSource, -1);
|
||||
groups[i].charset, null, rSource, -1);
|
||||
}
|
||||
} else {
|
||||
url = getNormalizedURL(gFld_URL.value);
|
||||
rSource = BMDS.createBookmark(gFld_Name.value, url, null, null, gBookmarkCharset, false);
|
||||
rSource = BMDS.createBookmark(gFld_Name.value, url, null, null, gBookmarkCharset, false, "");
|
||||
if (window.arguments.length > 4 && window.arguments[4] == "newBookmark") {
|
||||
window.arguments[5].newBookmark = rSource;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,9 @@
|
|||
* visible.
|
||||
* window.arguments[8]: Whether or not a keyword is required to add
|
||||
* the bookmark.
|
||||
* window.arguments[9]: PostData to be saved with this bookmark,
|
||||
* in the format a string of name=value pairs
|
||||
* separated by CRLFs.
|
||||
*/
|
||||
|
||||
var gSelectedFolder;
|
||||
|
@ -91,6 +94,7 @@ var gGroup;
|
|||
var gKeywordRequired;
|
||||
var gSuggestedKeyword;
|
||||
var gRequiredFields = [];
|
||||
var gPostData;
|
||||
|
||||
# on windows, sizeToContent is buggy (see bug 227951), we''ll use resizeTo
|
||||
# instead and cache the bookmarks tree view size.
|
||||
|
@ -121,6 +125,7 @@ function Startup()
|
|||
onFieldInput();
|
||||
gSelectedFolder = RDF.GetResource(gMenulist.selectedItem.id);
|
||||
gExpander.setAttribute("tooltiptext", gExpander.getAttribute("tooltiptextdown"));
|
||||
gPostData = window.arguments[9];
|
||||
|
||||
# read the persisted attribute. If it is not present, set a default height.
|
||||
WSucks = parseInt(gBookmarksTree.getAttribute("height"));
|
||||
|
@ -165,11 +170,11 @@ function onOK()
|
|||
for (var i = 0; i < groups.length; ++i) {
|
||||
url = getNormalizedURL(groups[i].url);
|
||||
BMDS.createBookmarkInContainer(groups[i].name, url, gKeyword.value, null,
|
||||
groups[i].charset, rSource, -1);
|
||||
groups[i].charset, gPostData, rSource, -1);
|
||||
}
|
||||
} else {
|
||||
url = getNormalizedURL(window.arguments[1]);
|
||||
rSource = BMDS.createBookmark(gName.value, url, gKeyword.value, null, window.arguments[3]);
|
||||
rSource = BMDS.createBookmark(gName.value, url, gKeyword.value, null, window.arguments[3], gPostData);
|
||||
}
|
||||
|
||||
var selection = BookmarksUtils.getSelectionFromResource(rSource);
|
||||
|
|
|
@ -480,7 +480,7 @@ var BookmarksCommand = {
|
|||
items = data.substring(0, ix != -1 ? ix : data.length);
|
||||
name = data.substring(ix);
|
||||
// XXX: we should infer the best charset
|
||||
BookmarksUtils.createBookmark(null, items, null, name);
|
||||
BookmarksUtils.createBookmark(null, items, null, name, null);
|
||||
items = [items];
|
||||
break;
|
||||
default:
|
||||
|
@ -644,7 +644,7 @@ var BookmarksCommand = {
|
|||
createNewBookmark: function (aTarget)
|
||||
{
|
||||
var name = BookmarksUtils.getLocaleString("ile_newbookmark");
|
||||
var resource = BMSVC.createBookmark(name, "", "", "", "");
|
||||
var resource = BMSVC.createBookmark(name, "", "", "", "", null);
|
||||
this.createNewResource(resource, aTarget, "newbookmark");
|
||||
},
|
||||
|
||||
|
@ -1295,7 +1295,7 @@ var BookmarksUtils = {
|
|||
break;
|
||||
case "text/x-moz-url":
|
||||
case "text/unicode":
|
||||
rSource = BookmarksUtils.createBookmark(null, uri, null, extra);
|
||||
rSource = BookmarksUtils.createBookmark(null, uri, null, extra, null);
|
||||
parent = null;
|
||||
break;
|
||||
}
|
||||
|
@ -1347,7 +1347,7 @@ var BookmarksUtils = {
|
|||
if (fw)
|
||||
aCharSet = fw.document.characterSet;
|
||||
}
|
||||
return BMSVC.createBookmark(aName, aURL, null, null, aCharSet);
|
||||
return BMSVC.createBookmark(aName, aURL, null, null, aCharSet, null);
|
||||
},
|
||||
|
||||
flushDataSource: function ()
|
||||
|
|
|
@ -65,12 +65,14 @@ interface nsIBookmarksService : nsISupports
|
|||
in wstring aURL,
|
||||
in wstring aShortcutURL,
|
||||
in wstring aDescription,
|
||||
in wstring aDocCharSet);
|
||||
in wstring aDocCharSet,
|
||||
in wstring aPostData);
|
||||
nsIRDFResource createBookmarkInContainer(in wstring aName,
|
||||
in wstring aURL,
|
||||
in wstring aShortcutURL,
|
||||
in wstring aDescription,
|
||||
in wstring aDocCharSet,
|
||||
in wstring aDocCharSet,
|
||||
in wstring aPostData,
|
||||
in nsIRDFResource aFolder,
|
||||
in long aIndex);
|
||||
|
||||
|
@ -88,7 +90,7 @@ interface nsIBookmarksService : nsISupports
|
|||
|
||||
void updateLastVisitedDate(in string aURL, in wstring docCharset);
|
||||
|
||||
string resolveKeyword(in wstring aName);
|
||||
string resolveKeyword(in wstring aName, out wstring aPostData);
|
||||
|
||||
void importSystemBookmarks(in nsIRDFResource aParentFolder);
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ nsBookmarkContentHandler.prototype = {
|
|||
var root = rdf.GetResource("NC:BookmarksRoot");
|
||||
// Append this bookmark to the end.
|
||||
var bmRes = bms.createBookmarkInContainer(bookmark.name, bookmark.url, bookmark.keyword,
|
||||
bookmark.description, bookmark.charset, root, -1);
|
||||
bookmark.description, bookmark.charset, root, -1, "");
|
||||
dump("*** bookmark =" + bookmark.toSource() + "\n");
|
||||
var ds = bms.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
if (bookmark.webpanel == "true") {
|
||||
|
|
|
@ -107,6 +107,7 @@ nsIRDFResource *kNC_BookmarksToolbarFolder;
|
|||
nsIRDFResource *kNC_ShortcutURL;
|
||||
nsIRDFResource *kNC_URL;
|
||||
nsIRDFResource *kNC_WebPanel;
|
||||
nsIRDFResource *kNC_PostData;
|
||||
nsIRDFResource *kRDF_type;
|
||||
nsIRDFResource *kRDF_nextVal;
|
||||
nsIRDFResource *kWEB_LastModifiedDate;
|
||||
|
@ -232,6 +233,8 @@ bm_AddRefGlobals()
|
|||
&kNC_URL);
|
||||
gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "WebPanel"),
|
||||
&kNC_WebPanel);
|
||||
gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "PostData"),
|
||||
&kNC_PostData);
|
||||
gRDF->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"),
|
||||
&kRDF_type);
|
||||
gRDF->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
|
||||
|
@ -329,6 +332,7 @@ bm_ReleaseGlobals()
|
|||
NS_IF_RELEASE(kNC_ShortcutURL);
|
||||
NS_IF_RELEASE(kNC_URL);
|
||||
NS_IF_RELEASE(kNC_WebPanel);
|
||||
NS_IF_RELEASE(kNC_PostData);
|
||||
NS_IF_RELEASE(kRDF_type);
|
||||
NS_IF_RELEASE(kRDF_nextVal);
|
||||
NS_IF_RELEASE(kWEB_LastModifiedDate);
|
||||
|
@ -549,6 +553,7 @@ static const char kLastCharsetEquals[] = "LAST_CHARSET=\"";
|
|||
static const char kShortcutURLEquals[] = "SHORTCUTURL=\"";
|
||||
static const char kIconEquals[] = "ICON=\"";
|
||||
static const char kWebPanelEquals[] = "WEB_PANEL=\"";
|
||||
static const char kPostDataEquals[] = "POST_DATA=\"";
|
||||
static const char kScheduleEquals[] = "SCHEDULE=\"";
|
||||
static const char kLastPingEquals[] = "LAST_PING=\"";
|
||||
static const char kPingETagEquals[] = "PING_ETAG=\"";
|
||||
|
@ -1036,6 +1041,7 @@ BookmarkParser::gBookmarkFieldTable[] =
|
|||
{ kShortcutURLEquals, NC_NAMESPACE_URI "ShortcutURL", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kIconEquals, NC_NAMESPACE_URI "Icon", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kWebPanelEquals, NC_NAMESPACE_URI "WebPanel", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kPostDataEquals, NC_NAMESPACE_URI "PostData", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kLastCharsetEquals, WEB_NAMESPACE_URI "LastCharset", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kScheduleEquals, WEB_NAMESPACE_URI "Schedule", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kLastPingEquals, WEB_NAMESPACE_URI "LastPingDate", nsnull, BookmarkParser::ParseDate, nsnull },
|
||||
|
@ -2519,6 +2525,7 @@ nsBookmarksService::CreateBookmark(const PRUnichar* aName,
|
|||
const PRUnichar* aShortcutURL,
|
||||
const PRUnichar* aDescription,
|
||||
const PRUnichar* aDocCharSet,
|
||||
const PRUnichar* aPostData,
|
||||
nsIRDFResource** aResult)
|
||||
{
|
||||
// Resource: Bookmark ID
|
||||
|
@ -2606,6 +2613,17 @@ nsBookmarksService::CreateBookmark(const PRUnichar* aName,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Literal: PostData associated with this bookmark (used for smart keywords)
|
||||
if (aPostData && *aPostData) {
|
||||
nsCOMPtr<nsIRDFLiteral> postDataLiteral;
|
||||
rv = gRDF->GetLiteral(aPostData, getter_AddRefs(postDataLiteral));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = mInner->Assert(bookmarkResource, kNC_PostData, postDataLiteral, PR_TRUE);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = bookmarkResource;
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
|
@ -2618,11 +2636,12 @@ nsBookmarksService::CreateBookmarkInContainer(const PRUnichar* aName,
|
|||
const PRUnichar* aShortcutURL,
|
||||
const PRUnichar* aDescription,
|
||||
const PRUnichar* aDocCharSet,
|
||||
const PRUnichar* aPostData,
|
||||
nsIRDFResource* aParentFolder,
|
||||
PRInt32 aIndex,
|
||||
nsIRDFResource** aResult)
|
||||
{
|
||||
nsresult rv = CreateBookmark(aName, aURL, aShortcutURL, aDescription, aDocCharSet, aResult);
|
||||
nsresult rv = CreateBookmark(aName, aURL, aShortcutURL, aDescription, aDocCharSet, aPostData, aResult);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = InsertResource(*aResult, aParentFolder, aIndex);
|
||||
return rv;
|
||||
|
@ -3070,7 +3089,7 @@ nsBookmarksService::UpdateBookmarkLastModifiedDate(nsIRDFResource *aSource)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::ResolveKeyword(const PRUnichar *aUserInput, char **aShortcutURL)
|
||||
nsBookmarksService::ResolveKeyword(const PRUnichar *aUserInput, PRUnichar** aPostData, char **aShortcutURL)
|
||||
{
|
||||
NS_PRECONDITION(aUserInput != nsnull, "null ptr");
|
||||
if (! aUserInput)
|
||||
|
@ -3097,6 +3116,19 @@ nsBookmarksService::ResolveKeyword(const PRUnichar *aUserInput, char **aShortcut
|
|||
return rv;
|
||||
|
||||
if (source) {
|
||||
// Get postData
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
GetTarget(source, kNC_PostData, PR_TRUE, getter_AddRefs(node));
|
||||
if (node) {
|
||||
nsCOMPtr<nsIRDFLiteral> postData(do_QueryInterface(node));
|
||||
|
||||
const PRUnichar* postDataVal = nsnull;
|
||||
postData->GetValueConst(&postDataVal);
|
||||
|
||||
nsDependentString postDataStr(postDataVal);
|
||||
*aPostData = ToNewUnicode(postDataStr);
|
||||
}
|
||||
|
||||
nsAutoString url;
|
||||
rv = GetURLFromResource(source, url);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -4686,6 +4718,10 @@ nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds,
|
|||
// output kNC_WebPanel
|
||||
rv |= WriteBookmarkProperties(ds, strm, child, kNC_WebPanel,
|
||||
kWebPanelEquals, PR_FALSE);
|
||||
|
||||
// output kNC_PostData
|
||||
rv |= WriteBookmarkProperties(ds, strm, child, kNC_PostData,
|
||||
kPostDataEquals, PR_FALSE);
|
||||
|
||||
// output SCHEDULE
|
||||
rv |= WriteBookmarkProperties(ds, strm, child, kWEB_Schedule, kScheduleEquals, PR_FALSE);
|
||||
|
@ -4979,6 +5015,7 @@ nsBookmarksService::CanAccept(nsIRDFResource* aSource,
|
|||
(aProperty == kNC_ShortcutURL) ||
|
||||
(aProperty == kNC_URL) ||
|
||||
(aProperty == kNC_WebPanel) ||
|
||||
(aProperty == kNC_PostData) ||
|
||||
(aProperty == kWEB_LastModifiedDate) ||
|
||||
(aProperty == kWEB_LastVisitDate) ||
|
||||
(aProperty == kNC_BookmarkAddDate) ||
|
||||
|
|
|
@ -1160,7 +1160,8 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
|
|||
NS_ConvertASCIItoUTF16(url).get(),
|
||||
keyword.get(),
|
||||
keywordDesc.get(),
|
||||
NS_LITERAL_STRING("").get(),
|
||||
nsnull,
|
||||
nsnull,
|
||||
keywordsFolder,
|
||||
-1,
|
||||
getter_AddRefs(bookmark));
|
||||
|
|
|
@ -1116,6 +1116,7 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
|
|||
NS_ConvertUTF8toUTF16(keyword).get(),
|
||||
keywordDesc.get(),
|
||||
nsnull,
|
||||
nsnull,
|
||||
keywordsFolder,
|
||||
-1,
|
||||
getter_AddRefs(itemRes));
|
||||
|
|
|
@ -706,6 +706,7 @@
|
|||
<parameter name="aURI"/>
|
||||
<parameter name="aReferrerURI"/>
|
||||
<parameter name="aCharset"/>
|
||||
<parameter name="aPostData"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var blank = (aURI == "about:blank");
|
||||
|
@ -762,9 +763,12 @@
|
|||
this.mTabListeners[position] = tabListener;
|
||||
this.mTabFilters[position] = filter;
|
||||
|
||||
if (!blank)
|
||||
if (!blank) {
|
||||
if (aPostData === undefined)
|
||||
aPostData = null;
|
||||
b.loadURIWithFlags(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
|
||||
aReferrerURI, null, null);
|
||||
aReferrerURI, aPostData, null);
|
||||
}
|
||||
|
||||
return t;
|
||||
]]>
|
||||
|
|
|
@ -145,8 +145,11 @@ nsExtensionManager.prototype = {
|
|||
var appVersion = pref.getCharPref(PREF_EM_APP_VERSION);
|
||||
|
||||
var extensions = this._ds.getExtensionList(aExtensionID);
|
||||
var updater = new nsExtensionUpdater(extensions, appID, appVersion);
|
||||
updater.checkForUpdates();
|
||||
var updater = new nsExtensionUpdater2(extensions, appID, appVersion);
|
||||
updater.loadSchema();
|
||||
|
||||
// var updater = new nsExtensionUpdater(extensions, appID, appVersion);
|
||||
// updater.checkForUpdates();
|
||||
},
|
||||
|
||||
// Themes
|
||||
|
@ -198,6 +201,112 @@ nsExtensionManager.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function nsExtensionUpdater2(aExtensions,
|
||||
aTargetAppID, aTargetAppVersion)
|
||||
{
|
||||
this._extensions = aExtensions;
|
||||
this._count = aExtensions.length;
|
||||
this._appID = aTargetAppID;
|
||||
this._appVersion = aTargetAppVersion;
|
||||
|
||||
this._os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
}
|
||||
|
||||
nsExtensionUpdater2.prototype = {
|
||||
_extensionSchemaType: null,
|
||||
loadSchema: function ()
|
||||
{
|
||||
function SchemaLoaderListener(aUpdater)
|
||||
{
|
||||
this._updater = aUpdater;
|
||||
}
|
||||
|
||||
SchemaLoaderListener.prototype = {
|
||||
onLoad: function (aSchema)
|
||||
{
|
||||
dump("*** schema loaded = " + aSchema + "\n");
|
||||
var count = aSchema.typeCount;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
var type = aSchema.getTypeByIndex(i);
|
||||
dump("*** schema type = " + type.name + "\n");
|
||||
}
|
||||
|
||||
this._updater._extensionSchemaType = aSchema.getTypeByName("Extension");
|
||||
|
||||
this._updater._schemaLoaded();
|
||||
},
|
||||
|
||||
onError: function (aStatus, aMessage)
|
||||
{
|
||||
dump("*** schema load error " + aStatus + ", msg = " + aMessage + "\n");
|
||||
}
|
||||
};
|
||||
|
||||
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
||||
.createInstance(Components.interfaces.nsISchemaLoader);
|
||||
var schemaLoaderListener = new SchemaLoaderListener(this);
|
||||
schemaLoader.loadAsync("http://www.bengoodger.com/software/mb/umo/types.xsd",
|
||||
schemaLoaderListener);
|
||||
},
|
||||
|
||||
_schemaLoaded: function ()
|
||||
{
|
||||
var call = Components.classes["@mozilla.org/xmlextras/soap/call;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPCall);
|
||||
call.transportURI = "http://localhost:8080/axis/services/VersionCheck";
|
||||
|
||||
for (var i = 0; i < this._extensions.length; ++i) {
|
||||
var e = this._extensions[i];
|
||||
|
||||
var params = [this._createParam("in0", e, this._extensionSchemaType),
|
||||
this._createParam("in1", this._appID, null),
|
||||
this._createParam("in2", this._appVersion, null)];
|
||||
call.encode(0, "getNewestExtension", "urn:VersionCheck", 0, null, params.length, params);
|
||||
var response = call.invoke();
|
||||
dump("*** response = " + response + "\n");
|
||||
var count = { };
|
||||
var params;
|
||||
response.getParameters(false, count, params);
|
||||
dump("*** params = " + count.value + "\n");
|
||||
for (var j = 0; j < count.value; ++j) {
|
||||
var param = params[j];
|
||||
dump("*** param = " + param.name + ", parm = " + param + ", element = " + param.element + ", value = " + param.value + "\n");
|
||||
// var v = param.value.QueryInterface(Components.interfaces.nsIVariant);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_walkKids: function (e)
|
||||
{
|
||||
for (var i = 0; i < e.childNodes.length; ++i) {
|
||||
var kid = e.childNodes[i];
|
||||
dump("<" + kid.nodeName);
|
||||
for (var k = 0; k < kid.attributes.length; ++k)
|
||||
dump(" " + kid.attributes[k] + "=" + kid.getAttribute(kid.attributes[k]));
|
||||
if (kid.hasChildNodes()) {
|
||||
this._walkKids(kid);
|
||||
dump("</" + kid.nodeName);
|
||||
}
|
||||
else
|
||||
dump(">");
|
||||
}
|
||||
},
|
||||
|
||||
_createParam: function (aParamName, aParamValue, aParamSchemaType)
|
||||
{
|
||||
var param = Components.classes["@mozilla.org/xmlextras/soap/parameter;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPParameter);
|
||||
param.name = aParamName;
|
||||
param.namespaceURI = "urn:VersionCheck";
|
||||
if (aParamSchemaType)
|
||||
param.schemaType = aParamSchemaType;
|
||||
param.value = aParamValue;
|
||||
return param;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
function nsExtensionUpdater(aExtensions,
|
||||
aTargetAppID, aTargetAppVersion)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче