2012-11-29 14:52:03 -08:00
|
|
|
/* 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 "AudioChannelManager.h"
|
|
|
|
#include "nsIDOMClassInfo.h"
|
2013-02-08 08:34:47 -08:00
|
|
|
#include "mozilla/dom/AudioChannelManagerBinding.h"
|
2012-11-29 14:52:03 -08:00
|
|
|
|
|
|
|
using namespace mozilla::hal;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace system {
|
|
|
|
|
|
|
|
AudioChannelManager::AudioChannelManager()
|
|
|
|
: mState(SWITCH_STATE_UNKNOWN)
|
|
|
|
{
|
|
|
|
RegisterSwitchObserver(SWITCH_HEADPHONES, this);
|
|
|
|
mState = GetCurrentSwitchState(SWITCH_HEADPHONES);
|
2013-02-08 08:34:47 -08:00
|
|
|
SetIsDOMBinding();
|
2012-11-29 14:52:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
AudioChannelManager::~AudioChannelManager()
|
|
|
|
{
|
|
|
|
UnregisterSwitchObserver(SWITCH_HEADPHONES, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioChannelManager::Init(nsPIDOMWindow* aWindow)
|
|
|
|
{
|
|
|
|
BindToOwner(aWindow->IsOuterWindow() ?
|
|
|
|
aWindow->GetCurrentInnerWindow() : aWindow);
|
|
|
|
}
|
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
JSObject*
|
2013-04-25 09:29:54 -07:00
|
|
|
AudioChannelManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
2012-11-29 14:52:03 -08:00
|
|
|
{
|
2013-03-11 16:03:47 -07:00
|
|
|
return AudioChannelManagerBinding::Wrap(aCx, aScope, this);
|
2012-11-29 14:52:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioChannelManager::Notify(const SwitchEvent& aEvent)
|
|
|
|
{
|
2013-07-16 23:21:00 -07:00
|
|
|
mState = aEvent.status();
|
2012-11-29 14:52:03 -08:00
|
|
|
|
|
|
|
DispatchTrustedEvent(NS_LITERAL_STRING("headphoneschange"));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace system
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|