Closed Bug 39911 Opened 24 years ago Closed 24 years ago

Plugins should be scriptable

Categories

(Core Graveyard :: Plug-ins, defect, P3)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: beard, Assigned: mike+mozilla)

References

Details

(Keywords: arch)

Attachments

(2 files)

We should define an interface that can be used by plugins to advertise their
scriptable interfaces. Here's a first cut at such an interface. I think a plugin
should be able to provide more than one scriptable interface, so this interface
permits simple enumeration.

class nsIScriptableInterfaces : public nsISupports {
public:
  /**
   * Returns number of scriptable interfaces this plugin supports.
   */
  NS_IMETHOD GetInterfaceCount(PRUInt32* aCount) = 0;

  /**
   * Returns the IID of the Nth scriptable interface.
   */
  NS_IMETHOD GetIID(PRUInt32 aIndex, nsIID* aIID) = 0;

  /**
   * Returns the object that implements the interface of the specified IID.
   */
  NS_IMETHOD GetScriptableObject(nsIID* aIID, void* *aResult) = 0;
};
Is this a DUP of FIXED bug 32150, "Scriptable Plugin methods/members need to be 
accessable from JavaScript"? 

Or is it related to bug 38495, "need to support JS LiveConnect calls in existing 
content via upgraded plug-in binaries"?

Or is this bug really focused on the enhancement of enabling more than one 
scriptable interface?
Keywords: arch
Nope, it's part of our proposed solution to making plugins scriptable from
javascript via the existing api.

Patrick: I just noticed that this interface supports returning multiple IIDs...
XPConnect doesn't currently support exposing an object with multiple
(superimposed) interfaces, so we won't be able to reflect multiple plugins on
interfaces.  We may be able to support it in the future.  Is it OK to use this
interface, with the caveat that we'll only reflect the first interface for a
while?
I have plugins ready to be scriptable, I'm just missing this interface.  (The QI
can fail, but I need an interface to QI against.)

Patrick - This interface seems to allow returning different scriptable objects
for each IID needed.  If we were to support merging these interfaces in
XPConnect, would that mean supporting aggregation?  Flattening is in the future,
but I'm not sure that it means this; I'd imagined multiple interfaces on the
same object.  Or maybe aggregation is just easy and we should anticipate it.

Hm.

Would it make sense to dropthe nsIID* aIID parameter?
My proposal -
[scriptable, uuid(c1188f50-1dd1-11b2-a4eb-cbb32e611eec)]
interface nsIScriptablePlugin : nsISupports
{
    readonly attribute PRUint32 interfaceCount;
    nsIIDPtr getIID(in PRUint32 aIndex);
    nsISupports getScriptableObject();
};
Here's another stab at an "introspection" interface.

I think we should separate the notion of what interfaces a plugin supports from 
providing the object that is in fact scriptable itself. Thus, a plugin could 
provide an accessor method that returns an nsISupports. This object would be 
queried to ask it what interfaces it supports. Here's a simple interface for 
doing that:

interface nsIInterfaceCollection : nsISupports {
  /**
   * Returns array of valid interfaces that this object's class implements.
   */
  void getInterfaces(out PRUint32 count,
                     [retval, array, size_is(count)]
                     out nsIIDPtr interfaces);
};
Perhaps the interfaces result could be marked "shared" so it can live in 
statically allocated memory.
Reassigning to myself.
Assignee: av → mccabe
Blocks: 32150
Vidur pointed out that we really don't have any call for plugins to support
multiple scriptable interfaces at this time.  I'd also rather move forward with
this than try to finalize a general mechanism to fix this very specific problem.
Attaching what I hope to be the final revision of nsIScriptablePlugin.idl.  r=
and a= requested.
Blocks: 38495
Fine. Let's file another bug to at least table the more general solution.
Fix checked in; thanks to Patrick for mac IDL project assistance.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
marking verified.
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: