Bug 736400 - Make each decoder Clone() method check if its mimetype is enabled. r=cpearce
authorChristopher De Cairos <chris@chrisdecairos.ca>
Fri, 30 Mar 2012 20:52:07 -0400
changeset 90764 391418d235a8d2a033a68736c8f959a425630a97
parent 90763 f430bb8a0049068fb0e70658c0c935d2de7c4e08
child 90765 cbf3b105189b31953f46dabc0fae9873ff5e970a
push id22382
push userbmo@edmorley.co.uk
push dateSat, 31 Mar 2012 21:44:34 +0000
treeherdermozilla-central@bbe5086163c9 [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,24 +1707,25 @@ 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()) {
+  if (!nsHTMLMediaElement::IsRawEnabled()) {
     return false;
   }
 
   for (PRUint32 i = 0; i < ArrayLength(gRawTypes); ++i) {
     if (aType.EqualsASCII(gRawTypes[i])) {
       return true;
     }
   }
--- 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