Bug 1349456 part 2 - mark elemet as tainted while captured via MozCaptureStream(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 22 Mar 2017 14:46:09 +0800
changeset 502692 8e68361d4eb1455093ad567ad5b70029093a967a
parent 502691 8da99bc68333c7ed3849563167f00533070b848d
child 502693 e3d9be125ef24e72c2e9930a8d0ffb2dfbcbaea4
push id50358
push userbmo:kaku@mozilla.com
push dateWed, 22 Mar 2017 07:06:35 +0000
reviewersjwwang
bugs1349456
milestone55.0a1
Bug 1349456 part 2 - mark elemet as tainted while captured via MozCaptureStream(); r?jwwang MozReview-Commit-ID: 1V776bLuH43
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1527,22 +1527,17 @@ HTMLMediaElement::SetVisible(bool aVisib
   }
 
   mDecoder->SetForcedHidden(!aVisible);
 }
 
 already_AddRefed<layers::Image>
 HTMLMediaElement::GetCurrentImage()
 {
-  // Mark the decoder owned by the element as tainted so that the
-  // suspend-video-decoder is disabled.
-  mHasSuspendTaint = true;
-  if (mDecoder) {
-    mDecoder->SetSuspendTaint(true);
-  }
+  MarkAsTainted();
 
   // TODO: In bug 1345404, handle case when video decoder is already suspended.
   ImageContainer* container = GetImageContainer();
   if (!container) {
     return nullptr;
   }
 
   AutoLockImage lockImage(container);
@@ -3330,16 +3325,17 @@ HTMLMediaElement::AddCaptureMediaTrackTo
 already_AddRefed<DOMMediaStream>
 HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded,
                                         bool aCaptureAudio,
                                         MediaStreamGraph* aGraph)
 {
   MOZ_RELEASE_ASSERT(aGraph);
 
   MarkAsContentSource(CallerAPI::CAPTURE_STREAM);
+  MarkAsTainted();
 
   nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
   if (!window) {
     return nullptr;
   }
   if (ContainsRestrictedContent()) {
     return nullptr;
   }
@@ -7486,16 +7482,26 @@ private:
 };
 
 already_AddRefed<GMPCrashHelper>
 HTMLMediaElement::CreateGMPCrashHelper()
 {
   return MakeAndAddRef<MediaElementGMPCrashHelper>(this);
 }
 
+void
+HTMLMediaElement::MarkAsTainted()
+{
+  mHasSuspendTaint = true;
+
+  if (mDecoder) {
+    mDecoder->SetSuspendTaint(true);
+  }
+}
+
 bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
 {
   return nsContentUtils::CallerHasPermission(aCx,
                                              NS_LITERAL_STRING("debugger"));
  }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1305,16 +1305,20 @@ protected:
   // and queues a task to resolve them also to dispatch a "playing" event.
   void NotifyAboutPlaying();
 
   already_AddRefed<Promise> CreateDOMPromise(ErrorResult& aRv) const;
 
   // Pass information for deciding the video decode mode to decoder.
   void NotifyDecoderActivityChanges() const;
 
+  // Mark the decoder owned by the element as tainted so that the
+  // suspend-video-decoder is disabled.
+  void MarkAsTainted();
+
   // The current decoder. Load() has been called on this decoder.
   // At most one of mDecoder and mSrcStream can be non-null.
   RefPtr<MediaDecoder> mDecoder;
 
   // The DocGroup-specific AbstractThread::MainThread() of this HTML element.
   RefPtr<AbstractThread> mAbstractMainThread;
 
   // Observers listening to changes to the mDecoder principal.