widget/windows/winrt/WakeLockListener.cpp

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:f3ab81640934
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "WakeLockListener.h"
6 #include "MetroUtils.h"
7
8 using namespace mozilla::widget::winrt;
9
10 NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener)
11
12 NS_IMETHODIMP
13 WakeLockListener::Callback(const nsAString& aTopic, const nsAString& aState)
14 {
15 if (!mDisplayRequest) {
16 if (FAILED(ActivateGenericInstance(RuntimeClass_Windows_System_Display_DisplayRequest, mDisplayRequest))) {
17 NS_WARNING("Failed to instantiate IDisplayRequest, wakelocks will be broken!");
18 return NS_OK;
19 }
20 }
21
22 if (aState.Equals(NS_LITERAL_STRING("locked-foreground"))) {
23 mDisplayRequest->RequestActive();
24 } else {
25 mDisplayRequest->RequestRelease();
26 }
27
28 return NS_OK;
29 }

mercurial