Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_system_AudioChannelManager_h
6 #define mozilla_dom_system_AudioChannelManager_h
8 #include "mozilla/DOMEventTargetHelper.h"
9 #include "mozilla/Hal.h"
10 #include "mozilla/HalTypes.h"
11 #include "AudioChannelService.h"
13 namespace mozilla {
14 namespace hal {
15 class SwitchEvent;
16 typedef Observer<SwitchEvent> SwitchObserver;
17 } // namespace hal
19 namespace dom {
20 namespace system {
22 class AudioChannelManager MOZ_FINAL
23 : public DOMEventTargetHelper
24 , public hal::SwitchObserver
25 , public nsIDOMEventListener
26 {
27 public:
28 AudioChannelManager();
29 virtual ~AudioChannelManager();
31 NS_DECL_ISUPPORTS_INHERITED
32 NS_DECL_NSIDOMEVENTLISTENER
34 void Notify(const hal::SwitchEvent& aEvent);
36 void Init(nsPIDOMWindow* aWindow);
38 /**
39 * WebIDL Interface
40 */
42 nsPIDOMWindow* GetParentObject() const
43 {
44 return GetOwner();
45 }
47 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
49 bool Headphones() const
50 {
51 // Bug 929139 - Remove the assert check for SWITCH_STATE_UNKNOWN.
52 // If any devices (ex: emulator) didn't have the corresponding sys node for
53 // headset switch state then GonkSwitch will report the unknown state.
54 // So it is possible to get unknown state here.
55 return mState != hal::SWITCH_STATE_OFF &&
56 mState != hal::SWITCH_STATE_UNKNOWN;
57 }
59 bool SetVolumeControlChannel(const nsAString& aChannel);
61 bool GetVolumeControlChannel(nsAString& aChannel);
63 IMPL_EVENT_HANDLER(headphoneschange)
65 private:
66 void NotifyVolumeControlChannelChanged();
68 hal::SwitchState mState;
69 int32_t mVolumeChannel;
70 };
72 } // namespace system
73 } // namespace dom
74 } // namespace mozilla
76 #endif // mozilla_dom_system_AudioChannelManager_h