michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "WakeLockListener.h" michael@0: #include "MetroUtils.h" michael@0: michael@0: using namespace mozilla::widget::winrt; michael@0: michael@0: NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener) michael@0: michael@0: NS_IMETHODIMP michael@0: WakeLockListener::Callback(const nsAString& aTopic, const nsAString& aState) michael@0: { michael@0: if (!mDisplayRequest) { michael@0: if (FAILED(ActivateGenericInstance(RuntimeClass_Windows_System_Display_DisplayRequest, mDisplayRequest))) { michael@0: NS_WARNING("Failed to instantiate IDisplayRequest, wakelocks will be broken!"); michael@0: return NS_OK; michael@0: } michael@0: } michael@0: michael@0: if (aState.Equals(NS_LITERAL_STRING("locked-foreground"))) { michael@0: mDisplayRequest->RequestActive(); michael@0: } else { michael@0: mDisplayRequest->RequestRelease(); michael@0: } michael@0: michael@0: return NS_OK; michael@0: }