bug 33099
r=shaver a=edburns Native code changes: This fix eradicates all occurrences of the following symbols nsComponentManager nsServiceManeger And replaces them with their nsI counterparts. The following ns* classes still are used in webclient, and no plans exist to replace them with nsI counterparts: nsresult nsCOMPtr nsCRT nsnull * nsServiceManager occurrences were replaced with do_GetService(), using a PROGID. * nsComponentManager occurrences were replaced with a call on the global class gComponentManager, declared in the new file ns_globals.h, and defined in WrapperFactoryImpl.cpp. ns_globals.h is included in jni_util.h. See the attachment to bug 33099 for ns_globals.h * Added deallocation code to WindowControlImpl.cpp nativeTerminate. I know it doesn't do much, but it's correct. Java code changes: * Added static method BrowserControlFactory.appTerminate(). This method simply calls the existing BrowserControlImpl.appTerminate(), which calls WrapperFactoryImpl.cpp nativeTerminate(). BrowserControlFactory.appTerminate() is called from EmbeddedMozilla's WindowListener, which gets fired when the user signals she wants the app to terminate. git-svn-id: svn://10.0.0.236/trunk@66563 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -63,6 +63,10 @@ static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID);
|
||||
|
||||
#endif // XP_PC
|
||||
|
||||
//
|
||||
// file data
|
||||
//
|
||||
|
||||
|
||||
static nsFileSpec gBinDir;
|
||||
|
||||
@@ -78,6 +82,16 @@ const char *gImplementedInterfaces[] = {
|
||||
nsnull
|
||||
};
|
||||
|
||||
//
|
||||
// global data
|
||||
//
|
||||
|
||||
nsIComponentManager *gComponentManager = nsnull;
|
||||
|
||||
//
|
||||
// Functions to hook into mozilla
|
||||
//
|
||||
|
||||
extern "C" void NS_SetupRegistry();
|
||||
extern nsresult NS_AutoregisterComponents();
|
||||
|
||||
@@ -85,16 +99,25 @@ JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
|
||||
JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
nsresult rv;
|
||||
|
||||
if (gFirstTime) {
|
||||
const char *nativePath = (const char *) ::util_GetStringUTFChars(env,
|
||||
verifiedBinDirAbsolutePath);
|
||||
gBinDir = nativePath;
|
||||
|
||||
// It is vitally important to call NS_InitXPCOM before calling
|
||||
// anything else.
|
||||
NS_InitXPCOM(nsnull, &gBinDir);
|
||||
NS_SetupRegistry();
|
||||
rv = NS_GetGlobalComponentManager(&gComponentManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "NS_GetGlobalComponentManager() failed.");
|
||||
::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath,
|
||||
nativePath);
|
||||
return;
|
||||
}
|
||||
prLogModuleInfo = PR_NewLogModule("webclient");
|
||||
const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE");
|
||||
if (nsnull != webclientLogFile) {
|
||||
@@ -102,9 +125,9 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitializ
|
||||
// If this fails, it just goes to stdout/stderr
|
||||
}
|
||||
|
||||
nsComponentManager::RegisterComponentLib(kSessionHistoryCID, nsnull,
|
||||
nsnull, APPSHELL_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
gComponentManager->RegisterComponentLib(kSessionHistoryCID, nsnull,
|
||||
nsnull, APPSHELL_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
NS_AutoregisterComponents();
|
||||
gFirstTime = PR_FALSE;
|
||||
::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, nativePath);
|
||||
@@ -114,9 +137,10 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitializ
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeTerminate
|
||||
(JNIEnv *, jobject)
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
|
||||
gComponentManager = nsnull;
|
||||
gHistory = nsnull;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
||||
Reference in New Issue
Block a user