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"
15 #include "mozilla/dom/MozPowerManagerBinding.h"
24 class PowerManager MOZ_FINAL
: public nsIDOMMozWakeLockListener
25 , public nsWrapperCache
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager
)
30 NS_DECL_NSIDOMMOZWAKELOCKLISTENER
37 nsresult
Init(nsIDOMWindow
*aWindow
);
40 static already_AddRefed
<PowerManager
> CreateInstance(nsPIDOMWindow
*);
43 nsIDOMWindow
* GetParentObject() const
47 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
48 void Reboot(ErrorResult
& aRv
);
49 void FactoryReset(mozilla::dom::FactoryResetReason
& aReason
);
50 void PowerOff(ErrorResult
& aRv
);
51 void AddWakeLockListener(nsIDOMMozWakeLockListener
* aListener
);
52 void RemoveWakeLockListener(nsIDOMMozWakeLockListener
* aListener
);
53 void GetWakeLockState(const nsAString
& aTopic
, nsAString
& aState
,
56 void SetScreenEnabled(bool aEnabled
);
57 bool KeyLightEnabled();
58 void SetKeyLightEnabled(bool aEnabled
);
59 double ScreenBrightness();
60 void SetScreenBrightness(double aBrightness
, ErrorResult
& aRv
);
61 bool CpuSleepAllowed();
62 void SetCpuSleepAllowed(bool aAllowed
);
67 nsCOMPtr
<nsIDOMWindow
> mWindow
;
68 nsTArray
<nsCOMPtr
<nsIDOMMozWakeLockListener
> > mListeners
;
72 } // namespace mozilla
74 #endif // mozilla_dom_power_PowerManager_h