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 {
|
|
|
|
|
2013-09-11 03:03:56 +04:00
|
|
|
class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener
|
|
|
|
, 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;
|
|
|
|
}
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) MOZ_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
|