Bug 890690 - Add postDataString property to nsISearchSubmission. r=gavin

--HG--
extra : transplant_source : %F8%86%BD%9A%0Bt%95%F8%DC%E5%FA%BD%C8%3BP%87%A1%CB/%95
This commit is contained in:
Mike de Boer 2013-07-19 19:56:38 +02:00
Родитель 0613309e46
Коммит d3a98caab4
2 изменённых файлов: 17 добавлений и 6 удалений

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

@ -7,7 +7,7 @@
interface nsIURI;
interface nsIInputStream;
[scriptable, uuid(58e4f602-a7c8-4cd1-9dca-716705e826ef)]
[scriptable, uuid(82ec6ee8-68b5-49ef-87b7-0d5240f8a183)]
interface nsISearchSubmission : nsISupports
{
/**
@ -16,6 +16,12 @@ interface nsISearchSubmission : nsISupports
*/
readonly attribute nsIInputStream postData;
/**
* The POST data associated with a search submission as an
* application/x-www-form-urlencoded string. May be null.
*/
readonly attribute AString postDataString;
/**
* The URI to submit a search to.
*/

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

@ -931,6 +931,7 @@ EngineURL.prototype = {
}
var postData = null;
let postDataString = null;
if (this.method == "GET") {
// GET method requests have no post data, and append the encoded
// query string to the url...
@ -938,8 +939,8 @@ EngineURL.prototype = {
url += "?";
url += dataString;
} else if (this.method == "POST") {
// POST method requests must wrap the encoded text in a MIME
// stream and supply that as POSTDATA.
// For POST requests, specify the data as a MIME stream as well as a string.
postDataString = dataString;
var stringStream = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsIStringInputStream);
stringStream.data = dataString;
@ -951,7 +952,7 @@ EngineURL.prototype = {
postData.setData(stringStream);
}
return new Submission(makeURI(url), postData);
return new Submission(makeURI(url), postData, postDataString);
},
_hasRelation: function SRC_EURL__hasRelation(aRel)
@ -2543,7 +2544,7 @@ Engine.prototype = {
if (!aData) {
// Return a dummy submission object with our searchForm attribute
return new Submission(makeURI(this.searchForm), null);
return new Submission(makeURI(this.searchForm));
}
LOG("getSubmission: In data: \"" + aData + "\"; Purpose: \"" + aPurpose + "\"");
@ -2580,9 +2581,10 @@ Engine.prototype = {
};
// nsISearchSubmission
function Submission(aURI, aPostData) {
function Submission(aURI, aPostData = null, aPostDataString = null) {
this._uri = aURI;
this._postData = aPostData;
this._postDataString = aPostDataString;
}
Submission.prototype = {
get uri() {
@ -2591,6 +2593,9 @@ Submission.prototype = {
get postData() {
return this._postData;
},
get postDataString() {
return this._postDataString;
},
QueryInterface: function SRCH_SUBM_QI(aIID) {
if (aIID.equals(Ci.nsISearchSubmission) ||
aIID.equals(Ci.nsISupports))