dom/speakermanager/SpeakerManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/speakermanager/SpeakerManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_dom_SpeakerManager_h
     1.9 +#define mozilla_dom_SpeakerManager_h
    1.10 +
    1.11 +#include "mozilla/DOMEventTargetHelper.h"
    1.12 +#include "mozilla/dom/MozSpeakerManagerBinding.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +namespace dom {
    1.16 +/* This class is used for UA to control devices's speaker status.
    1.17 + * After UA set the speaker status, the UA should handle the
    1.18 + * forcespeakerchange event and change the speaker status in UI.
    1.19 + * The device's speaker status would set back to normal when UA close the application.
    1.20 + */
    1.21 +class SpeakerManager MOZ_FINAL
    1.22 +  : public DOMEventTargetHelper
    1.23 +  , public nsIDOMEventListener
    1.24 +{
    1.25 +  friend class SpeakerManagerService;
    1.26 +  friend class SpeakerManagerServiceChild;
    1.27 +
    1.28 +  NS_DECL_ISUPPORTS_INHERITED
    1.29 +  NS_DECL_NSIDOMEVENTLISTENER
    1.30 +
    1.31 +public:
    1.32 +  void Init(nsPIDOMWindow* aWindow);
    1.33 +
    1.34 +  nsPIDOMWindow* GetParentObject() const;
    1.35 +
    1.36 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.37 +  /**
    1.38 +   * WebIDL Interface
    1.39 +   */
    1.40 +  // Get this api's force speaker setting.
    1.41 +  bool Forcespeaker();
    1.42 +  // Force acoustic sound go through speaker. Don't force to speaker if application
    1.43 +  // stay in the background and re-force when application
    1.44 +  // go to foreground
    1.45 +  void SetForcespeaker(bool aEnable);
    1.46 +  // Get the device's speaker forced setting.
    1.47 +  bool Speakerforced();
    1.48 +
    1.49 +  void SetAudioChannelActive(bool aIsActive);
    1.50 +  IMPL_EVENT_HANDLER(speakerforcedchange)
    1.51 +
    1.52 +  static already_AddRefed<SpeakerManager>
    1.53 +  Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
    1.54 +
    1.55 +protected:
    1.56 +  SpeakerManager();
    1.57 +  ~SpeakerManager();
    1.58 +  void DispatchSimpleEvent(const nsAString& aStr);
    1.59 +  // This api's force speaker setting
    1.60 +  bool mForcespeaker;
    1.61 +  bool mVisible;
    1.62 +};
    1.63 +
    1.64 +} // namespace dom
    1.65 +} // namespace mozilla
    1.66 +
    1.67 +#endif // mozilla_dom_SpeakerManager_h

mercurial