Closed Bug 577745 Opened 14 years ago Closed 14 years ago

New Perfidies API knownPluginsByMimeType

Categories

(Websites :: plugins.mozilla.org, defect)

defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ozten, Unassigned)

References

Details

We need a simplar API in the client library called something like knownPluginsByMimeType.

Given a mime-type and related inputs it returns a list of pfsInfo objects. This will allow the plugin manager to list plugins to the user when they *do not have the plugin installed*.

This comes from PFS currently.
Working this with other 1.1 bugs.
Target Milestone: --- → 1.1
@dtownsend - What is the usage pattern of this API? Do you discover a single mime-type or a list of mime-types?

For a list of mime-types... do you expect them to map to the same types of plugins (say Flash or flash like) or would you be discovering lots of different plugins at the same time.
@dtownsend - Does this look like the API you want?

@lorchard - Can you think of any issues of abusing the pfs v2 api in this manner, instead of designing a new API?

I've got the following integration test working in development:

module("knownPluginsByMimeTypes");
    test("Demonstrates high level API for finding plugins by mime-type", function() {
        var incCallbackCount = 0,
            sawFlash = false,
            sawDivX = false,
            sawSunJava = false,
            sawIceTeaJava = false,
            sawVLC = false,
            sawQuickTime = false;
        
        var mimeTypes = ["application/x-shockwave-flash", "application/futuresplash", "video/divx",
                         "application/x-java-vm", "video/quicktime", "unknown/mime-type"];
        //mimeTypes = [];
        
        // The stage database has Flash, DivX, Sun's Java, and Ice Tea Java, VLC, and QuickTime.
        // It doesn't have anything registered for unknown/mime-type.
        // So we should see 6 plugins for these 6 mime-types
        var totalPlugins = 6;
        
        Pfs.knownPluginsByMimeTypes(navigatorInfo, mimeTypes, function(pfsResponse){
            
            incCallbackCount++;
            if (pfsResponse.pfsInfo.aliases.literal[0] == "Adobe Flash Player") {
                sawFlash = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://www.adobe.com/go/getflashplayer",
                     "Given application/x-shockwave-flash or application/futuresplash we should list Flash plugin url");
            
            } else if (pfsResponse.pfsInfo.aliases.literal[0] == "DivX Web Player") {
                sawDivX = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://www.divx.com/en/products/software/mac/divx", "Given video/divx we should list Foobar plugin url");
            } else if (pfsResponse.pfsInfo.aliases.literal[0] == "Java Runtime Environment") {
                sawSunJava = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://www.java.com/en/download/manual.jsp", "Given application/x-java-vm we should list SunJava and IceTea Java plugins url");
            
            } else if (pfsResponse.pfsInfo.aliases.literal[0] == "IcedTea Java Web Browser Plugin") {
                sawIceTeaJava = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://icedtea.classpath.org/wiki/Main_Page", "Given application/x-java-vm we should list SunJava and IceTea Java plugins url");

            } else if (pfsResponse.pfsInfo.aliases.literal[0] == "VLC Multimedia Plug-in") {
                sawVLC = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://www.videolan.org/vlc/", "Given video/quicktime we should list Quicktime and VLC plugins url");

            } else if (pfsResponse.pfsInfo.aliases.literal[0] == "QuickTime Plug-in") {
                sawQuickTime = true;
                same(pfsResponse.pfsInfo.releases.latest.url, "http://www.apple.com/quicktime/download/", "Given video/quicktime we should list Quicktime and VLC plugins url");
            }
            
          }, function(){
            start();
            equals(incCallbackCount, totalPlugins, "Several different mime-types queried, several plugins returned");
            equals(sawFlash, true, "We should have seen flash");
            equals(sawDivX, true, "We should have seen DivX");
            
            equals(sawSunJava, true, "We should have seen SunJava");
            equals(sawIceTeaJava, true, "We should have seen IceTea Java");
            
            equals(sawVLC, true, "We should have seen VLC");
            equals(sawQuickTime, true, "We should have seen QuickTime");
            
          });
        stop(30000);
    });


