dom/speakermanager/SpeakerManager.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d404baf9e87b
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/. */
4
5 #ifndef mozilla_dom_SpeakerManager_h
6 #define mozilla_dom_SpeakerManager_h
7
8 #include "mozilla/DOMEventTargetHelper.h"
9 #include "mozilla/dom/MozSpeakerManagerBinding.h"
10
11 namespace mozilla {
12 namespace dom {
13 /* This class is used for UA to control devices's speaker status.
14 * After UA set the speaker status, the UA should handle the
15 * forcespeakerchange event and change the speaker status in UI.
16 * The device's speaker status would set back to normal when UA close the application.
17 */
18 class SpeakerManager MOZ_FINAL
19 : public DOMEventTargetHelper
20 , public nsIDOMEventListener
21 {
22 friend class SpeakerManagerService;
23 friend class SpeakerManagerServiceChild;
24
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_NSIDOMEVENTLISTENER
27
28 public:
29 void Init(nsPIDOMWindow* aWindow);
30
31 nsPIDOMWindow* GetParentObject() const;
32
33 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
34 /**
35 * WebIDL Interface
36 */
37 // Get this api's force speaker setting.
38 bool Forcespeaker();
39 // Force acoustic sound go through speaker. Don't force to speaker if application
40 // stay in the background and re-force when application
41 // go to foreground
42 void SetForcespeaker(bool aEnable);
43 // Get the device's speaker forced setting.
44 bool Speakerforced();
45
46 void SetAudioChannelActive(bool aIsActive);
47 IMPL_EVENT_HANDLER(speakerforcedchange)
48
49 static already_AddRefed<SpeakerManager>
50 Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
51
52 protected:
53 SpeakerManager();
54 ~SpeakerManager();
55 void DispatchSimpleEvent(const nsAString& aStr);
56 // This api's force speaker setting
57 bool mForcespeaker;
58 bool mVisible;
59 };
60
61 } // namespace dom
62 } // namespace mozilla
63
64 #endif // mozilla_dom_SpeakerManager_h

mercurial