- Include debug options

M webclient/build.xml
A webclient/default-profile-dir-contents.jar

- Include a sample profile dir into the webclient jar

M webclient/classes_spec/org/mozilla/webclient/WebclientFactory.java
M webclient/classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java

- add setProfileDir()

M webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java

- add methods for allowing the setting of profile directories.

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java

- cook up a profile directory based on the bin directory if the user hasn't provided one.

M webclient/src_moz/ProfileManagerImpl.cpp

- Make sure NSS is initialized by giving the system a ProfD and getting the
  psm service via contract id.

M webclient/test/manual/src/classes/org/mozilla/webclient/test/TestBrowser.java

- Make sure the darn thing is visible


git-svn-id: svn://10.0.0.236/trunk@253371 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org 2008-08-04 20:51:22 +00:00
parent 8c2c6808cb
commit 1a89ffedc8
9 changed files with 157 additions and 6 deletions

View File

@ -75,3 +75,6 @@ Problems?
* post to netscape.public.mozilla.java newsgroup
A sample of working debugger opts for msdev:
-DNSPR_LOG_MODULES=javadom:4,webclient:4,webclientstub:4,pluglets:4 -DNSPR_LOG_FILE=F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\java\webclient\build.test\webclient.log -Dbuild.test.results.dir=F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\java\webclient\build.test -DBROWSER_BIN_DIR=F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\xulrunner-win32_d.obj\dist\bin -Djava.util.logging.config.file=F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\java\logging.properties -Djava.library.path=F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\xulrunner-win32_d.obj\dist\bin -classpath F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\xulrunner-win32_d.obj\dist\classes;F:\Projects\mozilla\FIREFOX_2_0_0_3_RELEASE\mozilla\xulrunner-win32_d.obj\dist\classes\test\classes;C:\PROGRA~1\netbeans-5.5.1\ide7\modules\ext\junit-3.8.1.jar org.mozilla.webclient.test.TestBrowser

View File

@ -90,7 +90,8 @@
</and>
</condition>
<copy todir="${build.home}/META-INF"
file="default-profile-dir-contents.jar" />
</target>

View File

