зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 52827. Getting the parent window and passing it to the alert and confirm dialogs. r=dveditz, law a=law (I used the old appproval list).
This commit is contained in:
Родитель
87fc282f05
Коммит
cecb8d2d14
|
@ -35,6 +35,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#define NS_IXPINSTALLCOMPONENT_CONTRACTID NS_IAPPSHELLCOMPONENT_CONTRACTID "/xpinstall;1"
|
||||
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
|
||||
|
@ -64,6 +65,7 @@ class nsISoftwareUpdate : public nsISupports
|
|||
NS_IMETHOD InstallJar(nsIFile* localFile,
|
||||
const PRUnichar* URL,
|
||||
const PRUnichar* arguments,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
PRUint32 flags,
|
||||
nsIXPIListener* aListener = 0) = 0;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsProxiedService.h"
|
||||
#include "nsINetSupportDialogService.h"
|
||||
#include "nsICommonDialogs.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
@ -84,7 +84,7 @@
|
|||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID);
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
|
||||
|
@ -97,6 +97,7 @@ nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
|
|||
const PRUnichar* aArgs,
|
||||
PRUint32 flags,
|
||||
nsIXPIListener* aListener,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
nsIChromeRegistry* aChromeReg)
|
||||
: mError(0),
|
||||
mType(aInstallType),
|
||||
|
@ -105,6 +106,7 @@ nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
|
|||
mArgs(aArgs),
|
||||
mFile(aFile),
|
||||
mListener(aListener),
|
||||
mParent(aParentWindow),
|
||||
mChromeReg(aChromeReg)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsInstallInfo);
|
||||
|
@ -2401,13 +2403,13 @@ void nsInstall::SetInstallURL(const nsString& url) { mInstallURL = url; }
|
|||
PRInt32
|
||||
nsInstall::Alert(nsString& string)
|
||||
{
|
||||
nsresult res;
|
||||
nsresult res;
|
||||
|
||||
NS_WITH_PROXIED_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, NS_UI_THREAD_EVENTQ, &res);
|
||||
NS_WITH_PROXIED_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, NS_UI_THREAD_EVENTQ, &res);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
return dialog->Alert(nsnull, string.GetUnicode());
|
||||
|
||||
return dialog->Alert(mParent, nsnull, string.GetUnicode());
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -2416,11 +2418,11 @@ nsInstall::Confirm(nsString& string, PRBool* aReturn)
|
|||
*aReturn = PR_FALSE; /* default value */
|
||||
|
||||
nsresult res;
|
||||
NS_WITH_PROXIED_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, NS_UI_THREAD_EVENTQ, &res);
|
||||
NS_WITH_PROXIED_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, NS_UI_THREAD_EVENTQ, &res);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
return dialog->Confirm(nsnull, string.GetUnicode(), aReturn);
|
||||
return dialog->Confirm(mParent, nsnull, string.GetUnicode(), aReturn);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ class nsInstallInfo
|
|||
const PRUnichar* aArgs,
|
||||
PRUint32 aFlags,
|
||||
nsIXPIListener* aListener,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
nsIChromeRegistry* aChromeReg);
|
||||
|
||||
virtual ~nsInstallInfo();
|
||||
|
@ -82,6 +83,7 @@ class nsInstallInfo
|
|||
PRUint32 GetType() { return mType; }
|
||||
nsIXPIListener* GetListener() { return mListener.get(); }
|
||||
nsIChromeRegistry* GetChromeRegistry() { return mChromeReg.get(); }
|
||||
nsIDOMWindowInternal* GetParentDOMWindow() { return mParent.get(); }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -94,6 +96,7 @@ class nsInstallInfo
|
|||
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
nsCOMPtr<nsIXPIListener> mListener;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mParent;
|
||||
nsCOMPtr<nsIChromeRegistry> mChromeReg;
|
||||
};
|
||||
|
||||
|
@ -277,6 +280,10 @@ class nsInstall
|
|||
void SetChromeRegistry(nsIChromeRegistry* reg)
|
||||
{ mChromeRegistry = reg; }
|
||||
|
||||
nsIDOMWindowInternal* GetParentDOMWindow() { return mParent; }
|
||||
void SetParentDOMWindow(nsIDOMWindowInternal* parent)
|
||||
{ mParent = parent; }
|
||||
|
||||
PRBool GetStatusSent() { return mStatusSent; }
|
||||
PRBool InInstallTransaction(void) { return mInstalledFiles != nsnull; }
|
||||
|
||||
|
@ -302,6 +309,7 @@ class nsInstall
|
|||
nsString mInstallURL;
|
||||
PRUint32 mInstallFlags;
|
||||
nsIChromeRegistry* mChromeRegistry; // we don't own it, it outlives us
|
||||
nsIDOMWindowInternal* mParent;
|
||||
nsInstallFolder* mPackageFolder;
|
||||
|
||||
PRBool mUserCancelled;
|
||||
|
|
|
@ -1930,6 +1930,7 @@ JSObject * InitXPInstallObjects(JSContext *jscontext,
|
|||
const PRUnichar* args,
|
||||
PRUint32 flags,
|
||||
nsIChromeRegistry* reg,
|
||||
nsIDOMWindowInternal* aParent,
|
||||
nsIZipReader * theJARFile)
|
||||
{
|
||||
JSObject *installObject = nsnull;
|
||||
|
@ -1968,6 +1969,7 @@ JSObject * InitXPInstallObjects(JSContext *jscontext,
|
|||
nativeInstallObject->SetInstallURL(nsAutoString(url));
|
||||
nativeInstallObject->SetInstallFlags(flags);
|
||||
nativeInstallObject->SetChromeRegistry(reg);
|
||||
nativeInstallObject->SetParentDOMWindow(aParent);
|
||||
|
||||
JS_SetPrivate(jscontext, installObject, nativeInstallObject);
|
||||
nativeInstallObject->SetScriptObject(installObject);
|
||||
|
|
|
@ -309,6 +309,7 @@ NS_IMETHODIMP
|
|||
nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
|
||||
const PRUnichar* aURL,
|
||||
const PRUnichar* aArguments,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
PRUint32 flags,
|
||||
nsIXPIListener* aListener)
|
||||
{
|
||||
|
@ -327,7 +328,7 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
|
|||
|
||||
// we want to call this with or without a chrome registry
|
||||
nsInstallInfo *info = new nsInstallInfo( 0, aLocalFile, aURL, aArguments,
|
||||
flags, aListener, chromeReg );
|
||||
flags, aListener, aParentWindow, chromeReg );
|
||||
|
||||
if (!info)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -363,6 +364,7 @@ nsSoftwareUpdate::InstallChrome( PRUint32 aType,
|
|||
aName,
|
||||
(PRUint32)aSelect,
|
||||
aListener,
|
||||
nsnull,
|
||||
chromeReg);
|
||||
if (!info)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -19,6 +19,7 @@ class nsInstallInfo;
|
|||
|
||||
#include "nsIScriptExternalNameSet.h"
|
||||
#include "nsIAppShellComponent.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsPIXPIStubHook.h"
|
||||
#include "nsTopProgressNotifier.h"
|
||||
|
||||
|
@ -58,6 +59,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
|
|||
NS_IMETHOD InstallJar( nsIFile* localFile,
|
||||
const PRUnichar* URL,
|
||||
const PRUnichar* arguments,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
PRUint32 flags = 0,
|
||||
nsIXPIListener* aListener = 0);
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@
|
|||
static NS_DEFINE_CID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, nsIFile* jarfile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, nsIChromeRegistry* reg, nsIZipReader* hZip);
|
||||
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, nsIFile* jarfile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, nsIChromeRegistry* reg, nsIDOMWindowInternal* aParent, nsIZipReader* hZip);
|
||||
extern nsresult InitInstallVersionClass(JSContext *jscontext, JSObject *global, void** prototype);
|
||||
extern nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype);
|
||||
|
||||
// Defined in this file:
|
||||
PR_STATIC_CALLBACK(void) XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
static PRInt32 GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, char** scriptBuffer, PRUint32 *scriptLength);
|
||||
static nsresult SetupInstallContext(nsIZipReader* hZip, nsIFile* jarFile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, nsIChromeRegistry* reg, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
|
||||
static nsresult SetupInstallContext(nsIZipReader* hZip, nsIFile* jarFile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, nsIChromeRegistry* reg, nsIDOMWindowInternal* aParent, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
|
||||
|
||||
extern "C" void RunInstallOnThread(void *data);
|
||||
|
||||
|
@ -259,6 +259,7 @@ static nsresult SetupInstallContext(nsIZipReader* hZip,
|
|||
const PRUnichar* args,
|
||||
PRUint32 flags,
|
||||
nsIChromeRegistry* reg,
|
||||
nsIDOMWindowInternal* aParent,
|
||||
JSRuntime *rt,
|
||||
JSContext **jsCX,
|
||||
JSObject **jsGlob)
|
||||
|
@ -281,7 +282,7 @@ static nsresult SetupInstallContext(nsIZipReader* hZip,
|
|||
JS_SetErrorReporter(cx, XPInstallErrorReporter);
|
||||
|
||||
|
||||
glob = InitXPInstallObjects(cx, nsnull, jarFile, url, args, flags, reg, hZip);
|
||||
glob = InitXPInstallObjects(cx, nsnull, jarFile, url, args, flags, reg, aParent, hZip);
|
||||
// Init standard classes
|
||||
JS_InitStandardClasses(cx, glob);
|
||||
|
||||
|
@ -409,6 +410,7 @@ extern "C" void RunInstallOnThread(void *data)
|
|||
installInfo->GetArguments(),
|
||||
installInfo->GetFlags(),
|
||||
installInfo->GetChromeRegistry(),
|
||||
installInfo->GetParentDOMWindow(),
|
||||
rt, &cx, &glob);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -373,8 +373,10 @@ PRBool nsXPInstallManager::ConfirmChromeInstall(nsIScriptGlobalObject* aGlobalOb
|
|||
NS_IMETHODIMP nsXPInstallManager::DialogOpened(nsISupports* aWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMWindowInternal> win = do_QueryInterface(aWindow, &rv);
|
||||
|
||||
mParentWindow = do_QueryInterface(aWindow, &rv);
|
||||
DownloadNext();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -490,6 +492,7 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
|
|||
rv = softupdate->InstallJar(mItem->mFile,
|
||||
mItem->mURL.GetUnicode(),
|
||||
mItem->mArguments.GetUnicode(),
|
||||
mParentWindow,
|
||||
mItem->mFlags,
|
||||
this );
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ class nsXPInstallManager : public nsIXPIListener,
|
|||
PRTime mLastUpdate;
|
||||
|
||||
nsCOMPtr<nsIXPIProgressDlg> mDlg;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mParentWindow;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
};
|
||||
|
||||
|
|
|
@ -271,8 +271,12 @@ PR_PUBLIC_API(PRInt32) XPI_Install(
|
|||
#endif
|
||||
|
||||
if (iFile && gXPI)
|
||||
rv = gXPI->InstallJar( iFile, URLstr.GetUnicode(), args.GetUnicode(),
|
||||
(aFlags | XPI_NO_NEW_THREAD), gListener );
|
||||
rv = gXPI->InstallJar( iFile,
|
||||
URLstr.GetUnicode(),
|
||||
args.GetUnicode(),
|
||||
nsnull,
|
||||
(aFlags | XPI_NO_NEW_THREAD),
|
||||
gListener );
|
||||
|
||||
return gInstallStatus;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче