mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 473045 - Update to nsIHandlerApp for win7 jump lists (plus tests). r=bz
This commit is contained in:
parent
a7ec56131c
commit
02bf065ee8
@ -242,7 +242,7 @@ interface nsIMIMEInfo : nsIHandlerInfo {
|
||||
* we should also try to make nsIWebContentHandlerInfo inherit from or possibly
|
||||
* be replaced by nsIWebHandlerApp (bug 394710).
|
||||
*/
|
||||
[scriptable, uuid(8d298761-0963-4c90-99e2-6ea498825e82)]
|
||||
[scriptable, uuid(8BDF20A4-9170-4548-AF52-78311A44F920)]
|
||||
interface nsIHandlerApp : nsISupports {
|
||||
|
||||
/**
|
||||
@ -250,12 +250,19 @@ interface nsIHandlerApp : nsISupports {
|
||||
*/
|
||||
attribute AString name;
|
||||
|
||||
/**
|
||||
* Detailed description for this handler. Suitable for
|
||||
* a tooltip or short informative sentence.
|
||||
*/
|
||||
attribute AString detailedDescription;
|
||||
|
||||
/**
|
||||
* Whether or not the given handler app is logically equivalent to the
|
||||
* invokant (i.e. they represent the same app).
|
||||
*
|
||||
* Two apps are the same if they are both either local or web handlers
|
||||
* and their executables/URI templates are the same in a string comparison.
|
||||
* and their executables/URI templates and command line parameters are
|
||||
* the same.
|
||||
*
|
||||
* @param aHandlerApp the handler app to compare to the invokant
|
||||
*
|
||||
@ -289,13 +296,52 @@ interface nsIHandlerApp : nsISupports {
|
||||
/**
|
||||
* nsILocalHandlerApp is a local OS-level executable
|
||||
*/
|
||||
[scriptable, uuid(9812be73-273c-478c-8170-c3e0db08ae7c)]
|
||||
[scriptable, uuid(D36B6329-52AE-4f45-80F4-B2536AE5F8B2)]
|
||||
interface nsILocalHandlerApp : nsIHandlerApp {
|
||||
|
||||
/**
|
||||
* Pointer to the executable file used to handle content
|
||||
*/
|
||||
attribute nsIFile executable;
|
||||
|
||||
/**
|
||||
* Returns the current number of command line parameters.
|
||||
*/
|
||||
readonly attribute unsigned long parameterCount;
|
||||
|
||||
/**
|
||||
* Clears the current list of command line parameters.
|
||||
*/
|
||||
void clearParameters();
|
||||
|
||||
/**
|
||||
* Appends a command line parameter to the command line
|
||||
* parameter list.
|
||||
*
|
||||
* @param param the parameter to add.
|
||||
*/
|
||||
void appendParameter(in AString param);
|
||||
|
||||
/**
|
||||
* Retrieves a specific command line parameter.
|
||||
*
|
||||
* @param param the index of the parameter to return.
|
||||
*
|
||||
* @return the parameter string.
|
||||
*
|
||||
* @throw NS_ERROR_INVALID_ARG if the index is out of range.
|
||||
*/
|
||||
AString getParameter(in unsigned long parameterIndex);
|
||||
|
||||
/**
|
||||
* Checks to see if a parameter exists in the command line
|
||||
* parameter list.
|
||||
*
|
||||
* @param param the parameter to search for.
|
||||
*
|
||||
* @return TRUE if the parameter exists in the current list.
|
||||
*/
|
||||
boolean parameterExists(in AString param);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -73,6 +73,20 @@ NS_IMETHODIMP nsDBusHandlerApp::SetName(const nsAString & aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDBusHandlerApp::SetDetailedDescription(const nsAString & aDescription)
|
||||
{
|
||||
mDetailedDescription.Assign(aDescription);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDBusHandlerApp::GetDetailedDescription(nsAString& aDescription)
|
||||
{
|
||||
aDescription.Assign(mDetailedDescription);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDBusHandlerApp::Equals(nsIHandlerApp *aHandlerApp, PRBool *_retval)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsString mDetailedDescription;
|
||||
nsCString mService;
|
||||
nsCString mMethod;
|
||||
nsCString mInterface;
|
||||
|
@ -69,27 +69,65 @@ NS_IMETHODIMP nsLocalHandlerApp::SetName(const nsAString & aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::SetDetailedDescription(const nsAString & aDescription)
|
||||
{
|
||||
mDetailedDescription.Assign(aDescription);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::GetDetailedDescription(nsAString& aDescription)
|
||||
{
|
||||
aDescription.Assign(mDetailedDescription);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::Equals(nsIHandlerApp *aHandlerApp, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHandlerApp);
|
||||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
// If the handler app isn't a local handler app, then it's not the same app.
|
||||
nsCOMPtr <nsILocalHandlerApp> localHandlerApp = do_QueryInterface(aHandlerApp);
|
||||
if (!localHandlerApp) {
|
||||
*_retval = PR_FALSE;
|
||||
if (!localHandlerApp)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If either handler app doesn't have an executable, then they aren't
|
||||
// the same app.
|
||||
nsCOMPtr<nsIFile> executable;
|
||||
nsresult rv = localHandlerApp->GetExecutable(getter_AddRefs(executable));
|
||||
if (NS_FAILED(rv) || !executable || !mExecutable) {
|
||||
*_retval = PR_FALSE;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Equality for two empty nsIHandlerApp
|
||||
if (!executable && !mExecutable) {
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// At least one is set so they are not equal
|
||||
if (!mExecutable || !executable)
|
||||
return NS_OK;
|
||||
|
||||
// Check the command line parameter list lengths
|
||||
PRUint32 len;
|
||||
localHandlerApp->GetParameterCount(&len);
|
||||
if (mParameters.Length() != len)
|
||||
return NS_OK;
|
||||
|
||||
// Check the command line params lists
|
||||
for (PRUint32 idx = 0; idx < mParameters.Length(); idx++) {
|
||||
nsAutoString param;
|
||||
if (NS_FAILED(localHandlerApp->GetParameter(idx, param)) ||
|
||||
!param.Equals(mParameters[idx]))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return executable->Equals(mExecutable, _retval);
|
||||
}
|
||||
|
||||
@ -122,15 +160,60 @@ nsLocalHandlerApp::LaunchWithIProcess(const nsCString& aArg)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// nsILocalHandlerApp
|
||||
|
||||
NS_IMETHODIMP nsLocalHandlerApp::GetExecutable(nsIFile **aExecutable)
|
||||
/* attribute nsIFile executable; */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::GetExecutable(nsIFile **aExecutable)
|
||||
{
|
||||
NS_IF_ADDREF(*aExecutable = mExecutable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLocalHandlerApp::SetExecutable(nsIFile *aExecutable)
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::SetExecutable(nsIFile *aExecutable)
|
||||
{
|
||||
mExecutable = aExecutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long parameterCount; */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::GetParameterCount(PRUint32 *aParameterCount)
|
||||
{
|
||||
*aParameterCount = mParameters.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clearParameters (); */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::ClearParameters()
|
||||
{
|
||||
mParameters.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void appendParameter (in AString param); */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::AppendParameter(const nsAString & aParam)
|
||||
{
|
||||
mParameters.AppendElement(aParam);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* AString getParameter (in unsigned long parameterIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::GetParameter(PRUint32 parameterIndex, nsAString & _retval)
|
||||
{
|
||||
if (mParameters.Length() <= parameterIndex)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
_retval.Assign(mParameters[parameterIndex]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean parameterExists (in AString param); */
|
||||
NS_IMETHODIMP
|
||||
nsLocalHandlerApp::ParameterExists(const nsAString & aParam, PRBool *_retval)
|
||||
{
|
||||
*_retval = mParameters.Contains(aParam);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsLocalHandlerApp : public nsILocalHandlerApp
|
||||
{
|
||||
@ -62,6 +63,8 @@ public:
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsString mDetailedDescription;
|
||||
nsTArray<nsString> mParameters;
|
||||
nsCOMPtr<nsIFile> mExecutable;
|
||||
|
||||
/**
|
||||
@ -72,8 +75,7 @@ protected:
|
||||
* @param aApp The application to launch (may not be null)
|
||||
* @param aArg The argument to pass on the command line
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) LaunchWithIProcess(const nsCString &aArg);
|
||||
|
||||
NS_HIDDEN_(nsresult) LaunchWithIProcess(const nsCString &aArg);
|
||||
};
|
||||
|
||||
// any platforms that need a platform-specific class instead of just
|
||||
|
@ -60,6 +60,7 @@ nsWebHandlerApp.prototype = {
|
||||
contractID: "@mozilla.org/uriloader/web-handler-app;1",
|
||||
|
||||
_name: null,
|
||||
_detailedDescription: null,
|
||||
_uriTemplate: null,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -73,6 +74,14 @@ nsWebHandlerApp.prototype = {
|
||||
this._name = aName;
|
||||
},
|
||||
|
||||
get detailedDescription() {
|
||||
return this._detailedDescription;
|
||||
},
|
||||
|
||||
set detailedDescription(aDesc) {
|
||||
this._detailedDescription = aDesc;
|
||||
},
|
||||
|
||||
equals: function(aHandlerApp) {
|
||||
if (!aHandlerApp)
|
||||
throw Cr.NS_ERROR_NULL_POINTER;
|
||||
|
@ -342,6 +342,70 @@ function run_test() {
|
||||
do_check_eq(webPossibleHandler.name, webHandler.name);
|
||||
do_check_true(webPossibleHandler.equals(webHandler));
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// handler info command line parameters and equality
|
||||
var localApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Ci.nsILocalHandlerApp);
|
||||
var handlerApp = localApp.QueryInterface(Ci.nsIHandlerApp);
|
||||
|
||||
do_check_true(handlerApp.equals(localApp));
|
||||
|
||||
localApp.executable = executable;
|
||||
|
||||
do_check_eq(0, localApp.parameterCount);
|
||||
localApp.appendParameter("-test1");
|
||||
do_check_eq(1, localApp.parameterCount);
|
||||
localApp.appendParameter("-test2");
|
||||
do_check_eq(2, localApp.parameterCount);
|
||||
do_check_true(localApp.parameterExists("-test1"));
|
||||
do_check_true(localApp.parameterExists("-test2"));
|
||||
do_check_false(localApp.parameterExists("-false"));
|
||||
localApp.clearParameters();
|
||||
do_check_eq(0, localApp.parameterCount);
|
||||
|
||||
var localApp2 = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Ci.nsILocalHandlerApp);
|
||||
|
||||
localApp2.executable = executable;
|
||||
|
||||
localApp.clearParameters();
|
||||
do_check_true(localApp.equals(localApp2));
|
||||
|
||||
// equal:
|
||||
// cut -d 1 -f 2
|
||||
// cut -d 1 -f 2
|
||||
|
||||
localApp.appendParameter("-test1");
|
||||
localApp.appendParameter("-test2");
|
||||
localApp.appendParameter("-test3");
|
||||
localApp2.appendParameter("-test1");
|
||||
localApp2.appendParameter("-test2");
|
||||
localApp2.appendParameter("-test3");
|
||||
do_check_true(localApp.equals(localApp2));
|
||||
|
||||
// not equal:
|
||||
// cut -d 1 -f 2
|
||||
// cut -f 1 -d 2
|
||||
|
||||
localApp.clearParameters();
|
||||
localApp2.clearParameters();
|
||||
|
||||
localApp.appendParameter("-test1");
|
||||
localApp.appendParameter("-test2");
|
||||
localApp.appendParameter("-test3");
|
||||
localApp2.appendParameter("-test2");
|
||||
localApp2.appendParameter("-test1");
|
||||
localApp2.appendParameter("-test3");
|
||||
do_check_false(localApp2.equals(localApp));
|
||||
|
||||
var str;
|
||||
str = localApp.getParameter(0)
|
||||
do_check_eq(str, "-test1");
|
||||
str = localApp.getParameter(1)
|
||||
do_check_eq(str, "-test2");
|
||||
str = localApp.getParameter(2)
|
||||
do_check_eq(str, "-test3");
|
||||
|
||||
// FIXME: test round trip integrity for a protocol.
|
||||
// FIXME: test round trip integrity for a handler info with a web handler.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user