@ -57,6 +57,8 @@ public interface WebclientFactory {
public void setAppData(String absolutePathToNativeBrowserBinDir)
throws FileNotFoundException, ClassNotFoundException;
public void setProfileDir(String profileDir);
/**
*

View File

@ -102,6 +102,11 @@ public void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotF
throw new ClassNotFoundException(ule.getMessage(), ule);
}
}
public void setProfileDir(String profileDir) {
getWrapperFactory().setProfileDir(profileDir);
}
/******
// figure out the correct value for platformCanvasClassName
if (browserType.equals(BrowserControl.BROWSER_TYPE_NON_NATIVE)) {
@ -137,6 +142,8 @@ public void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotF
}
********************/
public void appTerminate() throws Exception
{
getWrapperFactory().terminate();

View File

@ -80,6 +80,12 @@ public interface WrapperFactory {
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError;
public String getBinDir();
public void setProfileDir(String profileDir);
public String getProfileDir();
public void verifyInitialized() throws IllegalStateException;
public void terminate() throws Exception;

View File

@ -23,8 +23,15 @@
package org.mozilla.webclient.impl.wrapper_native;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
@ -32,7 +39,6 @@ import org.mozilla.webclient.ProfileManager;
import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.impl.Service;
import org.mozilla.webclient.UnimplementedException;
public class ProfileManagerImpl extends ImplObjectNative implements ProfileManager, Service
@ -47,8 +53,17 @@ public ProfileManagerImpl(WrapperFactory yourFactory)
}
public void startup() {
String profileDir = this.getWrapperFactory().getProfileDir();
if (null == profileDir) {
createProfileDirInBinDir();
}
Assert.assert_it(isNativeEventThread());
nativeStartup(getWrapperFactory().getNativeWrapperFactory(), null,
// Ensure getProfileDir ends with File.separator
if (!getWrapperFactory().getProfileDir().endsWith(File.separator)) {
getWrapperFactory().setProfileDir(getWrapperFactory().getProfileDir() + File.separator);
}
nativeStartup(getWrapperFactory().getNativeWrapperFactory(), getWrapperFactory().getProfileDir(),
getWrapperFactory().getProfile());
}
@ -57,6 +72,42 @@ public void shutdown() {
nativeShutdown(getWrapperFactory().getNativeWrapperFactory());
}
private String defaultProfileName = "mevgf29o.default";
private void createProfileDirInBinDir() {
getWrapperFactory().setProfileDir(getWrapperFactory().getBinDir());
if (null == getWrapperFactory().getProfile()){
getWrapperFactory().setProfile(defaultProfileName);
}
File profileDirFile = new File(getWrapperFactory().getProfileDir() +
File.separator + getWrapperFactory().getProfile());
// Assume that if the profileDir exists, it must be valid. Otherwise
// create it.
if (!profileDirFile.exists()) {
profileDirFile.mkdir();
URL profileDirContentsResource = Thread.currentThread().getContextClassLoader().getResource("META-INF/default-profile-dir-contents.jar");
try {
JarInputStream jis = new JarInputStream(profileDirContentsResource.openStream());
JarEntry cur = null;
FileOutputStream fos = null;
File profileEntry = null;
int i;
while (null != (cur = jis.getNextJarEntry())) {
profileEntry = new File(profileDirFile, cur.getName());
fos = new FileOutputStream(profileEntry);
while (-1 != (i = jis.read())) {
fos.write(i);
}
fos.close();
jis.closeEntry();
}
jis.close();
} catch (IOException ex) {
Logger.getLogger(ProfileManagerImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public int getProfileCount()
{
Integer result = (Integer)

View File

@ -105,7 +105,7 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
// Attribute Instance Variables
protected String platformCanvasClassName = null;
protected String profileName = "webclient";
protected String profileName = null;
protected boolean initialized = false;
protected boolean terminated = false;
protected CountDownLatch oneCountLatch = null;
@ -137,6 +137,9 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
protected ProfileManager profileManager = null;
private String binDir = null;
private String profileDir = null;
//
// Constructors and Initializers
//
@ -184,6 +187,7 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
browserControls.put(result, new Integer(nativeBrowserControl));
if (1 == browserControls.size()) {
copyProxySettingsIfNecessary();
setMiscPrefs();
}
return result;
}
@ -360,8 +364,10 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
LOGGER.log(Level.SEVERE, "Unable to find method 'newNativeEventThread' on class " +
getPlatformCanvasClassName(), nsme);
}
binDir = verifiedBinDirAbsolutePath;
final String finalStr = new String(verifiedBinDirAbsolutePath);
final String finalStr = new String(binDir);
eventThread.pushRunnable(new Runnable() {
public void run() {
@ -425,6 +431,18 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
}
public String getBinDir() {
return binDir;
}
public String getProfileDir() {
return profileDir;
}
public void setProfileDir(String profileDir) {
this.profileDir = profileDir;
}
private enum ProxyEnum {
httpProxyHost,
@ -526,6 +544,11 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
}
}
public void setMiscPrefs() {
prefs.setPref("security.suppress_nss_rw_impossible_warning", "true");
}
public void verifyInitialized() throws IllegalStateException
{
if (!initialized) {

View File

@ -38,6 +38,13 @@
#include <nsIProfile.h> // for the profile manager
#include <nsIProfileInternal.h> // for the profile manager
#include <nsString.h> // for nsCAutoString
#include <nsIDirectoryService.h>
#include <nsIProperties.h>
#include <nsIFile.h>
#include <nsILocalFile.h>
#include <nsDependentString.h>
#include "nsXPCOMCID.h" // for NS_DIRECTORY_SERVICE_CONTRACTID
// edburns_20060216
// static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
@ -171,6 +178,54 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
NS_ADDREF(wcContext->sProfileInternal);
#endif // edburns_20060216
nsresult rv;
nsCOMPtr<nsIDirectoryService> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
nsCOMPtr<nsIProperties> properties = do_QueryInterface(directoryService);
nsCOMPtr<nsIFile> profileDirFile;
PRUnichar *profileDirUnichar = (PRUnichar *)
::util_GetStringChars(env, profileDir);
PRUnichar *profileNameUnichar = (PRUnichar *)
::util_GetStringChars(env, profileNameJstr);
nsDependentString profileDirStr(profileDirUnichar);
nsDependentString profileNameStr(profileNameUnichar);
nsString fullyQualified = profileDirStr + profileNameStr;
rv = NS_NewLocalFile(fullyQualified,
PR_TRUE,
(nsILocalFile **)((nsIFile **)getter_AddRefs(profileDirFile)));
::util_ReleaseStringChars(env, profileDir, profileDirUnichar);
::util_ReleaseStringChars(env, profileNameJstr, profileNameUnichar);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Can't create profile directory.");
return;
}
properties->Set("ProfD", profileDirFile);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Can't create profile directory.");
return;
}
nsCOMPtr<nsISupports> psm = do_GetService("@mozilla.org/psm;1");
if (!psm) {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("WrapperFactoryImpl_nativeAppSetup: unable to initialize PSM. https sites will crash the client\n"));
}
else {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("WrapperFactoryImpl_nativeAppSetup: successfully initialized PSM. https sites will NOT crash the client\n"));
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("ProfileManagerImpl_nativeStartup: exiting\n"));

View File

@ -120,6 +120,7 @@ public class TestBrowser extends JPanel {
frame.pack();
frame.setVisible(true);
testBrowser.setVisible(true);
if (1 == args.length) {
testBrowser.loadURL(args[0]);
}
@ -445,6 +446,7 @@ public class TestBrowser extends JPanel {
if (curUrl == null) {
// Check if the text value starts with known protocols.
if (inputValue.toLowerCase().startsWith("http://")
|| inputValue.toLowerCase().startsWith("https://")
|| inputValue.toLowerCase().startsWith("ftp://")
|| inputValue.toLowerCase().startsWith("gopher://")
|| inputValue.toLowerCase().startsWith("file://")) {
@ -460,6 +462,7 @@ public class TestBrowser extends JPanel {
}
}
browserControlCanvas.setVisible(true);
navigation.loadURL(curUrl.toString());
// Update the address text field, statusbar, and toolbar info.