michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_FMRadio_h michael@0: #define mozilla_dom_FMRadio_h michael@0: michael@0: #include "AudioChannelAgent.h" michael@0: #include "FMRadioCommon.h" michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/HalTypes.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsWeakReference.h" michael@0: michael@0: class nsPIDOMWindow; michael@0: class nsIScriptContext; michael@0: michael@0: BEGIN_FMRADIO_NAMESPACE michael@0: michael@0: class DOMRequest; michael@0: michael@0: class FMRadio MOZ_FINAL : public DOMEventTargetHelper michael@0: , public hal::SwitchObserver michael@0: , public FMRadioEventObserver michael@0: , public nsSupportsWeakReference michael@0: , public nsIAudioChannelAgentCallback michael@0: , public nsIDOMEventListener michael@0: michael@0: { michael@0: friend class FMRadioRequest; michael@0: michael@0: public: michael@0: FMRadio(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK michael@0: michael@0: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) michael@0: michael@0: void Init(nsPIDOMWindow *aWindow); michael@0: void Shutdown(); michael@0: michael@0: /* hal::SwitchObserver */ michael@0: virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE; michael@0: /* FMRadioEventObserver */ michael@0: virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE; michael@0: michael@0: nsPIDOMWindow* GetParentObject() const michael@0: { michael@0: return GetOwner(); michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: static bool Enabled(); michael@0: michael@0: bool AntennaAvailable() const; michael@0: michael@0: Nullable GetFrequency() const; michael@0: michael@0: double FrequencyUpperBound() const; michael@0: michael@0: double FrequencyLowerBound() const; michael@0: michael@0: double ChannelWidth() const; michael@0: michael@0: already_AddRefed Enable(double aFrequency); michael@0: michael@0: already_AddRefed Disable(); michael@0: michael@0: already_AddRefed SetFrequency(double aFrequency); michael@0: michael@0: already_AddRefed SeekUp(); michael@0: michael@0: already_AddRefed SeekDown(); michael@0: michael@0: already_AddRefed CancelSeek(); michael@0: michael@0: IMPL_EVENT_HANDLER(enabled); michael@0: IMPL_EVENT_HANDLER(disabled); michael@0: IMPL_EVENT_HANDLER(antennaavailablechange); michael@0: IMPL_EVENT_HANDLER(frequencychange); michael@0: michael@0: // nsIDOMEventListener michael@0: NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); michael@0: michael@0: private: michael@0: ~FMRadio(); michael@0: michael@0: void SetCanPlay(bool aCanPlay); michael@0: void EnableAudioChannelAgent(); michael@0: michael@0: hal::SwitchState mHeadphoneState; michael@0: bool mAudioChannelAgentEnabled; michael@0: bool mHasInternalAntenna; michael@0: bool mIsShutdown; michael@0: michael@0: nsCOMPtr mAudioChannelAgent; michael@0: }; michael@0: michael@0: END_FMRADIO_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_FMRadio_h michael@0: