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 file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_SpeakerManager_h michael@0: #define mozilla_dom_SpeakerManager_h michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/dom/MozSpeakerManagerBinding.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: /* This class is used for UA to control devices's speaker status. michael@0: * After UA set the speaker status, the UA should handle the michael@0: * forcespeakerchange event and change the speaker status in UI. michael@0: * The device's speaker status would set back to normal when UA close the application. michael@0: */ michael@0: class SpeakerManager MOZ_FINAL michael@0: : public DOMEventTargetHelper michael@0: , public nsIDOMEventListener michael@0: { michael@0: friend class SpeakerManagerService; michael@0: friend class SpeakerManagerServiceChild; michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: michael@0: public: michael@0: void Init(nsPIDOMWindow* aWindow); michael@0: michael@0: nsPIDOMWindow* GetParentObject() const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: /** michael@0: * WebIDL Interface michael@0: */ michael@0: // Get this api's force speaker setting. michael@0: bool Forcespeaker(); michael@0: // Force acoustic sound go through speaker. Don't force to speaker if application michael@0: // stay in the background and re-force when application michael@0: // go to foreground michael@0: void SetForcespeaker(bool aEnable); michael@0: // Get the device's speaker forced setting. michael@0: bool Speakerforced(); michael@0: michael@0: void SetAudioChannelActive(bool aIsActive); michael@0: IMPL_EVENT_HANDLER(speakerforcedchange) michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); michael@0: michael@0: protected: michael@0: SpeakerManager(); michael@0: ~SpeakerManager(); michael@0: void DispatchSimpleEvent(const nsAString& aStr); michael@0: // This api's force speaker setting michael@0: bool mForcespeaker; michael@0: bool mVisible; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_SpeakerManager_h