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