Bug 736400 - Make each decoder Clone() method check if its mimetype is enabled r=cpearce
authorChristopher De Cairos
Mon, 26 Mar 2012 14:21:53 +1300
changeset 90277 4ad6c040729f220a079a0c771117ef973375c7ba
parent 90276 b95853f361bf9efc9d0dcb0bdd763a34837a4408
child 90278 95c4ed9b56f2d35e296b51691fe93b3f65461f4b
push id7559
push usercpearce@mozilla.com
push dateMon, 26 Mar 2012 01:23:57 +0000
treeherdermozilla-inbound@4ad6c040729f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs736400
milestone14.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 736400 - Make each decoder Clone() method check if its mimetype is enabled r=cpearce
content/html/content/public/nsHTMLMediaElement.h
content/html/content/src/nsHTMLMediaElement.cpp
content/media/ogg/nsOggDecoder.h
content/media/raw/nsRawDecoder.h
content/media/wave/nsWaveDecoder.h
content/media/webm/nsWebMDecoder.h
--- a/content/html/content/public/nsHTMLMediaElement.h
+++ b/content/html/content/public/nsHTMLMediaElement.h
@@ -272,16 +272,20 @@ public:
   static CanPlayStatus GetCanPlay(const nsAString& aType);
 
   // Returns true if we should handle this MIME type when it appears
   // as an <object> or as a toplevel page. If, in practice, our support
   // for the type is more limited than appears in the wild, we should return
   // false here even if CanHandleMediaType would return true.
   static bool ShouldHandleMediaType(const char* aMIMEType);
 
+#ifdef MOZ_RAW
+  static bool IsRawEnabled();
+#endif
+
 #ifdef MOZ_OGG
   static bool IsOggEnabled();
   static bool IsOggType(const nsACString& aType);
   static const char gOggTypes[3][16];
   static char const *const gOggCodecs[3];
 #endif
 
 #ifdef MOZ_WAVE
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -1707,17 +1707,18 @@ static const char gRawTypes[][16] = {
   "video/x-raw",
   "video/x-raw-yuv"
 };
 
 static const char* gRawCodecs[] = {
   nsnull
 };
 
-static bool IsRawEnabled()
+bool
+nsHTMLMediaElement::IsRawEnabled()
 {
   return Preferences::GetBool("media.raw.enabled");
 }
 
 static bool IsRawType(const nsACString& aType)
 {
   if (!IsRawEnabled()) {
     return false;
--- a/content/media/ogg/nsOggDecoder.h
+++ b/content/media/ogg/nsOggDecoder.h
@@ -39,13 +39,18 @@
 #if !defined(nsOggDecoder_h_)
 #define nsOggDecoder_h_
 
 #include "nsBuiltinDecoder.h"
 
 class nsOggDecoder : public nsBuiltinDecoder
 {
 public:
-  virtual nsMediaDecoder* Clone() { return new nsOggDecoder(); }
+  virtual nsMediaDecoder* Clone() {
+    if (!nsHTMLMediaElement::IsOggEnabled()) {
+      return nsnull;
+    }
+    return new nsOggDecoder();
+  }
   virtual nsDecoderStateMachine* CreateStateMachine();
 };
 
 #endif
--- a/content/media/raw/nsRawDecoder.h
+++ b/content/media/raw/nsRawDecoder.h
@@ -37,13 +37,18 @@
 #if !defined(nsRawDecoder_h_)
 #define nsRawDecoder_h_
 
 #include "nsBuiltinDecoder.h"
 
 class nsRawDecoder : public nsBuiltinDecoder
 {
 public:
-  virtual nsMediaDecoder* Clone() { return new nsRawDecoder(); }
+  virtual nsMediaDecoder* Clone() { 
+    if (!nsHTMLMediaElement::IsRawEnabled()) {
+      return nsnull;
+    }    
+    return new nsRawDecoder();
+  }
   virtual nsDecoderStateMachine* CreateStateMachine();
 };
 
 #endif
--- a/content/media/wave/nsWaveDecoder.h
+++ b/content/media/wave/nsWaveDecoder.h
@@ -50,13 +50,18 @@
  * require extending nsWaveDecoder to support parsing the newer
  * WAVE_FORMAT_EXTENSIBLE chunk format.
 **/
 
 
 class nsWaveDecoder : public nsBuiltinDecoder
 {
 public:
-   virtual nsMediaDecoder* Clone() { return new nsWaveDecoder(); }
-   virtual nsDecoderStateMachine* CreateStateMachine();
+  virtual nsMediaDecoder* Clone() {
+    if (!nsHTMLMediaElement::IsWaveEnabled()) {
+      return nsnull;
+    }
+    return new nsWaveDecoder();
+  }
+  virtual nsDecoderStateMachine* CreateStateMachine();
 };
 
 #endif
--- a/content/media/webm/nsWebMDecoder.h
+++ b/content/media/webm/nsWebMDecoder.h
@@ -39,13 +39,18 @@
 #if !defined(nsWebMDecoder_h_)
 #define nsWebMDecoder_h_
 
 #include "nsBuiltinDecoder.h"
 
 class nsWebMDecoder : public nsBuiltinDecoder
 {
 public:
-  virtual nsMediaDecoder* Clone() { return new nsWebMDecoder(); }
+  virtual nsMediaDecoder* Clone() {
+    if (!nsHTMLMediaElement::IsWebMEnabled()) {
+      return nsnull;
+    }
+    return new nsWebMDecoder();
+  }
   virtual nsDecoderStateMachine* CreateStateMachine();
 };
 
 #endif