Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_FMRadio_h |
michael@0 | 7 | #define mozilla_dom_FMRadio_h |
michael@0 | 8 | |
michael@0 | 9 | #include "AudioChannelAgent.h" |
michael@0 | 10 | #include "FMRadioCommon.h" |
michael@0 | 11 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 12 | #include "mozilla/HalTypes.h" |
michael@0 | 13 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 14 | #include "nsWeakReference.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsPIDOMWindow; |
michael@0 | 17 | class nsIScriptContext; |
michael@0 | 18 | |
michael@0 | 19 | BEGIN_FMRADIO_NAMESPACE |
michael@0 | 20 | |
michael@0 | 21 | class DOMRequest; |
michael@0 | 22 | |
michael@0 | 23 | class FMRadio MOZ_FINAL : public DOMEventTargetHelper |
michael@0 | 24 | , public hal::SwitchObserver |
michael@0 | 25 | , public FMRadioEventObserver |
michael@0 | 26 | , public nsSupportsWeakReference |
michael@0 | 27 | , public nsIAudioChannelAgentCallback |
michael@0 | 28 | , public nsIDOMEventListener |
michael@0 | 29 | |
michael@0 | 30 | { |
michael@0 | 31 | friend class FMRadioRequest; |
michael@0 | 32 | |
michael@0 | 33 | public: |
michael@0 | 34 | FMRadio(); |
michael@0 | 35 | |
michael@0 | 36 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 37 | NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK |
michael@0 | 38 | |
michael@0 | 39 | NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) |
michael@0 | 40 | |
michael@0 | 41 | void Init(nsPIDOMWindow *aWindow); |
michael@0 | 42 | void Shutdown(); |
michael@0 | 43 | |
michael@0 | 44 | /* hal::SwitchObserver */ |
michael@0 | 45 | virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE; |
michael@0 | 46 | /* FMRadioEventObserver */ |
michael@0 | 47 | virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | nsPIDOMWindow* GetParentObject() const |
michael@0 | 50 | { |
michael@0 | 51 | return GetOwner(); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 55 | |
michael@0 | 56 | static bool Enabled(); |
michael@0 | 57 | |
michael@0 | 58 | bool AntennaAvailable() const; |
michael@0 | 59 | |
michael@0 | 60 | Nullable<double> GetFrequency() const; |
michael@0 | 61 | |
michael@0 | 62 | double FrequencyUpperBound() const; |
michael@0 | 63 | |
michael@0 | 64 | double FrequencyLowerBound() const; |
michael@0 | 65 | |
michael@0 | 66 | double ChannelWidth() const; |
michael@0 | 67 | |
michael@0 | 68 | already_AddRefed<DOMRequest> Enable(double aFrequency); |
michael@0 | 69 | |
michael@0 | 70 | already_AddRefed<DOMRequest> Disable(); |
michael@0 | 71 | |
michael@0 | 72 | already_AddRefed<DOMRequest> SetFrequency(double aFrequency); |
michael@0 | 73 | |
michael@0 | 74 | already_AddRefed<DOMRequest> SeekUp(); |
michael@0 | 75 | |
michael@0 | 76 | already_AddRefed<DOMRequest> SeekDown(); |
michael@0 | 77 | |
michael@0 | 78 | already_AddRefed<DOMRequest> CancelSeek(); |
michael@0 | 79 | |
michael@0 | 80 | IMPL_EVENT_HANDLER(enabled); |
michael@0 | 81 | IMPL_EVENT_HANDLER(disabled); |
michael@0 | 82 | IMPL_EVENT_HANDLER(antennaavailablechange); |
michael@0 | 83 | IMPL_EVENT_HANDLER(frequencychange); |
michael@0 | 84 | |
michael@0 | 85 | // nsIDOMEventListener |
michael@0 | 86 | NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); |
michael@0 | 87 | |
michael@0 | 88 | private: |
michael@0 | 89 | ~FMRadio(); |
michael@0 | 90 | |
michael@0 | 91 | void SetCanPlay(bool aCanPlay); |
michael@0 | 92 | void EnableAudioChannelAgent(); |
michael@0 | 93 | |
michael@0 | 94 | hal::SwitchState mHeadphoneState; |
michael@0 | 95 | bool mAudioChannelAgentEnabled; |
michael@0 | 96 | bool mHasInternalAntenna; |
michael@0 | 97 | bool mIsShutdown; |
michael@0 | 98 | |
michael@0 | 99 | nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent; |
michael@0 | 100 | }; |
michael@0 | 101 | |
michael@0 | 102 | END_FMRADIO_NAMESPACE |
michael@0 | 103 | |
michael@0 | 104 | #endif // mozilla_dom_FMRadio_h |
michael@0 | 105 |