Bug 1299390 - part 1: Remove BrowserElementAudioChannel. r=alwu draft
authorbtian <btian@mozilla.com>
Tue, 16 May 2017 10:53:33 +0800
changeset 578595 cd01ee2e7990925ceacd31d5d8ff9d519ef5ff62
parent 578175 3e166b6838931b3933ca274331f9e0e115af5cc0
child 578596 1f807d085cceeda04f6c7bf523538d08e22604f2
child 578600 8749e471f52a1f6e74f47c3778bae8d6cb2ea268
push id58978
push userbmo:btian@mozilla.com
push dateTue, 16 May 2017 07:56:34 +0000
reviewersalwu
bugs1299390
milestone55.0a1
Bug 1299390 - part 1: Remove BrowserElementAudioChannel. r=alwu MozReview-Commit-ID: GVBadeQsths
dom/browser-element/BrowserElementAudioChannel.cpp
dom/browser-element/BrowserElementAudioChannel.h
dom/browser-element/BrowserElementParent.cpp
dom/browser-element/moz.build
dom/html/nsBrowserElement.cpp
dom/html/nsBrowserElement.h
dom/html/nsGenericHTMLFrameElement.cpp
dom/webidl/BrowserElement.webidl
dom/webidl/BrowserElementAudioChannel.webidl
dom/webidl/moz.build
deleted file mode 100644
--- a/dom/browser-element/BrowserElementAudioChannel.cpp
+++ /dev/null
@@ -1,591 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "BrowserElementAudioChannel.h"
-
-#include "mozilla/Preferences.h"
-#include "mozilla/Services.h"
-#include "mozilla/dom/BrowserElementAudioChannelBinding.h"
-#include "mozilla/dom/DOMRequest.h"
-#include "mozilla/dom/Element.h"
-#include "mozilla/dom/TabParent.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "AudioChannelService.h"
-#include "nsContentUtils.h"
-#include "nsIBrowserElementAPI.h"
-#include "nsIDocShell.h"
-#include "nsIDOMDOMRequest.h"
-#include "nsIObserverService.h"
-#include "nsISupportsPrimitives.h"
-#include "nsITabParent.h"
-#include "nsPIDOMWindow.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_ADDREF_INHERITED(BrowserElementAudioChannel, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(BrowserElementAudioChannel, DOMEventTargetHelper)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BrowserElementAudioChannel)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(BrowserElementAudioChannel,
-                                   DOMEventTargetHelper,
-                                   mFrameLoader,
-                                   mFrameWindow,
-                                   mTabParent,
-                                   mBrowserElementAPI)
-
-/* static */ already_AddRefed<BrowserElementAudioChannel>
-BrowserElementAudioChannel::Create(nsPIDOMWindowInner* aWindow,
-                                   nsIFrameLoader* aFrameLoader,
-                                   nsIBrowserElementAPI* aAPI,
-                                   AudioChannel aAudioChannel,
-                                   ErrorResult& aRv)
-{
-  RefPtr<BrowserElementAudioChannel> ac =
-    new BrowserElementAudioChannel(aWindow, aFrameLoader, aAPI, aAudioChannel);
-
-  aRv = ac->Initialize();
-  if (NS_WARN_IF(aRv.Failed())) {
-    return nullptr;
-  }
-
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("BrowserElementAudioChannel, Create, channel = %p, type = %" PRIu32 "\n",
-          ac.get(), static_cast<uint32_t>(aAudioChannel)));
-
-  return ac.forget();
-}
-
-BrowserElementAudioChannel::BrowserElementAudioChannel(
-						nsPIDOMWindowInner* aWindow,
-						nsIFrameLoader* aFrameLoader,
-                                                nsIBrowserElementAPI* aAPI,
-                                                AudioChannel aAudioChannel)
-  : DOMEventTargetHelper(aWindow)
-  , mFrameLoader(aFrameLoader)
-  , mBrowserElementAPI(aAPI)
-  , mAudioChannel(aAudioChannel)
-  , mState(eStateUnknown)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  if (obs) {
-    nsAutoString name;
-    AudioChannelService::GetAudioChannelString(aAudioChannel, name);
-
-    nsAutoCString topic;
-    topic.Assign("audiochannel-activity-");
-    topic.Append(NS_ConvertUTF16toUTF8(name));
-
-    obs->AddObserver(this, topic.get(), true);
-  }
-}
-
-BrowserElementAudioChannel::~BrowserElementAudioChannel()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  if (obs) {
-    nsAutoString name;
-    AudioChannelService::GetAudioChannelString(mAudioChannel, name);
-
-    nsAutoCString topic;
-    topic.Assign("audiochannel-activity-");
-    topic.Append(NS_ConvertUTF16toUTF8(name));
-
-    obs->RemoveObserver(this, topic.get());
-  }
-}
-
-nsresult
-BrowserElementAudioChannel::Initialize()
-{
-  if (!mFrameLoader) {
-    nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-    if (!window) {
-      return NS_ERROR_FAILURE;
-    }
-
-    mFrameWindow = window->GetScriptableTop();
-    mFrameWindow = mFrameWindow->GetOuterWindow();
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIDocShell> docShell;
-  nsresult rv = mFrameLoader->GetDocShell(getter_AddRefs(docShell));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  if (docShell) {
-    nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow();
-    if (!window) {
-      return NS_ERROR_FAILURE;
-    }
-
-    mFrameWindow = window->GetScriptableTop();
-    mFrameWindow = mFrameWindow->GetOuterWindow();
-    return NS_OK;
-  }
-
-  rv = mFrameLoader->GetTabParent(getter_AddRefs(mTabParent));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  MOZ_ASSERT(mTabParent);
-  return NS_OK;
-}
-
-JSObject*
-BrowserElementAudioChannel::WrapObject(JSContext *aCx,
-                                       JS::Handle<JSObject*> aGivenProto)
-{
-  return BrowserElementAudioChannelBinding::Wrap(aCx, this, aGivenProto);
-}
-
-AudioChannel
-BrowserElementAudioChannel::Name() const
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  return mAudioChannel;
-}
-
-namespace {
-
-class BaseRunnable : public Runnable
-{
-protected:
-  nsCOMPtr<nsPIDOMWindowInner> mParentWindow;
-  nsCOMPtr<nsPIDOMWindowOuter> mFrameWindow;
-  RefPtr<DOMRequest> mRequest;
-  AudioChannel mAudioChannel;
-
-  virtual void DoWork(AudioChannelService* aService,
-                      JSContext* aCx) = 0;
-
-public:
-  BaseRunnable(nsPIDOMWindowInner* aParentWindow,
-	       nsPIDOMWindowOuter* aFrameWindow,
-               DOMRequest* aRequest, AudioChannel aAudioChannel)
-    : mParentWindow(aParentWindow)
-    , mFrameWindow(aFrameWindow)
-    , mRequest(aRequest)
-    , mAudioChannel(aAudioChannel)
-  {}
-
-  NS_IMETHOD Run() override
-  {
-    RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-    if (!service) {
-      return NS_OK;
-    }
-
-    AutoJSAPI jsapi;
-    if (!jsapi.Init(mParentWindow)) {
-      mRequest->FireError(NS_ERROR_FAILURE);
-      return NS_OK;
-    }
-
-    DoWork(service, jsapi.cx());
-    return NS_OK;
-  }
-};
-
-class GetVolumeRunnable final : public BaseRunnable
-{
-public:
-  GetVolumeRunnable(nsPIDOMWindowInner* aParentWindow,
-		    nsPIDOMWindowOuter* aFrameWindow,
-                    DOMRequest* aRequest, AudioChannel aAudioChannel)
-    : BaseRunnable(aParentWindow, aFrameWindow, aRequest, aAudioChannel)
-  {}
-
-protected:
-  void DoWork(AudioChannelService* aService, JSContext* aCx) override
-  {
-    float volume = aService->GetAudioChannelVolume(mFrameWindow, mAudioChannel);
-
-    JS::Rooted<JS::Value> value(aCx);
-    if (!ToJSValue(aCx, volume, &value)) {
-      mRequest->FireError(NS_ERROR_FAILURE);
-      return;
-    }
-
-    mRequest->FireSuccess(value);
-  }
-};
-
-class GetMutedRunnable final : public BaseRunnable
-{
-public:
-  GetMutedRunnable(nsPIDOMWindowInner* aParentWindow,
-		   nsPIDOMWindowOuter* aFrameWindow,
-                   DOMRequest* aRequest, AudioChannel aAudioChannel)
-    : BaseRunnable(aParentWindow, aFrameWindow, aRequest, aAudioChannel)
-  {}
-
-protected:
-  void DoWork(AudioChannelService* aService, JSContext* aCx) override
-  {
-    bool muted = aService->GetAudioChannelMuted(mFrameWindow, mAudioChannel);
-
-    JS::Rooted<JS::Value> value(aCx);
-    if (!ToJSValue(aCx, muted, &value)) {
-      mRequest->FireError(NS_ERROR_FAILURE);
-      return;
-    }
-
-    mRequest->FireSuccess(value);
-  }
-};
-
-class IsActiveRunnable final : public BaseRunnable
-{
-  bool mActive;
-  bool mValueKnown;
-
-public:
-  IsActiveRunnable(nsPIDOMWindowInner* aParentWindow,
-		   nsPIDOMWindowOuter* aFrameWindow,
-                   DOMRequest* aRequest, AudioChannel aAudioChannel,
-                   bool aActive)
-    : BaseRunnable(aParentWindow, aFrameWindow, aRequest, aAudioChannel)
-    , mActive(aActive)
-    , mValueKnown(true)
-  {}
-
-  IsActiveRunnable(nsPIDOMWindowInner* aParentWindow,
-		   nsPIDOMWindowOuter* aFrameWindow,
-                   DOMRequest* aRequest, AudioChannel aAudioChannel)
-    : BaseRunnable(aParentWindow, aFrameWindow, aRequest, aAudioChannel)
-    , mActive(true)
-    , mValueKnown(false)
-  {}
-
-protected:
-  void DoWork(AudioChannelService* aService, JSContext* aCx) override
-  {
-    if (!mValueKnown) {
-      mActive = aService->IsAudioChannelActive(mFrameWindow, mAudioChannel);
-    }
-
-    JS::Rooted<JS::Value> value(aCx);
-    if (!ToJSValue(aCx, mActive, &value)) {
-      mRequest->FireError(NS_ERROR_FAILURE);
-      return;
-    }
-
-    mRequest->FireSuccess(value);
-  }
-};
-
-class FireSuccessRunnable final : public BaseRunnable
-{
-public:
-  FireSuccessRunnable(nsPIDOMWindowInner* aParentWindow,
-		      nsPIDOMWindowOuter* aFrameWindow,
-                      DOMRequest* aRequest, AudioChannel aAudioChannel)
-    : BaseRunnable(aParentWindow, aFrameWindow, aRequest, aAudioChannel)
-  {}
-
-protected:
-  void DoWork(AudioChannelService* aService, JSContext* aCx) override
-  {
-    JS::Rooted<JS::Value> value(aCx);
-    mRequest->FireSuccess(value);
-  }
-};
-
-} // anonymous namespace
-
-already_AddRefed<dom::DOMRequest>
-BrowserElementAudioChannel::GetVolume(ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mFrameWindow) {
-    nsCOMPtr<nsIDOMDOMRequest> request;
-    aRv = mBrowserElementAPI->GetAudioChannelVolume((uint32_t)mAudioChannel,
-                                                    getter_AddRefs(request));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return nullptr;
-    }
-
-    return request.forget().downcast<DOMRequest>();
-  }
-
-  RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new GetVolumeRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel);
-  NS_DispatchToMainThread(runnable);
-
-  return domRequest.forget();
-}
-
-already_AddRefed<dom::DOMRequest>
-BrowserElementAudioChannel::SetVolume(float aVolume, ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mFrameWindow) {
-    nsCOMPtr<nsIDOMDOMRequest> request;
-    aRv = mBrowserElementAPI->SetAudioChannelVolume((uint32_t)mAudioChannel,
-                                                    aVolume,
-                                                    getter_AddRefs(request));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return nullptr;
-    }
-
-    return request.forget().downcast<DOMRequest>();
-  }
-
-  RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-  if (service) {
-    service->SetAudioChannelVolume(mFrameWindow, mAudioChannel, aVolume);
-  }
-
-  RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-  nsCOMPtr<nsIRunnable> runnable = new FireSuccessRunnable(GetOwner(),
-                                                           mFrameWindow,
-                                                           domRequest,
-                                                           mAudioChannel);
-  NS_DispatchToMainThread(runnable);
-
-  return domRequest.forget();
-}
-
-already_AddRefed<dom::DOMRequest>
-BrowserElementAudioChannel::GetMuted(ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mFrameWindow) {
-    nsCOMPtr<nsIDOMDOMRequest> request;
-    aRv = mBrowserElementAPI->GetAudioChannelMuted((uint32_t)mAudioChannel,
-                                                   getter_AddRefs(request));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return nullptr;
-    }
-
-    return request.forget().downcast<DOMRequest>();
-  }
-
-  RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new GetMutedRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel);
-  NS_DispatchToMainThread(runnable);
-
-  return domRequest.forget();
-}
-
-already_AddRefed<dom::DOMRequest>
-BrowserElementAudioChannel::SetMuted(bool aMuted, ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mFrameWindow) {
-    nsCOMPtr<nsIDOMDOMRequest> request;
-    aRv = mBrowserElementAPI->SetAudioChannelMuted((uint32_t)mAudioChannel,
-                                                   aMuted,
-                                                   getter_AddRefs(request));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return nullptr;
-    }
-
-    return request.forget().downcast<DOMRequest>();
-  }
-
-  RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-  if (service) {
-    service->SetAudioChannelMuted(mFrameWindow, mAudioChannel, aMuted);
-  }
-
-  RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-  nsCOMPtr<nsIRunnable> runnable = new FireSuccessRunnable(GetOwner(),
-                                                           mFrameWindow,
-                                                           domRequest,
-                                                           mAudioChannel);
-  NS_DispatchToMainThread(runnable);
-
-  return domRequest.forget();
-}
-
-already_AddRefed<dom::DOMRequest>
-BrowserElementAudioChannel::IsActive(ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (mState != eStateUnknown) {
-    RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-
-    nsCOMPtr<nsIRunnable> runnable =
-      new IsActiveRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel,
-                           mState == eStateActive);
-    NS_DispatchToMainThread(runnable);
-
-    return domRequest.forget();
-  }
-
-  if (!mFrameWindow) {
-    nsCOMPtr<nsIDOMDOMRequest> request;
-    aRv = mBrowserElementAPI->IsAudioChannelActive((uint32_t)mAudioChannel,
-                                                   getter_AddRefs(request));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return nullptr;
-    }
-
-    return request.forget().downcast<DOMRequest>();
-  }
-
-  RefPtr<DOMRequest> domRequest = new DOMRequest(GetOwner());
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new IsActiveRunnable(GetOwner(), mFrameWindow, domRequest, mAudioChannel);
-  NS_DispatchToMainThread(runnable);
-
-  return domRequest.forget();
-}
-
-NS_IMETHODIMP
-BrowserElementAudioChannel::Observe(nsISupports* aSubject, const char* aTopic,
-                                    const char16_t* aData)
-{
-  nsAutoString name;
-  AudioChannelService::GetAudioChannelString(mAudioChannel, name);
-
-  nsAutoCString topic;
-  topic.Assign("audiochannel-activity-");
-  topic.Append(NS_ConvertUTF16toUTF8(name));
-
-  if (strcmp(topic.get(), aTopic)) {
-    return NS_OK;
-  }
-
-  // Message received from the child.
-  if (!mFrameWindow) {
-    if (mTabParent == aSubject) {
-      ProcessStateChanged(aData);
-    }
-
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(aSubject);
-  if (!wrapper) {
-    bool isNested = false;
-    nsresult rv = IsFromNestedFrame(aSubject, isNested);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
-    if (isNested) {
-      ProcessStateChanged(aData);
-    }
-
-    return NS_OK;
-  }
-
-  uint64_t windowID;
-  nsresult rv = wrapper->GetData(&windowID);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  if (windowID != mFrameWindow->WindowID()) {
-    return NS_OK;
-  }
-
-  ProcessStateChanged(aData);
-  return NS_OK;
-}
-
-void
-BrowserElementAudioChannel::ProcessStateChanged(const char16_t* aData)
-{
-  MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("BrowserElementAudioChannel, ProcessStateChanged, this = %p, "
-          "type = %" PRIu32 "\n", this, static_cast<uint32_t>(mAudioChannel)));
-
-  nsAutoString value(aData);
-  mState = value.EqualsASCII("active") ? eStateActive : eStateInactive;
-  DispatchTrustedEvent(NS_LITERAL_STRING("activestatechanged"));
-}
-
-bool
-BrowserElementAudioChannel::IsSystemAppWindow(nsPIDOMWindowOuter* aWindow) const
-{
-  nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
-  if (!doc) {
-    return false;
-  }
-
-  if (nsContentUtils::IsChromeDoc(doc)) {
-    return true;
-  }
-
-  nsAdoptingCString systemAppUrl =
-    mozilla::Preferences::GetCString("b2g.system_startup_url");
-  if (!systemAppUrl) {
-    return false;
-  }
-
-  nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
-  nsCOMPtr<nsIURI> uri;
-  principal->GetURI(getter_AddRefs(uri));
-
-  if (uri) {
-    nsAutoCString spec;
-    uri->GetSpec(spec);
-
-    if (spec.Equals(systemAppUrl)) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
-nsresult
-BrowserElementAudioChannel::IsFromNestedFrame(nsISupports* aSubject,
-                                              bool& aIsNested) const
-{
-  aIsNested = false;
-  nsCOMPtr<nsITabParent> iTabParent = do_QueryInterface(aSubject);
-  if (!iTabParent) {
-    return NS_ERROR_FAILURE;
-  }
-
-  RefPtr<TabParent> tabParent = TabParent::GetFrom(iTabParent);
-  if (!tabParent) {
-    return NS_ERROR_FAILURE;
-  }
-
-  Element* element = tabParent->GetOwnerElement();
-  if (!element) {
-    return NS_ERROR_FAILURE;
-  }
-
-  // Since the normal OOP processes are opened out from b2g process, the owner
-  // of their tabParent are the same - system app window. Therefore, in order
-  // to find the case of nested MozFrame, we need to exclude this situation.
-  nsCOMPtr<nsPIDOMWindowOuter> window = element->OwnerDoc()->GetWindow();
-  if (window == mFrameWindow && !IsSystemAppWindow(window)) {
-    aIsNested = true;
-    return NS_OK;
-  }
-
-  return NS_OK;
-}
-
-} // dom namespace
-} // mozilla namespace
deleted file mode 100644
--- a/dom/browser-element/BrowserElementAudioChannel.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_BrowserElementAudioChannels_h
-#define mozilla_dom_BrowserElementAudioChannels_h
-
-#include "mozilla/dom/AudioChannelBinding.h"
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/DOMEventTargetHelper.h"
-#include "mozilla/ErrorResult.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsIObserver.h"
-#include "nsIFrameLoader.h"
-#include "nsWeakReference.h"
-#include "nsWrapperCache.h"
-
-class nsIBrowserElementAPI;
-class nsITabParent;
-class nsPIDOMWindowOuter;
-
-namespace mozilla {
-namespace dom {
-
-class DOMRequest;
-
-class BrowserElementAudioChannel final : public DOMEventTargetHelper
-                                       , public nsSupportsWeakReference
-                                       , public nsIObserver
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIOBSERVER
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BrowserElementAudioChannel,
-                                           DOMEventTargetHelper)
-
-  static already_AddRefed<BrowserElementAudioChannel>
-  Create(nsPIDOMWindowInner* aWindow,
-         nsIFrameLoader* aFrameLoader,
-         nsIBrowserElementAPI* aAPI,
-         AudioChannel aAudioChannel,
-         ErrorResult& aRv);
-
-  // WebIDL methods
-
-  virtual JSObject* WrapObject(JSContext *aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
-  AudioChannel Name() const;
-
-  already_AddRefed<dom::DOMRequest> GetVolume(ErrorResult& aRv);
-  already_AddRefed<dom::DOMRequest> SetVolume(float aVolume, ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> GetMuted(ErrorResult& aRv);
-  already_AddRefed<dom::DOMRequest> SetMuted(bool aMuted, ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> IsActive(ErrorResult& aRv);
-
-  IMPL_EVENT_HANDLER(activestatechanged);
-
-private:
-  BrowserElementAudioChannel(nsPIDOMWindowInner* aWindow,
-                             nsIFrameLoader* aFrameLoader,
-                             nsIBrowserElementAPI* aAPI,
-                             AudioChannel aAudioChannel);
-
-  bool IsSystemAppWindow(nsPIDOMWindowOuter* aWindow) const;
-
-  // This method is used to check whether we're in the nested-mozbrower-frame
-  // situation, see bug1214148.
-  nsresult IsFromNestedFrame(nsISupports* aSubject,
-                             bool& aIsNested) const;
-
-  ~BrowserElementAudioChannel();
-
-  nsresult Initialize();
-
-  void ProcessStateChanged(const char16_t* aData);
-
-  nsCOMPtr<nsIFrameLoader> mFrameLoader;
-  nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI;
-  nsCOMPtr<nsITabParent> mTabParent;
-  nsCOMPtr<nsPIDOMWindowOuter> mFrameWindow;
-  AudioChannel mAudioChannel;
-
-  enum {
-    eStateActive,
-    eStateInactive,
-    eStateUnknown
-  } mState;
-};
-
-} // dom namespace
-} // mozilla namespace
-
-#endif // mozilla_dom_BrowserElementAudioChannels_h
--- a/dom/browser-element/BrowserElementParent.cpp
+++ b/dom/browser-element/BrowserElementParent.cpp
@@ -10,17 +10,16 @@
 //   #define CreateEvent CreateEventW
 // That messes up our call to EventDispatcher::CreateEvent below.
 
 #ifdef CreateEvent
 #undef CreateEvent
 #endif
 
 #include "BrowserElementParent.h"
-#include "BrowserElementAudioChannel.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/HTMLIFrameElement.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsVariant.h"
 #include "mozilla/dom/BrowserElementDictionariesBinding.h"
 #include "mozilla/dom/CustomEvent.h"
 #include "mozilla/layout/RenderFrameParent.h"
--- a/dom/browser-element/moz.build
+++ b/dom/browser-element/moz.build
@@ -6,22 +6,17 @@
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "DOM")
 
 EXPORTS.mozilla += [
     'BrowserElementParent.h',
 ]
 
