michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef mozilla_dom_power_PowerManager_h michael@0: #define mozilla_dom_power_PowerManager_h michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIDOMWakeLockListener.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsWrapperCache.h" michael@0: michael@0: class nsPIDOMWindow; michael@0: michael@0: namespace mozilla { michael@0: class ErrorResult; michael@0: michael@0: namespace dom { michael@0: michael@0: class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener michael@0: , public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager) michael@0: NS_DECL_NSIDOMMOZWAKELOCKLISTENER michael@0: michael@0: PowerManager() michael@0: { michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: nsresult Init(nsIDOMWindow *aWindow); michael@0: nsresult Shutdown(); michael@0: michael@0: static bool CheckPermission(nsPIDOMWindow*); michael@0: michael@0: static already_AddRefed CreateInstance(nsPIDOMWindow*); michael@0: michael@0: // WebIDL michael@0: nsIDOMWindow* GetParentObject() const michael@0: { michael@0: return mWindow; michael@0: } michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: void Reboot(ErrorResult& aRv); michael@0: void FactoryReset(); michael@0: void PowerOff(ErrorResult& aRv); michael@0: void AddWakeLockListener(nsIDOMMozWakeLockListener* aListener); michael@0: void RemoveWakeLockListener(nsIDOMMozWakeLockListener* aListener); michael@0: void GetWakeLockState(const nsAString& aTopic, nsAString& aState, michael@0: ErrorResult& aRv); michael@0: bool ScreenEnabled(); michael@0: void SetScreenEnabled(bool aEnabled); michael@0: double ScreenBrightness(); michael@0: void SetScreenBrightness(double aBrightness, ErrorResult& aRv); michael@0: bool CpuSleepAllowed(); michael@0: void SetCpuSleepAllowed(bool aAllowed); michael@0: michael@0: private: michael@0: nsCOMPtr mWindow; michael@0: nsTArray > mListeners; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_power_PowerManager_h