Is Using Pepper Flash?

by James Greene

JavaScript

// NOTE: Some code taken from this StackOverflow question:
//   http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript
 
var isUsingPepperFlash = (function() {
    var getFlashPlayerFileName = function(mimeTypes, type) {
        return (
            mimeTypes &&
            mimeTypes[type] &&
            mimeTypes[type].enabledPlugin &&
            mimeTypes[type].enabledPlugin.filename
        ) || '';
    };
 
    return function() {
        var isPPAPI = false;
        
        var mimeTypes = window.navigator.mimeTypes;
        var flashMimeType = "application/x-shockwave-flash";
        var flashPlayerFileName = getFlashPlayerFileName(mimeTypes, flashMimeType).toLowerCase();
        if (flashPlayerFileName &&
            (flashPlayerFileName === "pepflashplayer.dll" ||
            flashPlayerFileName === "libpepflashplayer.so" ||
            flashPlayerFileName === "pepperflashplayer.plugin" ||
            flashPlayerFileName.slice(-13) === "chrome.plugin"))
        {
            isPPAPI = true;
        }
        return isPPAPI;
    };
})();

document.body.innerHTML = "<b>Using Pepper Flash?</b> " + isUsingPepperFlash();