1999-09-07 06:18:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.1 (the "MPL"); you may not use this file except in
|
|
|
|
* compliance with the MPL. You may obtain a copy of the MPL at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the MPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* MPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the MPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
1999-09-07 20:30:25 +00:00
|
|
|
#include "plhash.h"
|
|
|
|
#include "jsapi.h"
|
1999-09-07 06:18:08 +00:00
|
|
|
#include "nsIComponentLoader.h"
|
1999-11-10 00:34:26 +00:00
|
|
|
#include "nsIJSRuntimeService.h"
|
|
|
|
#include "nsIJSContextStack.h"
|
1999-09-07 20:30:25 +00:00
|
|
|
#include "nsIRegistry.h"
|
1999-09-07 06:18:08 +00:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIXPConnect.h"
|
1999-09-21 14:38:50 +00:00
|
|
|
#include "nsIModule.h"
|
1999-11-10 00:34:26 +00:00
|
|
|
#include "nsSupportsArray.h"
|
2000-01-24 21:28:28 +00:00
|
|
|
#include "nsIFileSpec.h"
|
|
|
|
#include "nsIFile.h"
|
1999-09-07 06:18:08 +00:00
|
|
|
extern const char mozJSComponentLoaderProgID[];
|
|
|
|
extern const char jsComponentTypeName[];
|
|
|
|
|
|
|
|
/* 6bd13476-1dd2-11b2-bbef-f0ccb5fa64b6 (thanks, mozbot) */
|
|
|
|
|
|
|
|
#define MOZJSCOMPONENTLOADER_CID \
|
|
|
|
{0x6bd13476, 0x1dd2, 0x11b2, \
|
|
|
|
{ 0xbb, 0xef, 0xf0, 0xcc, 0xb5, 0xfa, 0x64, 0xb6 }}
|
|
|
|
|
|
|
|
class mozJSComponentLoader : public nsIComponentLoader {
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICOMPONENTLOADER
|
|
|
|
|
|
|
|
mozJSComponentLoader();
|
|
|
|
virtual ~mozJSComponentLoader();
|
|
|
|
|
|
|
|
protected:
|
1999-09-24 01:37:44 +00:00
|
|
|
nsresult ReallyInit();
|
2000-01-24 21:28:28 +00:00
|
|
|
nsresult AttemptRegistration(nsIFile *component, PRBool deferred);
|
2000-04-18 05:26:40 +00:00
|
|
|
nsresult UnregisterComponent(nsIFile *component);
|
2000-01-24 21:28:28 +00:00
|
|
|
nsresult RegisterComponentsInDir(PRInt32 when, nsIFile *dir);
|
|
|
|
JSObject *GlobalForLocation(const char *aLocation, nsIFile *component);
|
1999-09-07 20:30:25 +00:00
|
|
|
nsIModule *ModuleForLocation(const char *aLocation,
|
2000-01-24 21:28:28 +00:00
|
|
|
nsIFile *component);
|
|
|
|
PRBool HasChanged(const char *registryLocation, nsIFile *component);
|
1999-09-07 20:30:25 +00:00
|
|
|
nsresult SetRegistryInfo(const char *registryLocation,
|
2000-01-24 21:28:28 +00:00
|
|
|
nsIFile *component);
|
2000-04-18 05:26:40 +00:00
|
|
|
nsresult RemoveRegistryInfo(const char *registryLocation);
|
1999-09-07 20:30:25 +00:00
|
|
|
|
1999-11-10 00:34:26 +00:00
|
|
|
nsIComponentManager* mCompMgr; // weak ref, should make it strong?
|
1999-09-07 20:30:25 +00:00
|
|
|
nsCOMPtr<nsIRegistry> mRegistry;
|
1999-11-18 15:39:28 +00:00
|
|
|
nsCOMPtr<nsIXPConnect> mXPC;
|
|
|
|
nsCOMPtr<nsIJSRuntimeService> mRuntimeService;
|
1999-09-07 06:18:08 +00:00
|
|
|
|
|
|
|
JSObject *mSuperGlobal;
|
|
|
|
JSRuntime *mRuntime;
|
|
|
|
JSContext *mContext;
|
|
|
|
JSObject *mCompMgrWrapper;
|
2000-05-26 04:56:23 +00:00
|
|
|
JSObject *mSeasonPass; // holds system principal atop the scope chain
|
1999-09-07 06:18:08 +00:00
|
|
|
|
|
|
|
PLHashTable *mModules;
|
|
|
|
PLHashTable *mGlobals;
|
1999-09-29 02:36:54 +00:00
|
|
|
nsRegistryKey mXPCOMKey;
|
1999-09-24 01:37:44 +00:00
|
|
|
|
|
|
|
PRBool mInitialized;
|
1999-11-10 00:34:26 +00:00
|
|
|
nsSupportsArray mDeferredComponents;
|
1999-09-07 06:18:08 +00:00
|
|
|
};
|