bug #14889 Lazy loading wallet dll r=morse,gagan sr=jband a=asa

This commit is contained in:
dp%netscape.com 2001-08-28 22:32:03 +00:00
Родитель 2bae087ecb
Коммит 8bf4f6454a
8 изменённых файлов: 95 добавлений и 10 удалений

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

@ -42,6 +42,8 @@ class nsIURI;
{ 0xa6cf9106, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#define NS_FORMSUBMIT_SUBJECT "formsubmit"
#define NS_FIRST_FORMSUBMIT_CATEGORY "firstformsubmit"
#define NS_PASSWORDMANAGER_CATEGORY "passwordmanager"
class nsIFormSubmitObserver : public nsISupports {
public:

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

@ -35,7 +35,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSingleSignOnPrompt, Init)
// The list of components we register
static nsModuleComponentInfo components[] = {
{ NS_WALLETSERVICE_CLASSNAME, NS_WALLETSERVICE_CID,
NS_WALLETSERVICE_CONTRACTID, nsWalletlibServiceConstructor },
NS_WALLETSERVICE_CONTRACTID, nsWalletlibServiceConstructor,
nsWalletlibService::RegisterProc,
nsWalletlibService::UnregisterProc
},
{ NS_PASSWORDMANAGER_CLASSNAME, NS_PASSWORDMANAGER_CID,
NS_PASSWORDMANAGER_CONTRACTID, nsPasswordManagerConstructor },
{ NS_SINGLESIGNONPROMPT_CLASSNAME, NS_SINGLESIGNONPROMPT_CID,

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

@ -47,6 +47,7 @@
#include "nsIWindowWatcher.h"
#include "nsIWebProgress.h"
#include "nsXPIDLString.h"
#include "nsICategoryManager.h"
// for making the leap from nsIDOMWindowInternal -> nsIPresShell
#include "nsIScriptGlobalObject.h"
@ -213,6 +214,47 @@ NS_IMETHODIMP nsWalletlibService::Notify(nsIContent* formNode, nsIDOMWindowInter
return NS_OK;
}
NS_IMETHODIMP
nsWalletlibService::RegisterProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
// Register ourselves into the NS_CATEGORY_HTTP_STARTUP
nsresult rv;
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLCString prevEntry;
catman->AddCategoryEntry(NS_FIRST_FORMSUBMIT_CATEGORY, "Form Manager", NS_WALLETSERVICE_CONTRACTID,
PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
catman->AddCategoryEntry(NS_PASSWORDMANAGER_CATEGORY, "Password Manager", NS_WALLETSERVICE_CONTRACTID,
PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
return NS_OK;
}
NS_IMETHODIMP
nsWalletlibService::UnregisterProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const nsModuleComponentInfo *info)
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
catman->DeleteCategoryEntry(NS_FIRST_FORMSUBMIT_CATEGORY,
NS_WALLETSERVICE_CONTRACTID, PR_TRUE);
catman->DeleteCategoryEntry(NS_PASSWORDMANAGER_CATEGORY,
NS_WALLETSERVICE_CONTRACTID, PR_TRUE);
// Return value is not used from this function.
return NS_OK;
}
nsresult nsWalletlibService::Init()
{
nsresult rv;

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

@ -32,6 +32,8 @@
#include "nsIDOMWindowInternal.h"
#include "nsIURI.h"
#include "nsIWebProgressListener.h"
#include "nsIComponentManager.h"
#include "nsIGenericFactory.h"
class nsWalletlibService : public nsIWalletService,
public nsIObserver,
@ -53,6 +55,18 @@ public:
// NS_DECL_NSIFORMSUBMITOBSERVER
NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindowInternal* window, nsIURI* actionURL, PRBool* cancelSubmit);
// {Un}Register proc that do category {Un}Registration
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info);
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const nsModuleComponentInfo *info);
protected:
virtual ~nsWalletlibService();
@ -71,7 +85,7 @@ public:
virtual ~nsSingleSignOnPrompt() {}
nsresult Init();
protected:
nsCOMPtr<nsIPrompt> mPrompt;
static PRBool mgRegisteredObserver;

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

