2012-01-20 07:24:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 07:24:00 +04:00
|
|
|
#ifndef mozilla_dom_power_PowerManager_h
|
|
|
|
#define mozilla_dom_power_PowerManager_h
|
|
|
|
|
2012-03-07 15:03:25 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsIDOMWakeLockListener.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsWeakReference.h"
|
2013-08-28 08:14:57 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-09-11 03:03:56 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2014-07-18 05:30:47 +04:00
|
|
|
#include "mozilla/dom/MozPowerManagerBinding.h"
|
2012-01-20 07:24:00 +04:00
|
|
|
|
2012-08-11 15:40:43 +04:00
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
2012-01-20 07:24:00 +04:00
|
|
|
namespace mozilla {
|
2013-09-11 03:03:56 +04:00
|
|
|
class ErrorResult;
|
|
|
|
|
2012-01-20 07:24:00 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class PowerManager final : public nsIDOMMozWakeLockListener
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsWrapperCache
|
2012-01-20 07:24:00 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 20:07:28 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-09-11 03:03:56 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager)
|
2012-03-07 15:03:25 +04:00
|
|
|
NS_DECL_NSIDOMMOZWAKELOCKLISTENER
|
2012-01-20 07:24:00 +04:00
|
|
|
|
2012-03-07 15:03:25 +04:00
|
|
|
nsresult Init(nsIDOMWindow *aWindow);
|
|
|
|
nsresult Shutdown();
|
|
|
|
|
2013-07-12 18:35:35 +04:00
|
|
|
static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
|
2012-08-11 15:40:43 +04:00
|
|
|
|
2013-09-11 03:03:56 +04:00
|
|
|
// WebIDL
|
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow;
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-11 03:03:56 +04:00
|
|
|
void Reboot(ErrorResult& aRv);
|
2014-07-18 05:30:47 +04:00
|
|
|
void FactoryReset(mozilla::dom::FactoryResetReason& aReason);
|
2013-09-11 03:03:56 +04: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 07:11:23 +04:00
|
|
|
bool KeyLightEnabled();
|
|
|
|
void SetKeyLightEnabled(bool aEnabled);
|
2013-09-11 03:03:56 +04:00
|
|
|
double ScreenBrightness();
|
|
|
|
void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
|
|
|
|
bool CpuSleepAllowed();
|
|
|
|
void SetCpuSleepAllowed(bool aAllowed);
|
2012-03-07 15:03:25 +04:00
|
|
|
|
2013-09-11 03:03:56 +04:00
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
~PowerManager() {}
|
|
|
|
|
2013-09-11 03:03:56 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2012-03-07 15:03:25 +04:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;
|
2012-01-20 07:24:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_power_PowerManager_h
|