Bug 848994 - p5. Check Silverlight presence - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 22 Apr 2016 13:42:11 +1000
changeset 294417 0843709b5d55e352fc464a43619bb982a4af6487
parent 294416 1c4133b49948431d4c98d0e9bde33eb6f38f3916
child 294418 4f09b3b6b8e9181652c1a005898ee019ddc11456
push id75530
push usergsquelart@mozilla.com
push dateFri, 22 Apr 2016 03:42:29 +0000
treeherdermozilla-inbound@e07d236d6566 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs848994
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 848994 - p5. Check Silverlight presence - r=cpearce MozReview-Commit-ID: JRzyIWmMTtf
dom/media/DecoderDoctorDiagnostics.cpp
--- 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;