-EXPORTS.mozilla.dom += [
-    'BrowserElementAudioChannel.h',
-]
-
 SOURCES += [
-    'BrowserElementAudioChannel.cpp',
     'BrowserElementParent.cpp',
 ]
 
 XPIDL_SOURCES += [
     'nsIBrowserElementAPI.idl',
 ]
 
 XPIDL_MODULE = 'browser-element'
--- a/dom/html/nsBrowserElement.cpp
+++ b/dom/html/nsBrowserElement.cpp
@@ -4,23 +4,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsBrowserElement.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/BrowserElementBinding.h"
-#include "mozilla/dom/BrowserElementAudioChannel.h"
 #include "mozilla/dom/DOMRequest.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/ToJSValue.h"
 
-#include "AudioChannelService.h"
-
 #include "nsComponentManagerUtils.h"
 #include "nsFrameLoader.h"
 #include "nsIDOMDOMRequest.h"
 #include "nsIDOMElement.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsINode.h"
 #include "nsIPrincipal.h"
 
@@ -452,137 +449,16 @@ nsBrowserElement::RemoveNextPaintListene
 
   nsresult rv = mBrowserElementAPI->RemoveNextPaintListener(listener);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
-void
-nsBrowserElement::GetAllowedAudioChannels(
-                 nsTArray<RefPtr<BrowserElementAudioChannel>>& aAudioChannels,
-                 ErrorResult& aRv)
-{
-  aAudioChannels.Clear();
-
-  // If empty, it means that this is the first call of this method.
-  if (mBrowserElementAudioChannels.IsEmpty()) {
-    nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
-    if (NS_WARN_IF(!frameLoader)) {
-      return;
-    }
-
-    bool isMozBrowser;
-    aRv = frameLoader->GetOwnerIsMozBrowserFrame(&isMozBrowser);
-    if (NS_WARN_IF(aRv.Failed())) {
-      return;
-    }
-
-    if (!isMozBrowser) {
-      return;
-    }
-
-    nsCOMPtr<nsIDOMElement> frameElement;
-    aRv = frameLoader->GetOwnerElement(getter_AddRefs(frameElement));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return;
-    }
-
-    MOZ_ASSERT(frameElement);
-
-    nsCOMPtr<nsIDOMDocument> doc;
-    aRv = frameElement->GetOwnerDocument(getter_AddRefs(doc));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return;
-    }
-
-    MOZ_ASSERT(doc);
-
-    nsCOMPtr<mozIDOMWindowProxy> win;
-    aRv = doc->GetDefaultView(getter_AddRefs(win));
-    if (NS_WARN_IF(aRv.Failed())) {
-      return;
-    }
-
-    MOZ_ASSERT(win);
-
-    auto* window = nsPIDOMWindowOuter::From(win);
-    nsPIDOMWindowInner* innerWindow = window->GetCurrentInnerWindow();
-
-    nsCOMPtr<nsIMozBrowserFrame> mozBrowserFrame =
-      do_QueryInterface(frameElement);
-    if (NS_WARN_IF(!mozBrowserFrame)) {
-      aRv.Throw(NS_ERROR_FAILURE);
-      return;
-    }
-
-    MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-            ("nsBrowserElement, GetAllowedAudioChannels, this = %p\n", this));
-
-    GenerateAllowedAudioChannels(innerWindow, frameLoader, mBrowserElementAPI,
-                                 mBrowserElementAudioChannels, aRv);
-    if (NS_WARN_IF(aRv.Failed())) {
-      return;
-    }
-  }
-
-  aAudioChannels.AppendElements(mBrowserElementAudioChannels);
-}
-
-/* static */ void
-nsBrowserElement::GenerateAllowedAudioChannels(
-                 nsPIDOMWindowInner* aWindow,
-                 nsIFrameLoader* aFrameLoader,
-                 nsIBrowserElementAPI* aAPI,
-                 nsTArray<RefPtr<BrowserElementAudioChannel>>& aAudioChannels,
-                 ErrorResult& aRv)
-{
-  MOZ_ASSERT(aAudioChannels.IsEmpty());
-
-  // Normal is always allowed.
-  nsTArray<RefPtr<BrowserElementAudioChannel>> channels;
-
-  RefPtr<BrowserElementAudioChannel> ac =
-    BrowserElementAudioChannel::Create(aWindow, aFrameLoader, aAPI,
-                                       AudioChannel::Normal, aRv);
-  if (NS_WARN_IF(aRv.Failed())) {
-    return;
-  }
-
-  channels.AppendElement(ac);
-
-  nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
-  if (NS_WARN_IF(!doc)) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  // Since we don't have permissions anymore let only chrome windows pick a
-  // non-default channel
-  if (nsContentUtils::IsChromeDoc(doc)) {
-    const nsAttrValue::EnumTable* audioChannelTable =
-      AudioChannelService::GetAudioChannelTable();
-
-    for (uint32_t i = 0; audioChannelTable && audioChannelTable[i].tag; ++i) {
-      AudioChannel value = (AudioChannel)audioChannelTable[i].value;
-      RefPtr<BrowserElementAudioChannel> ac =
-        BrowserElementAudioChannel::Create(aWindow, aFrameLoader, aAPI,
-                                           value, aRv);
-      if (NS_WARN_IF(aRv.Failed())) {
-        return;
-      }
-
-      channels.AppendElement(ac);
-    }
-  }
-
-  aAudioChannels.SwapElements(channels);
-}
-
 already_AddRefed<DOMRequest>
 nsBrowserElement::GetMuted(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->GetMuted(getter_AddRefs(req));
 
--- a/dom/html/nsBrowserElement.h
+++ b/dom/html/nsBrowserElement.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsBrowserElement_h
 #define nsBrowserElement_h
 
 #include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/dom/BrowserElementAudioChannel.h"
 
 #include "nsCOMPtr.h"
 #include "nsIBrowserElementAPI.h"
 
 class nsFrameLoader;
 
 namespace mozilla {
 
@@ -67,20 +66,16 @@ public:
 
   already_AddRefed<dom::DOMRequest>
   Download(const nsAString& aUrl,
            const dom::BrowserElementDownloadOptions& options,
            ErrorResult& aRv);
 
   already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv);
 
-  void GetAllowedAudioChannels(
-            nsTArray<RefPtr<dom::BrowserElementAudioChannel>>& aAudioChannels,
-            ErrorResult& aRv);
-
   void Mute(ErrorResult& aRv);
   void Unmute(ErrorResult& aRv);
   already_AddRefed<dom::DOMRequest> GetMuted(ErrorResult& aRv);
 
   void SetVolume(float aVolume , ErrorResult& aRv);
   already_AddRefed<dom::DOMRequest> GetVolume(ErrorResult& aRv);
 
   already_AddRefed<dom::DOMRequest>
@@ -106,31 +101,22 @@ public:
                                ErrorResult& aRv);
 
   already_AddRefed<dom::DOMRequest> ExecuteScript(const nsAString& aScript,
                                                   const dom::BrowserElementExecuteScriptOptions& aOptions,
                                                   ErrorResult& aRv);
 
   already_AddRefed<dom::DOMRequest> GetWebManifest(ErrorResult& aRv);
 
