author Gijs Kruitbosch <>
Wed, 13 May 2015 22:18:00 +0100
changeset 260491 d5ba1bc97911bc35917c83ce5a92e873af38ec2c
parent 259646 a20c7910a82fa2df2f3398c1108d102bac9128b0
permissions -rw-r--r--
Bug 1164302 - pocket button gets lost after a restart, r=jaws a=dolske

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 */
#ifndef mozilla_dom_power_PowerManager_h
#define mozilla_dom_power_PowerManager_h

#include "nsCOMPtr.h"
#include "nsTArray.h"
#include "nsIDOMWakeLockListener.h"
#include "nsIDOMWindow.h"
#include "nsWeakReference.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/MozPowerManagerBinding.h"

class nsPIDOMWindow;

namespace mozilla {
class ErrorResult;

namespace dom {

class PowerManager final : public nsIDOMMozWakeLockListener
                             , public nsWrapperCache

  nsresult Init(nsIDOMWindow *aWindow);
  nsresult Shutdown();

  static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);

  // WebIDL
  nsIDOMWindow* GetParentObject() const
    return mWindow;
  virtual JSObject* WrapObject(JSContext* aCx) override;
  void Reboot(ErrorResult& aRv);
  void FactoryReset(mozilla::dom::FactoryResetReason& aReason);
  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);
  bool KeyLightEnabled();
  void SetKeyLightEnabled(bool aEnabled);
  double ScreenBrightness();
  void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
  bool CpuSleepAllowed();
  void SetCpuSleepAllowed(bool aAllowed);

  ~PowerManager() {}

  nsCOMPtr<nsIDOMWindow> mWindow;
  nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_power_PowerManager_h