1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WAKE_LOCK_WAKE_LOCK_TYPE_H_
6 #define THIRD_PARTY_BLINK_RENDERER_MODULES_WAKE_LOCK_WAKE_LOCK_TYPE_H_
7 
8 #include <stdint.h>
9 
10 #include "services/device/public/mojom/wake_lock.mojom-blink.h"
11 #include "third_party/blink/renderer/modules/modules_export.h"
12 
13 namespace WTF {
14 
15 class String;
16 
17 }  // namespace WTF
18 
19 namespace blink {
20 
21 // This header contains types and utility functions for representing the
22 // WakeLockType enum as a C++ enum, and for converting between WakeLockType and
23 // device.mojom.WakeLockType.
24 
25 // https://w3c.github.io/screen-wake-lock/#the-wakelocktype-enum
26 enum class WakeLockType : int8_t { kScreen, kSystem, kMaxValue = kSystem };
27 
28 // Useful for creating arrays with size N, where N is the number of different
29 // wake lock types.
30 constexpr size_t kWakeLockTypeCount =
31     static_cast<size_t>(WakeLockType::kMaxValue) + 1;
32 
33 MODULES_EXPORT device::mojom::blink::WakeLockType ToMojomWakeLockType(
34     WakeLockType type);
35 
36 MODULES_EXPORT WakeLockType ToWakeLockType(const String& type);
37 
38 }  // namespace blink
39 
40 #endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_WAKE_LOCK_WAKE_LOCK_TYPE_H_
41