diff --git a/security/manager/pki/resources/content/createCertInfo.js b/security/manager/pki/resources/content/createCertInfo.js index f8a6528a556e..650385da5dfc 100644 --- a/security/manager/pki/resources/content/createCertInfo.js +++ b/security/manager/pki/resources/content/createCertInfo.js @@ -48,8 +48,15 @@ function onLoad() } setCursor("wait"); + + var obs = { + observe : function keygenListenerObserve(subject, topic, data) { + if (topic == "keygen-finished") + window.close(); + } + }; - keygenThread.startKeyGeneration(window); + keygenThread.startKeyGeneration(obs); } function onClose() diff --git a/security/manager/ssl/public/nsIGenKeypairInfoDlg.idl b/security/manager/ssl/public/nsIGenKeypairInfoDlg.idl index 5fa51bf3a93e..5dddd39416a1 100644 --- a/security/manager/ssl/public/nsIGenKeypairInfoDlg.idl +++ b/security/manager/ssl/public/nsIGenKeypairInfoDlg.idl @@ -52,5 +52,15 @@ interface nsIGeneratingKeypairInfoDialogs : nsISupports }; %{C++ -#define NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID "@mozilla.org/nsGeneratingKeypairInfoDialogs;1" +/** + * This component is to be implemented by the embeddor. It is used to show + * feedback to the user while a private key is being generated. + * + * This component is only ever used on the UI thread. + * + * INTERFACES THAT NEED TO BE IMPLEMENTED: + * nsIGeneratingKeypairInfoDialogs + */ +#define NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID \ + "@mozilla.org/nsGeneratingKeypairInfoDialogs;1" %} diff --git a/security/manager/ssl/public/nsIKeygenThread.idl b/security/manager/ssl/public/nsIKeygenThread.idl index 73f60e2eb58d..d7ca557832c3 100644 --- a/security/manager/ssl/public/nsIKeygenThread.idl +++ b/security/manager/ssl/public/nsIKeygenThread.idl @@ -38,25 +38,30 @@ #include "nsISupports.idl" -interface nsIDOMWindowInternal; +interface nsIObserver; /** * nsIKeygenThread * This is used to communicate with the thread generating a key pair, * to be used by the dialog displaying status information. */ -[scriptable, uuid(195763b8-1dd2-11b2-a843-eb44e44aaa37)] +[scriptable, uuid(8712a243-5539-447c-9f47-8653f40c3a09)] interface nsIKeygenThread : nsISupports { /** * startKeyGeneration - run the thread - * A user interface implementing this interface needs to + * A user interface using this interface needs to * call this method as soon as the status information * is displaying. This will trigger key generation. * To allow the closure of the status information, - * the thread needs a handle to the displayed window. + * the thread needs a handle to an observer. + * + * observer will be called on the UI thread. + * When the key generation is done, the observe method will + * be called with a topic of "keygen-finished" and null data + * and subject. */ - void startKeyGeneration(in nsIDOMWindowInternal statusDialog); + void startKeyGeneration(in nsIObserver observer); /** * userCanceled - notify the thread diff --git a/security/manager/ssl/src/nsKeygenThread.cpp b/security/manager/ssl/src/nsKeygenThread.cpp index e2af8ca2fafd..cbaa15417804 100644 --- a/security/manager/ssl/src/nsKeygenThread.cpp +++ b/security/manager/ssl/src/nsKeygenThread.cpp @@ -40,7 +40,7 @@ #include "nsCOMPtr.h" #include "nsProxiedService.h" #include "nsKeygenThread.h" -#include "nsIDOMWindowInternal.h" +#include "nsIObserver.h" #include "nsNSSShutDown.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsKeygenThread, nsIKeygenThread) @@ -48,7 +48,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsKeygenThread, nsIKeygenThread) nsKeygenThread::nsKeygenThread() :mutex(nsnull), - statusDialogPtr(nsnull), iAmRunning(PR_FALSE), keygenReady(PR_FALSE), statusDialogClosed(PR_FALSE), @@ -71,10 +70,6 @@ nsKeygenThread::~nsKeygenThread() if (mutex) { PR_DestroyLock(mutex); } - - if (statusDialogPtr) { - NS_RELEASE(statusDialogPtr); - } } void nsKeygenThread::SetParams( @@ -146,24 +141,24 @@ static void PR_CALLBACK nsKeygenThreadRunner(void *arg) self->Run(); } -nsresult nsKeygenThread::StartKeyGeneration(nsIDOMWindowInternal *statusDialog) +nsresult nsKeygenThread::StartKeyGeneration(nsIObserver* aObserver) { if (!mutex) return NS_OK; - if (!statusDialog ) + if (!aObserver) return NS_OK; nsCOMPtr proxyman(do_GetService(NS_XPCOMPROXY_CONTRACTID)); if (!proxyman) return NS_OK; - nsCOMPtr wi; + nsCOMPtr obs; proxyman->GetProxyForObject( NS_UI_THREAD_EVENTQ, - nsIDOMWindowInternal::GetIID(), - statusDialog, + NS_GET_IID(nsIObserver), + aObserver, PROXY_SYNC | PROXY_ALWAYS, - getter_AddRefs(wi)); + getter_AddRefs(obs)); PR_Lock(mutex); @@ -172,9 +167,7 @@ nsresult nsKeygenThread::StartKeyGeneration(nsIDOMWindowInternal *statusDialog) return NS_OK; } - statusDialogPtr = wi; - NS_ADDREF(statusDialogPtr); - wi = 0; + observer.swap(obs); iAmRunning = PR_TRUE; @@ -238,8 +231,7 @@ void nsKeygenThread::Run(void) // As long as key generation can't be canceled, we don't need // to care for cleaning this up. - nsIDOMWindowInternal *windowToClose = 0; - + nsCOMPtr obs; PR_Lock(mutex); keygenReady = PR_TRUE; @@ -255,15 +247,14 @@ void nsKeygenThread::Run(void) wincx = 0; if (!statusDialogClosed) - windowToClose = statusDialogPtr; + obs = observer; - statusDialogPtr = 0; - statusDialogClosed = PR_TRUE; + observer = nsnull; PR_Unlock(mutex); - if (windowToClose) - windowToClose->Close(); + if (obs) + obs->Observe(nsnull, "keygen-finished", nsnull); } void nsKeygenThread::Join() diff --git a/security/manager/ssl/src/nsKeygenThread.h b/security/manager/ssl/src/nsKeygenThread.h index cc512ac00883..93860e4b70df 100644 --- a/security/manager/ssl/src/nsKeygenThread.h +++ b/security/manager/ssl/src/nsKeygenThread.h @@ -43,13 +43,16 @@ #include "nspr.h" #include "nsIKeygenThread.h" +#include "nsCOMPtr.h" + +class nsIObserver; class nsKeygenThread : public nsIKeygenThread { private: PRLock *mutex; - nsIDOMWindowInternal* statusDialogPtr; + nsCOMPtr observer; PRBool iAmRunning; PRBool keygenReady; diff --git a/uriloader/base/nsIDownload.idl b/uriloader/base/nsIDownload.idl index 2714058182a7..fdf119fd2228 100644 --- a/uriloader/base/nsIDownload.idl +++ b/uriloader/base/nsIDownload.idl @@ -154,7 +154,6 @@ interface nsIDownload : nsITransfer { * be stored, but which is not equal to the target file. * * INTERFACES THAT NEED TO BE IMPLEMENTED: - * nsISupports * nsITransfer * nsIDownload * nsIWebProgressListener