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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_system_AudioChannelManager_h
|
|
|
|
#define mozilla_dom_system_AudioChannelManager_h
|
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
#include "mozilla/Hal.h"
|
2012-11-29 14:52:03 -08:00
|
|
|
#include "mozilla/HalTypes.h"
|
|
|
|
#include "nsDOMEventTargetHelper.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace hal {
|
|
|
|
class SwitchEvent;
|
|
|
|
typedef Observer<SwitchEvent> SwitchObserver;
|
|
|
|
} // namespace hal
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
namespace system {
|
|
|
|
|
|
|
|
class AudioChannelManager : public nsDOMEventTargetHelper
|
|
|
|
, public hal::SwitchObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AudioChannelManager();
|
|
|
|
virtual ~AudioChannelManager();
|
|
|
|
|
|
|
|
void Notify(const hal::SwitchEvent& aEvent);
|
|
|
|
|
|
|
|
void Init(nsPIDOMWindow* aWindow);
|
2013-02-08 08:34:47 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WebIDL Interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2013-02-08 08:34:47 -08:00
|
|
|
|
|
|
|
bool Headphones() const
|
|
|
|
{
|
2013-07-16 23:21:00 -07:00
|
|
|
MOZ_ASSERT(mState != hal::SWITCH_STATE_UNKNOWN);
|
|
|
|
return mState != hal::SWITCH_STATE_OFF;
|
2013-02-08 08:34:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(headphoneschange)
|
|
|
|
|
2012-11-29 14:52:03 -08:00
|
|
|
private:
|
|
|
|
hal::SwitchState mState;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace system
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_system_AudioChannelManager_h
|