@ -42,6 +42,8 @@ class nsIURI;
{ 0xa6cf9106, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#define NS_FORMSUBMIT_SUBJECT "formsubmit"
#define NS_FIRST_FORMSUBMIT_CATEGORY "firstformsubmit"
#define NS_PASSWORDMANAGER_CATEGORY "passwordmanager"
class nsIFormSubmitObserver : public nsISupports {
public:

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

@ -126,6 +126,11 @@ static NS_DEFINE_CID(kUBidiUtilCID, NS_UNICHARBIDIUTIL_CID);
#endif
//end
// Marks if the first form is submitted or not. Once we submit the first
// form, this will become PR_TRUE
PRBool nsFormFrame::gFirstFormSubmitted = PR_FALSE;
PRBool nsFormFrame::gInitPasswordManager = PR_FALSE;
NS_IMETHODIMP
nsFormFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
@ -444,6 +449,16 @@ void nsFormFrame::DoDefaultSelection(nsIPresContext* aPresContext,
void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFormControlFrame& aFrame)
{
PRInt32 type;
aFrame.GetType(&type);
if (!gInitPasswordManager && type == NS_FORM_INPUT_PASSWORD) {
// Initialize the password manager category
gInitPasswordManager = PR_TRUE;
NS_CreateServicesFromCategory(NS_PASSWORDMANAGER_CATEGORY,
NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)),
NS_ConvertASCIItoUCS2(NS_PASSWORDMANAGER_CATEGORY).get());
}
// Add this control to the list
// Sort by content ID - this assures we submit in document order (bug 18728)
PRInt32 i = mFormControls.Count();
@ -480,8 +495,6 @@ void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFormContr
// determine which radio buttons belong to which radio groups, unnamed radio buttons
// don't go into any group since they can't be submitted.
PRInt32 type;
aFrame.GetType(&type);
if (NS_FORM_INPUT_RADIO == type) {
nsGfxRadioControlFrame* radioFrame = (nsGfxRadioControlFrame*)&aFrame;
// gets the name of the radio group and the group
@ -847,6 +860,15 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
result = NS_MakeAbsoluteURI(absURLSpec, href, docURL);
if (NS_FAILED(result)) return result;
// If this is the first form, bring alive the first form submit
// category observers
if (!gFirstFormSubmitted) {
gFirstFormSubmitted = PR_TRUE;
NS_CreateServicesFromCategory(NS_FIRST_FORMSUBMIT_CATEGORY,
NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)),
NS_ConvertASCIItoUCS2(NS_FIRST_FORMSUBMIT_CATEGORY).get());
}
// Notify observers that the form is being submitted.
result = NS_OK;
nsCOMPtr<nsIObserverService> service =

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

@ -82,6 +82,12 @@ public:
NS_IMETHOD GetTarget(nsString* aTarget);
NS_IMETHOD GetAction(nsString* aAction);
// Detection of first form to notify observers
static PRBool gFirstFormSubmitted;
// Detection of first password field to notify any password manager
// style modules
static PRBool gInitPasswordManager;
// static helper functions for nsIFormControls
static PRBool GetDisabled(nsIFrame* aChildFrame, nsIContent* aContent = 0);

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

@ -44,7 +44,6 @@
#include "nsIDirectoryService.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsSpecialSystemDirectory.h"
#include "nsIWalletService.h"
#include "nsIWindowMediator.h"
#include "nsIDOMWindowInternal.h"
#include "nsIClipboard.h"
@ -1375,11 +1374,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");
if (NS_FAILED(rv)) return rv;
// Startup wallet service so it registers for notifications
NS_TIMELINE_ENTER("walletService");
nsCOMPtr<nsIWalletService> walletService(do_GetService(NS_WALLETSERVICE_CONTRACTID, &rv));
NS_TIMELINE_LEAVE("walletService");
// From this point on, should be true
appShell->SetQuitOnLastWindowClosing(PR_TRUE);
// Start main event loop