- 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

@@ -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) {