From 9b04329899823b8d60a77769b0f610e1d01c2f03 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Fri, 11 May 2001 23:16:59 +0000 Subject: [PATCH] Removing at Nikolay's request git-svn-id: svn://10.0.0.236/trunk@94704 18797224-902f-48f8-a5cc-f745e15eee43 --- .../sun/jvmp/mozilla/MozillaAppletPeer.java | 265 ------------------ .../jvmp/mozilla/MozillaHostObjectPeer.java | 107 ------- .../sun/jvmp/mozilla/MozillaPeerFactory.java | 237 ---------------- .../jvmp/mozilla/MozillaSecurityManager.java | 54 ---- 4 files changed, 663 deletions(-) delete mode 100644 mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaAppletPeer.java delete mode 100644 mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaHostObjectPeer.java delete mode 100644 mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaPeerFactory.java delete mode 100644 mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaSecurityManager.java diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaAppletPeer.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaAppletPeer.java deleted file mode 100644 index 52266d1b9f0..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaAppletPeer.java +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- 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 "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: MozillaAppletPeer.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.mozilla; - -import sun.jvmp.*; -import sun.jvmp.security.*; -import sun.jvmp.applet.*; -import java.util.Hashtable; -import java.net.URL; -import java.net.MalformedURLException; -import java.applet.*; -import java.awt.Frame; - -public class MozillaAppletPeer extends WFAppletContext - implements HostObjectPeer, sun.jvmp.javascript.JSContext -{ - private int m_id; - private int m_winid; - private long m_params = 0; - MozillaPeerFactory m_factory; - WFAppletViewer m_viewer = null; - private boolean m_stopped = true; - protected JSObject m_js = null; - PluggableJVM jvm; - - MozillaAppletPeer(MozillaHostObjectPeer fake, int id) - { - m_factory = fake.m_factory;; - jvm = m_factory.m_jvm; - jvm.trace("CREATED APPLET OBJECT: "+this, - PluggableJVM.LOG_DEBUG); - m_id = id; - m_winid = 0; - } - - public int getID() - { - return m_id; - } - - public void setID(int id) - { - if (m_id != 0) return; - m_id = id; - } - public int handleEvent(SecurityCaps caps, int eventID, long eventData) - { - int retval = 0; - //jvm.trace("GOT EVENT "+eventID+"!!!"); - switch (eventID) - { - case PE_CREATE: - retval = 1; - break; - case PE_SETTYPE: - jvm.trace("SETTYPE called twice - IGNORED", - PluggableJVM.LOG_WARNING); - retval = 1; - break; - case PE_SETWINDOW: - jvm.trace("PE_SETWINDOW", PluggableJVM.LOG_DEBUG); - m_winid = (int)eventData; - retval = handleSetWindow(); - break; - case PE_NEWPARAMS: - m_params = eventData; - retval = handleNewParams(); - break; - case PE_DESTROY: - retval = destroy(caps); - break; - case PE_STOP: - retval = 1; - // do it before stop, as after we can't be sure - // our browser peer is still alive - m_stopped = true; - if (m_viewer != null) m_viewer.stopApplet(); - break; - case PE_START: - retval = 1; - m_stopped = false; - m_viewer.startApplet(); - break; - case PE_GETPEER: - // this call is handled in both ways - direct and - // queued as policy on place where to handle - // JS calls can be changed on Mozilla side - // At least for now it works OK with both cases - retval = handleCall(caps, PE_GETPEER, eventData); - break; - default: - retval = 0; - } - return retval; - } - - public int handleCall(SecurityCaps caps, int arg1, long arg2) - { - int retval = 0; - switch (arg1) - { - case PE_GETPEER: - if (m_viewer == null) break; - Object o = null; - switch (m_viewer.getLoadingStatus()) - { - case sun.applet.AppletPanel.APPLET_START: - o = m_viewer.getApplet(); - break; - case sun.applet.AppletPanel.APPLET_ERROR: - o = null; - break; - default: - jvm.trace("XXX: Applet loading in progress....", - PluggableJVM.LOG_WARNING); - // here we just return NULL, as for the moment no valid - // applet object exist - if someone really needs this - // object - call later - break; - } - nativeReturnJObject(o, arg2); - retval = 1; - break; - default: - retval = 0; - } - return retval; - } - - public int destroy(SecurityCaps caps) - { - jvm.trace("DESTROY", PluggableJVM.LOG_DEBUG); - finalizeParams(); - m_params = 0; - m_stopped = true; - if (m_viewer != null) { - m_viewer.destroyApplet(2500); - m_viewer = null; - } - return 1; - } - - public HostObjectPeerFactory getFactory() - { - return m_factory; - } - - private int handleNewParams() - { - String[][] params = getParams(); - String[] keys = params[0]; - String[] vals = params[1]; - URL docbase; - Hashtable hparams = new Hashtable(); - for (int i=0; i < keys.length; i++) - hparams.put(keys[i].toLowerCase(), vals[i]); - //hparams.put("OWNER", this); - //hparams.put("ID", new Integer(m_id)); - try - { - docbase = new URL((String)hparams.get("docbase")); - } - catch (MalformedURLException e) - { - jvm.trace("invalid docbase due "+e, - PluggableJVM.LOG_ERROR); - return 0; - } - m_viewer = m_factory.m_mgr.createAppletViewer(this, - m_factory, - hparams); - m_viewer.setDocumentBase(docbase); - return handleSetWindow(); - } - - private int handleSetWindow() - { - if (m_stopped) return 0; - if (m_winid != 0) { - Frame f = jvm.getFrameWithId(m_winid); - if (f != null) m_viewer.setWindow(f); - } - return 1; - } - /** - * From AppletContext - */ - public void showStatus(String string) - { - //PluggableJVM.trace("Status: "+string); - // calls back peer in Mozilla - if (m_stopped) return; - nativeShowStatus(string); - } - - public void showDocument(URL url, String target) - { - // never pass events after stop() - otherwise - // we'll crash the browser - if (m_stopped) return; - // calls back peer in Mozilla - nativeShowDocument(url.toString(), target); - } - - public void showDocument(URL url) - { - showDocument(url, "_top"); - } - - /** - * From JSContext - */ - public netscape.javascript.JSObject getJSObject() - { - // check if we got params from browser - fail otherwise - if (m_params == 0) return null; - if (m_js == null) - m_js = new sun.jvmp.mozilla.JSObject(m_params); - return m_js; - } - // duplicates of nsIJavaObjectInfo methods - // funny way to return 2 arrays of strings - native protected String[][] getParams(); - native protected void finalizeParams(); - native protected boolean nativeShowStatus(String status); - native protected boolean nativeShowDocument(String url, - String target); - // method to write jobject ret to native pointer ptr - native protected void nativeReturnJObject(Object ret, long ptr); - // XXX: add others -}; - - - - - - - - - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaHostObjectPeer.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaHostObjectPeer.java deleted file mode 100644 index 68a7d387792..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaHostObjectPeer.java +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- 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 "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: MozillaHostObjectPeer.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.mozilla; - -import sun.jvmp.*; -import sun.jvmp.security.*; - -public class MozillaHostObjectPeer implements HostObjectPeer -{ - private int m_id = 0; - private long m_data = 0; - private HostObjectPeer m_realPeer = null; - MozillaPeerFactory m_factory = null; - - public MozillaHostObjectPeer(MozillaPeerFactory factory, int version) - { - m_factory = factory; - } - - public int getID() - { - return m_id; - } - - public void setID(int id) - { - if (m_id != 0) return; - m_id = id; - } - - public int handleEvent(SecurityCaps caps, int eventID, long eventData) - { - int retval = 0; - // forward functionality to the real peer - if (m_realPeer != null) - return m_realPeer.handleEvent(caps, eventID, eventData); - switch (eventID) - { - case PE_CREATE: - retval = 1; - break; - case PE_SETTYPE: - switch((int)eventData) - { - case PT_APPLET: - case PT_OBJECT: - m_realPeer = new MozillaAppletPeer(this, m_id); - // maybe send CREATE event from here? - retval = 1; - break; - default: - m_factory.m_jvm.trace("Unknown tag type", - PluggableJVM.LOG_WARNING); - break; - } - break; - default: - retval = 0; - break; - } - return retval; - } - public int destroy(SecurityCaps caps) - { - if (m_realPeer != null) - return m_realPeer.destroy(caps); - return 0; - } - - public int handleCall(SecurityCaps caps, int arg1, long arg2) - { - if (m_realPeer != null) - return m_realPeer.handleCall(caps, arg1, arg2); - return 0; - } - - public HostObjectPeerFactory getFactory() - { - return m_factory; - } -}; - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaPeerFactory.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaPeerFactory.java deleted file mode 100644 index 93cc9c87d7d..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/mozilla/MozillaPeerFactory.java +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- 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 "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: MozillaPeerFactory.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.mozilla; - -import sun.jvmp.*; -import sun.jvmp.security.*; -import sun.jvmp.applet.*; -import java.net.*; -import java.util.StringTokenizer; -import java.util.*; -import java.security.*; - -public class MozillaPeerFactory implements HostObjectPeerFactory, - AccessControlDecider, - BrowserSupport -{ - protected final String cid = "@sun.com/wf/mozilla/appletpeer;1"; - protected final int version = 1; - PluggableJVM m_jvm = null; - protected long m_params = 0; - protected int m_id; - private static boolean initialized = false; - protected URL[] m_codebase; - AppletManager m_mgr; - - protected MozillaPeerFactory(PluggableJVM jvm, long data) - throws Exception - { - loadLibrary(); - m_jvm = jvm; - m_params = data; - /* as we could load only one factory, this will allow - generic operations, like JS evaluation, to be performed without - any applets at all */ - JSObject.m_evaluator = data; - m_mgr = new AppletManager(jvm); - try { - m_codebase = null; - URLClassLoader cl = - (URLClassLoader)this.getClass().getClassLoader(); - if (cl != null) m_codebase = cl.getURLs(); - } catch (ClassCastException e) { - // do nothing here - } - System.setSecurityManager(new MozillaSecurityManager()); - } - - public static HostObjectPeerFactory start(PluggableJVM jvm, Long data) - { - MozillaPeerFactory factory = null; - try { - factory = new MozillaPeerFactory(jvm, data.longValue()); - } catch (Exception e) { - jvm.trace("MOZILLA FACTORY NOT CREATED", PluggableJVM.LOG_ERROR); - return null; - } - return factory; - } - - public String getCID() - { - return cid; - } - - public HostObjectPeer create(int version) - { - return new MozillaHostObjectPeer(this, version); - } - - public int handleEvent(SecurityCaps caps, - int eventID, - long eventData) - { - return 1; - } - - private native int nativeHandleCall(int arg1, long arg2); - - public int handleCall(SecurityCaps caps, int arg1, long arg2) - { - int rv = 0; - if (arg1 > 0) - rv = nativeHandleCall(arg1, arg2); - else - rv = 1; - return rv; - } - - public int destroy(SecurityCaps caps) - { - return 1; - } - - public PermissionCollection getPermissions(CodeSource codesource) - { - Permissions perms = new Permissions(); - URL location = codesource.getLocation(); - if (m_codebase != null && location != null) { - for (int i=0; i - */ - -package sun.jvmp.mozilla; - -import sun.jvmp.*; -import sun.jvmp.security.*; -import sun.jvmp.applet.*; -import java.security.*; - -public class MozillaSecurityManager extends WFAppletSecurityManager -{ - public void checkPackageAccess(final String p) - { - //System.err.println("checkPackageAccesss: "+p); - // this check used to prevent infinite recursion when calling implies() - // in JavaScriptProtectionDomain,, as it has to load some classes - if (p.equals("sun.jvmp.mozilla")) - { - return; - } - super.checkPackageAccess(p); - } - - public void checkPermission(Permission p) - { - //System.err.println("checkPermission: "+p); - super.checkPermission(p); - } - -}