Bug 1316758-Remove nsContentUtils::LegacyIsCallerChromeOrNativeCode and IsCallerChrome calls from HTMLMediaElement. draft
authorKilik Kuo <kikuo@mozilla.com>
Fri, 18 Nov 2016 10:30:00 +0800
changeset 440742 9e4959bf1abdc275e08a20110dd15e2f8a3c77a6
parent 439375 79feeed4293336089590320a9f30a813fade8e3c
child 537454 38617971accbb0bd992f8e43cc53decfc091c727
push id36314
push userkikuo@mozilla.com
push dateFri, 18 Nov 2016 02:30:23 +0000
bugs1316758
milestone53.0a1
Bug 1316758-Remove nsContentUtils::LegacyIsCallerChromeOrNativeCode and IsCallerChrome calls from HTMLMediaElement. MozReview-Commit-ID: 47pOATtfflP
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1097,20 +1097,19 @@ static bool HasSourceChildren(nsIContent
   }
   return false;
 }
 
 NS_IMETHODIMP HTMLMediaElement::Load()
 {
   LOG(LogLevel::Debug,
       ("%p Load() hasSrcAttrStream=%d hasSrcAttr=%d hasSourceChildren=%d "
-       "handlingInput=%d isCallerChromeOrNative=%d",
+       "handlingInput=%d",
        this, !!mSrcAttrStream, HasAttr(kNameSpaceID_None, nsGkAtoms::src),
-       HasSourceChildren(this), EventStateManager::IsHandlingUserInput(),
-       nsContentUtils::LegacyIsCallerChromeOrNativeCode()));
+       HasSourceChildren(this), EventStateManager::IsHandlingUserInput()));
 
   if (mIsRunningLoadMethod) {
     return NS_OK;
   }
 
   mIsDoingExplicitLoad = true;
   DoLoad();
 
@@ -1122,18 +1121,17 @@ void HTMLMediaElement::DoLoad()
   if (mIsRunningLoadMethod) {
     return;
   }
 
   // Detect if user has interacted with element so that play will not be
   // blocked when initiated by a script. This enables sites to capture user
   // intent to play by calling load() in the click handler of a "catalog
   // view" of a gallery of videos.
-  if (EventStateManager::IsHandlingUserInput() ||
-      nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
+  if (EventStateManager::IsHandlingUserInput()) {
     mHasUserInteraction = true;
   }
 
   SetPlayedOrSeeked(false);
   mIsRunningLoadMethod = true;
   AbortExistingLoads();
   SetPlaybackRate(mDefaultPlaybackRate);
   QueueSelectResourceTask();
@@ -1844,17 +1842,17 @@ HTMLMediaElement::Seek(double aTime,
   RefPtr<Promise> promise = Promise::Create(global, aRv);
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // Detect if user has interacted with element by seeking so that
   // play will not be blocked when initiated by a script.
-  if (EventStateManager::IsHandlingUserInput() || nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
+  if (EventStateManager::IsHandlingUserInput()) {
     mHasUserInteraction = true;
   }
 
   StopSuspendingAfterFirstFrame();
 
   if (mSrcStream) {
     // do nothing since media streams have an empty Seekable range.
     promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -6034,18 +6032,17 @@ HTMLMediaElement::IsSuspendedByAudioChan
 
 bool
 HTMLMediaElement::IsAllowedToPlay()
 {
   // Prevent media element from being auto-started by a script when
   // media.autoplay.enabled=false
   if (!mHasUserInteraction &&
       !IsAutoplayEnabled() &&
-      !EventStateManager::IsHandlingUserInput() &&
-      !nsContentUtils::IsCallerChrome()) {
+      !EventStateManager::IsHandlingUserInput()) {
 #if defined(MOZ_WIDGET_ANDROID)
     nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                          static_cast<nsIContent*>(this),
                                          NS_LITERAL_STRING("MozAutoplayMediaBlocked"),
                                          false,
                                          false);
 #endif
     return false;