Bug 848994 - p5. Check Silverlight presence - r?cpearce
MozReview-Commit-ID: JRzyIWmMTtf
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -8,16 +8,17 @@
#include "mozilla/dom/DecoderDoctorNotificationBinding.h"
#include "mozilla/Logging.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsIObserverService.h"
#include "nsITimer.h"
#include "nsIWeakReference.h"
+#include "nsPluginHost.h"
static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
#define DD_LOG(level, arg, ...) MOZ_LOG(sDecoderDoctorLog, level, (arg, ##__VA_ARGS__))
#define DD_DEBUG(arg, ...) DD_LOG(mozilla::LogLevel::Debug, arg, ##__VA_ARGS__)
#define DD_INFO(arg, ...) DD_LOG(mozilla::LogLevel::Info, arg, ##__VA_ARGS__)
#define DD_WARN(arg, ...) DD_LOG(mozilla::LogLevel::Warning, arg, ##__VA_ARGS__)
namespace mozilla
@@ -288,16 +289,43 @@ DecoderDoctorDocumentWatcher::ReportAnal
// For now, disable all front-end notifications by default.
// TODO: Future bugs will use finer-grained filtering instead.
if (Preferences::GetBool("media.decoderdoctor.enable-notification-bar", false)) {
DispatchNotification(
mDocument->GetInnerWindow(), aNotificationType, aFormats);
}
}
+enum SilverlightPresence {
+ eNoSilverlight,
+ eSilverlightDisabled,
+ eSilverlightEnabled
+};
+static SilverlightPresence
+CheckSilverlight()
+{
+ MOZ_ASSERT(NS_IsMainThread());
+ RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
+ if (!pluginHost) {
+ return eNoSilverlight;
+ }
+ nsTArray<nsCOMPtr<nsIInternalPluginTag>> plugins;
+ pluginHost->GetPlugins(plugins, /*aIncludeDisabled*/ true);
+ for (const auto& plugin : plugins) {
+ for (const auto& mime : plugin->MimeTypes()) {
+ if (mime.LowerCaseEqualsLiteral("application/x-silverlight")
+ || mime.LowerCaseEqualsLiteral("application/x-silverlight-2")) {
+ return plugin->IsEnabled() ? eSilverlightEnabled : eSilverlightDisabled;
+ }
+ }
+ }
+
+ return eNoSilverlight;
+}
+
void
DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
{
MOZ_ASSERT(NS_IsMainThread());
bool canPlay = false;
#if defined(MOZ_FFMPEG)
bool FFMpegNeeded = false;