1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_power_PowerManager_h
6 #define mozilla_dom_power_PowerManager_h
10 #include "nsIDOMWakeLockListener.h"
11 #include "nsIDOMWindow.h"
12 #include "nsWeakReference.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsWrapperCache.h"
23 class PowerManager MOZ_FINAL
: public nsIDOMMozWakeLockListener
24 , public nsWrapperCache
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager
)
29 NS_DECL_NSIDOMMOZWAKELOCKLISTENER
36 nsresult
Init(nsIDOMWindow
*aWindow
);
39 static already_AddRefed
<PowerManager
> CreateInstance(nsPIDOMWindow
*);
42 nsIDOMWindow
* GetParentObject() const
46 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
47 void Reboot(ErrorResult
& aRv
);
49 void PowerOff(ErrorResult
& aRv
);
50 void AddWakeLockListener(nsIDOMMozWakeLockListener
* aListener
);
51 void RemoveWakeLockListener(nsIDOMMozWakeLockListener
* aListener
);
52 void GetWakeLockState(const nsAString
& aTopic
, nsAString
& aState
,
55 void SetScreenEnabled(bool aEnabled
);
56 bool KeyLightEnabled();
57 void SetKeyLightEnabled(bool aEnabled
);
58 double ScreenBrightness();
59 void SetScreenBrightness(double aBrightness
, ErrorResult
& aRv
);
60 bool CpuSleepAllowed();
61 void SetCpuSleepAllowed(bool aAllowed
);
64 nsCOMPtr
<nsIDOMWindow
> mWindow
;
65 nsTArray
<nsCOMPtr
<nsIDOMMozWakeLockListener
> > mListeners
;
69 } // namespace mozilla
71 #endif // mozilla_dom_power_PowerManager_h