2012-01-20 03:24:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-20 03:24:00 +00:00
|
|
|
#ifndef mozilla_dom_power_PowerManager_h
|
|
|
|
#define mozilla_dom_power_PowerManager_h
|
|
|
|
|
2012-03-07 11:03:25 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsIDOMWakeLockListener.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsWeakReference.h"
|
2013-08-28 04:14:57 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-09-10 23:03:56 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2014-07-18 01:30:47 +00:00
|
|
|
#include "mozilla/dom/MozPowerManagerBinding.h"
|
2012-01-20 03:24:00 +00:00
|
|
|
|
2012-08-11 11:40:43 +00:00
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
2012-01-20 03:24:00 +00:00
|
|
|
namespace mozilla {
|
2013-09-10 23:03:56 +00:00
|
|
|
class ErrorResult;
|
|
|
|
|
2012-01-20 03:24:00 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2013-09-10 23:03:56 +00:00
|
|
|
class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener
|
|
|
|
, public nsWrapperCache
|
2012-01-20 03:24:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 16:07:28 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-09-10 23:03:56 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager)
|
2012-03-07 11:03:25 +00:00
|
|
|
NS_DECL_NSIDOMMOZWAKELOCKLISTENER
|
2012-01-20 03:24:00 +00:00
|
|
|
|
2012-03-07 11:03:25 +00:00
|
|
|
nsresult Init(nsIDOMWindow *aWindow);
|
|
|
|
nsresult Shutdown();
|
|
|
|
|
2013-07-12 14:35:35 +00:00
|
|
|
static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
|
2012-08-11 11:40:43 +00:00
|
|
|
|
2013-09-10 23:03:56 +00:00
|
|
|
// WebIDL
|
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow;
|
|
|
|
}
|
2014-04-08 22:27:18 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-09-10 23:03:56 +00:00
|
|
|
void Reboot(ErrorResult& aRv);
|
2014-07-18 01:30:47 +00:00
|
|
|
void FactoryReset(mozilla::dom::FactoryResetReason& aReason);
|
2013-09-10 23:03:56 +00:00
|
|
|
void PowerOff(ErrorResult& aRv);
|
|
|
|
void AddWakeLockListener(nsIDOMMozWakeLockListener* aListener);
|
|
|
|
void RemoveWakeLockListener(nsIDOMMozWakeLockListener* aListener);
|
|
|
|
void GetWakeLockState(const nsAString& aTopic, nsAString& aState,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
bool ScreenEnabled();
|
|
|
|
void SetScreenEnabled(bool aEnabled);
|
2014-05-30 03:11:23 +00:00
|
|
|
bool KeyLightEnabled();
|
|
|
|
void SetKeyLightEnabled(bool aEnabled);
|
2013-09-10 23:03:56 +00:00
|
|
|
double ScreenBrightness();
|
|
|
|
void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
|
|
|
|
bool CpuSleepAllowed();
|
|
|
|
void SetCpuSleepAllowed(bool aAllowed);
|
2012-03-07 11:03:25 +00:00
|
|
|
|
2013-09-10 23:03:56 +00:00
|
|
|
private:
|
2014-06-23 19:56:07 +00:00
|
|
|
~PowerManager() {}
|
|
|
|
|
2013-09-10 23:03:56 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2012-03-07 11:03:25 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;
|
2012-01-20 03:24:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_power_PowerManager_h
|