1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/power/PowerManager.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef mozilla_dom_power_PowerManager_h 1.9 +#define mozilla_dom_power_PowerManager_h 1.10 + 1.11 +#include "nsCOMPtr.h" 1.12 +#include "nsTArray.h" 1.13 +#include "nsIDOMWakeLockListener.h" 1.14 +#include "nsIDOMWindow.h" 1.15 +#include "nsWeakReference.h" 1.16 +#include "nsCycleCollectionParticipant.h" 1.17 +#include "nsWrapperCache.h" 1.18 + 1.19 +class nsPIDOMWindow; 1.20 + 1.21 +namespace mozilla { 1.22 +class ErrorResult; 1.23 + 1.24 +namespace dom { 1.25 + 1.26 +class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener 1.27 + , public nsWrapperCache 1.28 +{ 1.29 +public: 1.30 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.31 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager) 1.32 + NS_DECL_NSIDOMMOZWAKELOCKLISTENER 1.33 + 1.34 + PowerManager() 1.35 + { 1.36 + SetIsDOMBinding(); 1.37 + } 1.38 + 1.39 + nsresult Init(nsIDOMWindow *aWindow); 1.40 + nsresult Shutdown(); 1.41 + 1.42 + static bool CheckPermission(nsPIDOMWindow*); 1.43 + 1.44 + static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*); 1.45 + 1.46 + // WebIDL 1.47 + nsIDOMWindow* GetParentObject() const 1.48 + { 1.49 + return mWindow; 1.50 + } 1.51 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.52 + void Reboot(ErrorResult& aRv); 1.53 + void FactoryReset(); 1.54 + void PowerOff(ErrorResult& aRv); 1.55 + void AddWakeLockListener(nsIDOMMozWakeLockListener* aListener); 1.56 + void RemoveWakeLockListener(nsIDOMMozWakeLockListener* aListener); 1.57 + void GetWakeLockState(const nsAString& aTopic, nsAString& aState, 1.58 + ErrorResult& aRv); 1.59 + bool ScreenEnabled(); 1.60 + void SetScreenEnabled(bool aEnabled); 1.61 + double ScreenBrightness(); 1.62 + void SetScreenBrightness(double aBrightness, ErrorResult& aRv); 1.63 + bool CpuSleepAllowed(); 1.64 + void SetCpuSleepAllowed(bool aAllowed); 1.65 + 1.66 +private: 1.67 + nsCOMPtr<nsIDOMWindow> mWindow; 1.68 + nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners; 1.69 +}; 1.70 + 1.71 +} // namespace dom 1.72 +} // namespace mozilla 1.73 + 1.74 +#endif // mozilla_dom_power_PowerManager_h