This function wraps a lower level reuse the API http://plugins.mozilla.org/pfs/v2
(In reply to comment #2)
Also: Besides plugin name and install url, what other data do you need?
(In reply to comment #2)
> @dtownsend - What is the usage pattern of this API? Do you discover a single
> mime-type or a list of mime-types?

With the current PFS we request a plugin that can handle a single mimetype (the mimetype that the webpage is requesting). PFS gives us back details of a single plugin including:

* name
* version
* icon
* installer url and hash or xpi url and hash or manual install url
* license url if the user must agree to something before downloading
* whether the installer will show UI
* whether the installation requires restarting Firefox.
(In reply to comment #5)

Off of the pfsResponse.pfsInfo.releases.latest we have the following optional properties:

> * name
> * version
These are good. Below here uses fields that exist, but are currently unused.

> * icon
icon_url -  What are the image standards? (size, type)

> * installer url and hash or xpi url and hash or manual install url
installer_location, installer_hash, xpi_location, manual_installation_url, 

> * license url if the user must agree to something before downloading
license_url

> * whether the installer will show UI
installer_shows_ui - What is the standard here? boolean value? How do we represent it?

> * whether the installation requires restarting Firefox.
needs_restart - Same data type as installer_shows_ui I assume
(In reply to comment #6)
> (In reply to comment #5)
> 
> Off of the pfsResponse.pfsInfo.releases.latest we have the following optional
> properties:
> 
> > * name
> > * version
> These are good. Below here uses fields that exist, but are currently unused.
> 
> > * icon
> icon_url -  What are the image standards? (size, type)

Any supported image format really, png is the norm but gif or jpg would work equally well. Also this is optional, we'd fallback to a default icon in its absence. The size is 16x16px

> > * installer url and hash or xpi url and hash or manual install url
> installer_location, installer_hash, xpi_location, manual_installation_url, 

We could probably have a single hash field that applies to whichever of installer_location and xpi_location exists, but basically one of installer_location, xpi_location or manual_installation_url must exist or we have no way to get a plugin to install.

> > * license url if the user must agree to something before downloading
> license_url
> 
> > * whether the installer will show UI
> installer_shows_ui - What is the standard here? boolean value? How do we
> represent it?

Boolean value. In the current UI it just varies whether or not we show a message "Some plugins may require additional information from you during installation." before launching the plugin installer.

> > * whether the installation requires restarting Firefox.
> needs_restart - Same data type as installer_shows_ui I assume

Yes, boolean.
(In reply to comment #7)
Okay, refactored.

New API

var incCallback(pfsInfo) {
    pfsInfo.name;
    pfsInfo.url;
    pfsInfo.icon_url;
};
var finishedCallback() {};

Pfs.knownPluginsByMimeType(navigatorInfo, "application/x-shockwave-flash", incCallback, finishedCallback);

Notes:
Incremental callback will be called more than once for a mime-type that has multiple known plugins. video/quicktime would get DivX, QuickTime, etc.

I've changed the input and outputs to give knownPluginsByMimeType a unique interface, but we still use the underlying pfs/v2 API. This should allow us to create a new API call on the backend w/o changing the interface, if we want optimize down the road.

This new API means we need to start populating the fields from Comment#6 on the latest release of each plugin. Currently these aren't used.

If this sounds good, I'll check-in.
Blocks: 566003
@dtownsend - Please comment on Comment#8 and I'll check-in. Assigning to rdoherty to coordinate. Thanks!
(In reply to comment #8)
> (In reply to comment #7)
> Okay, refactored.
> 
> New API
> 
> var incCallback(pfsInfo) {
>     pfsInfo.name;
>     pfsInfo.url;
>     pfsInfo.icon_url;
> };
> var finishedCallback() {};
> 
> Pfs.knownPluginsByMimeType(navigatorInfo, "application/x-shockwave-flash",
> incCallback, finishedCallback);

This API looks good to me.

> Notes:
> Incremental callback will be called more than once for a mime-type that has
> multiple known plugins. video/quicktime would get DivX, QuickTime, etc.

Which one do we recommend to users in this case? I'm pretty sure the existing Pfs would only return a single plugin for a mimetype.
(In reply to comment #10)

The current API will also return multiple plugins, since all we have is navigator and mime-type info.

Example: On linux a vanilla Java mime-type would return "Ice Tea" a GNU plugin and Sun's Plugin. This happens for the old API and this new API.

Cool, thanks! I'll commit soon.
http://github.com/ozten/Perfidies-of-the-Web updated.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Mossop, any chance you can verify this?
(In reply to comment #13)
> Mossop, any chance you can verify this?

Probably not immediately, but I think I should have chance sometime this week.
You need to log in before you can comment on or make changes to this bug.