-  // Helper
-  static void GenerateAllowedAudioChannels(
-                 nsPIDOMWindowInner* aWindow,
-                 nsIFrameLoader* aFrameLoader,
-                 nsIBrowserElementAPI* aAPI,
-                 nsTArray<RefPtr<dom::BrowserElementAudioChannel>>& aAudioChannels,
-                 ErrorResult& aRv);
-
 protected:
   NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
 
   void InitBrowserElementAPI();
   void DestroyBrowserElementFrameScripts();
   nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI;
-  nsTArray<RefPtr<dom::BrowserElementAudioChannel>> mBrowserElementAudioChannels;
 
 private:
   bool IsBrowserElementOrThrow(ErrorResult& aRv);
 };
 
 } // namespace mozilla
 
 #endif // nsBrowserElement_h
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsGenericHTMLFrameElement.h"
 
-#include "mozilla/dom/BrowserElementAudioChannel.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/HTMLIFrameElement.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ErrorResult.h"
 #include "GeckoProfiler.h"
 #include "nsAttrValueInlines.h"
 #include "nsContentUtils.h"
 #include "nsIDocShell.h"
@@ -31,29 +30,27 @@ using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
                                                   nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameLoader)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserElementAPI)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserElementAudioChannels)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsGenericHTMLFrameElement,
                                                 nsGenericHTMLElement)
   if (tmp->mFrameLoader) {
     tmp->mFrameLoader->Destroy();
   }
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameLoader)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerWindow)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowserElementAPI)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowserElementAudioChannels)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ADDREF_INHERITED(nsGenericHTMLFrameElement, nsGenericHTMLElement)
 NS_IMPL_RELEASE_INHERITED(nsGenericHTMLFrameElement, nsGenericHTMLElement)
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsGenericHTMLFrameElement)
   NS_INTERFACE_TABLE_INHERITED(nsGenericHTMLFrameElement,
                                nsIFrameLoaderOwner,
--- a/dom/webidl/BrowserElement.webidl
+++ b/dom/webidl/BrowserElement.webidl
@@ -169,21 +169,16 @@ interface BrowserElementPrivileged {
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   DOMRequest getWebManifest();
 
 };
 
 // Bits needed for BrowserElementAudioChannel.
 partial interface BrowserElementPrivileged {
-  [Pure, Cached, Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  readonly attribute sequence<BrowserElementAudioChannel> allowedAudioChannels;
-
   /**
    * Mutes all audio in this browser.
    */
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   void mute();
 
deleted file mode 100644
--- a/dom/webidl/BrowserElementAudioChannel.webidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-[Pref="dom.mozBrowserFramesEnabled",
- ChromeOnly]
-interface BrowserElementAudioChannel : EventTarget {
-  readonly attribute AudioChannel name;
-
-  // This event is dispatched when this audiochannel is actually in used by the
-  // app or one of the sub-iframes.
-  attribute EventHandler onactivestatechanged;
-
-  [Throws]
-  DOMRequest getVolume();
-
-  [Throws]
-  DOMRequest setVolume(float aVolume);
-
-  [Throws]
-  DOMRequest getMuted();
-
-  [Throws]
-  DOMRequest setMuted(boolean aMuted);
-
-  [Throws]
-  DOMRequest isActive();
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -413,17 +413,16 @@ WEBIDL_FILES = [
     'BaseKeyframeTypes.webidl',
     'BatteryManager.webidl',
     'BeforeUnloadEvent.webidl',
     'BiquadFilterNode.webidl',
     'Blob.webidl',
     'BoxObject.webidl',
     'BroadcastChannel.webidl',
     'BrowserElement.webidl',
-    'BrowserElementAudioChannel.webidl',
     'BrowserElementDictionaries.webidl',
     'Cache.webidl',
     'CacheStorage.webidl',
     'CanvasCaptureMediaStream.webidl',
     'CanvasRenderingContext2D.webidl',
     'CaretPosition.webidl',
     'CDATASection.webidl',
     'ChannelMergerNode.webidl',