Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / power / PowerManager.h
blob640113e0749cb6ae8868510a14aa732f5d62516f
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
8 #include "nsCOMPtr.h"
9 #include "nsTArray.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"
17 class nsPIDOMWindow;
19 namespace mozilla {
20 class ErrorResult;
22 namespace dom {
24 class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener
25 , public nsWrapperCache
27 public:
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager)
30 NS_DECL_NSIDOMMOZWAKELOCKLISTENER
32 PowerManager()
34 SetIsDOMBinding();
37 nsresult Init(nsIDOMWindow *aWindow);
38 nsresult Shutdown();
40 static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
42 // WebIDL
43 nsIDOMWindow* GetParentObject() const
45 return mWindow;
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,
54 ErrorResult& aRv);
55 bool ScreenEnabled();
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);
64 private:
65 ~PowerManager() {}
67 nsCOMPtr<nsIDOMWindow> mWindow;
68 nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;
71 } // namespace dom
72 } // namespace mozilla
74 #endif // mozilla_dom_power_PowerManager_h